Fix /storeraw swagger docs
@@ -5,6 +5,7 @@ import com.quorum.tessera.api.StoreRawResponse;
import com.quorum.tessera.core.api.ServiceFactory;
import com.quorum.tessera.encryption.PublicKey;
import com.quorum.tessera.transaction.TransactionManager;
+import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -42,15 +43,8 @@ public class RawTransactionResource {
this.transactionManager = Objects.requireNonNull(transactionManager);
}
- @Operation(
- summary = "/storeraw",
- operationId = "encryptAndStore",
- description = "encrypts a payload and stores result in the \"raw\" database")
- @ApiResponse(
- responseCode = "200",
- description = "hash of encrypted payload",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = StoreRawResponse.class)))
- @ApiResponse(responseCode = "404", description = "'from' key in request body not found")
+ // hide this operation from swagger generation; the /storeraw operation is overloaded and must be documented in a single place
+ @Hidden
@POST
@Path(ENDPOINT_STORE_RAW)
@Consumes(APPLICATION_JSON)
@@ -64,24 +58,34 @@ public class RawTransactionResource {
return Response.ok().type(APPLICATION_JSON).entity(storeRawResponse).build();
}
+ // path /storeraw is overloaded (application/json and application/vnd.tessera-2.1+json); swagger annotations cannot handle situations like this so this operation documents both
@Operation(
summary = "/storeraw",
- operationId = "encryptAndStore",
- description = "encrypts a payload and stores result in the \"raw\" database")
+ operationId = "encryptAndStoreVersion",
+ description = "encrypts a payload and stores result in the \"raw\" database",
+ requestBody =
+ @RequestBody(
+ required = true,
+ content = {
+ @Content(
+ mediaType = APPLICATION_JSON,
+ schema = @Schema(implementation = StoreRawRequest.class)),
+ @Content(
+ mediaType = MIME_TYPE_JSON_2_1,
+ schema = @Schema(implementation = StoreRawRequest.class))}))
@ApiResponse(
responseCode = "200",
description = "hash of encrypted payload",
- content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = StoreRawResponse.class)))
+ content = {
+ @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = StoreRawResponse.class)),
+ @Content(mediaType = MIME_TYPE_JSON_2_1, schema = @Schema(implementation = StoreRawResponse.class))
+ })
@ApiResponse(responseCode = "404", description = "'from' key in request body not found")
@POST
@Path(ENDPOINT_STORE_RAW)
@Consumes(MIME_TYPE_JSON_2_1)
@Produces(MIME_TYPE_JSON_2_1)
- public Response storeVersion21(
- @RequestBody(required = true, content = @Content(schema = @Schema(implementation = StoreRawRequest.class)))
- @NotNull
- @Valid
- final StoreRawRequest request) {
+ public Response storeVersion21(@NotNull @Valid final StoreRawRequest request) {
final StoreRawResponse storeRawResponse = this.forwardRequest(request);
return Response.ok().type(MIME_TYPE_JSON_2_1).entity(storeRawResponse).build();
}
