Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
feat!: force bump to 1.0
Browse files Browse the repository at this point in the history
update api docs to mirror other services
  • Loading branch information
mike-audi committed Apr 1, 2023
1 parent d73f7bf commit 523a034
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@

package com.mytiki.l0_storage.features.latest.report;

import com.mytiki.l0_storage.utilities.Constants;
import com.mytiki.spring_rest_api.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.RolesAllowed;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@Tag(name = "STORAGE")
@RestController
@RequestMapping(value = ReportController.PATH_CONTROLLER)
public class ReportController {
Expand All @@ -29,13 +23,7 @@ public ReportController(ReportService service) {
}

@RolesAllowed("REMOTE")
@Operation(operationId = Constants.PROJECT_DASH_PATH + "-report-post",
summary = "Report Usage",
description = "Submit a usage report (handled automatically by Upload)",
security = @SecurityRequirement(name = "remote"),
responses = {
@ApiResponse(responseCode = "204", description = "No Content", content = @Content),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content)})
@Operation(hidden = true)
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void post(@RequestBody ReportAOReq body){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import com.mytiki.spring_rest_api.ApiConstants;
import com.mytiki.spring_rest_api.ApiExceptionBuilder;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.HttpStatus;
Expand All @@ -25,7 +22,7 @@

import java.security.Principal;

@Tag(name = "STORAGE")
@Tag(name = "")
@RestController
@RequestMapping(value = TokenController.PATH_CONTROLLER)
public class TokenController {
Expand All @@ -41,13 +38,7 @@ public TokenController(TokenService service) {
@Operation(operationId = Constants.PROJECT_DASH_PATH + "-token-post",
summary = "Request Access Token",
description = "Request an access token for uploading to storage bucket",
security = @SecurityRequirement(name = "jwt"),
responses = {
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(schema = @Schema(implementation = TokenAORsp.class))),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content),
@ApiResponse(responseCode = "417", description = "Expectation Failed", content = @Content)})
security = @SecurityRequirement(name = "oauth"))
@RequestMapping(method = RequestMethod.POST)
public TokenAORsp post(
Authentication authentication,
Expand Down
67 changes: 27 additions & 40 deletions src/main/java/com/mytiki/l0_storage/main/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.security.*;
import io.swagger.v3.oas.models.servers.Server;
import jakarta.annotation.PostConstruct;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
Expand All @@ -33,6 +33,7 @@

import java.security.Security;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;

@Import({
Expand All @@ -54,7 +55,7 @@ public OpenAPI oenAPI(@Value("${springdoc.version}") String appVersion) {
return new OpenAPI()
.info(new Info()
.title("L0 Storage")
.description("Long-term immutable storage")
.description("Immutable Storage Service")
.version(appVersion)
.license(new License()
.name("MIT")
Expand All @@ -63,43 +64,29 @@ public OpenAPI oenAPI(@Value("${springdoc.version}") String appVersion) {
new Server()
.url("https://storage.l0.mytiki.com")))
.components(new Components()
.addSecuritySchemes("remote",
new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("basic"))
.addSecuritySchemes("jwt",
new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")))
.path("/api/latest/upload",
new PathItem().post(
new Operation()
.tags(Collections.singletonList("STORAGE"))
.operationId(Constants.PROJECT_DASH_PATH + "-upload-post")
.summary("Upload Content")
.description("Upload a block/pub.key to storage bucket")
.requestBody(new RequestBody()
.content(new Content()
.addMediaType("application/json",
new MediaType()
.schema(new JsonSchema()
.type("object")
.addProperty("key", new StringSchema())
.addProperty("content", new StringSchema())
))))
.responses(new ApiResponses()
.addApiResponse("201",
new ApiResponse().description("Created"))
.addApiResponse("400",
new ApiResponse().description("Bad Request"))
.addApiResponse("401",
new ApiResponse().description("Unauthorized"))
.addApiResponse("405",
new ApiResponse().description("Method Not Allowed"))
.addApiResponse("413",
new ApiResponse().description("Payload Too Large"))
.addApiResponse("424",
new ApiResponse().description("Failed Dependency")))));
.addSecuritySchemes("oauth", new SecurityScheme()
.type(SecurityScheme.Type.OAUTH2)
.flows(new OAuthFlows()
.clientCredentials(new OAuthFlow()
.tokenUrl("https://auth.l0.mytiki.com/api/latest/oauth/token")
.refreshUrl("https://auth.l0.mytiki.com/api/latest/oauth/token")
.scopes(new Scopes().addString("storage","this service")))))
.addSecuritySchemes("jwt", new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")))
.path("/api/latest/upload", new PathItem().post(new Operation()
.tags(Collections.singletonList(""))
.operationId(Constants.PROJECT_DASH_PATH + "-upload-post")
.summary("Upload Content")
.security(List.of(new SecurityRequirement().addList("jwt")))
.description("Upload a block/pub.key to storage bucket")
.requestBody(new RequestBody().content(new Content()
.addMediaType("application/json", new MediaType()
.schema(new JsonSchema().type("object")
.addProperty("key", new StringSchema())
.addProperty("content", new StringSchema())))))
.responses(new ApiResponses()
.addApiResponse("201", new ApiResponse().description("Created")))));
}
}

0 comments on commit 523a034

Please sign in to comment.