From 604e366263cd453c0ea64c74e2ada64391d3eb69 Mon Sep 17 00:00:00 2001 From: Bram Buitendijk Date: Thu, 11 Mar 2021 08:56:40 +0100 Subject: [PATCH 1/2] Add @ApiResponses --- .../java/nl/knaw/huc/resources/rest/TypesResource.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/TypesResource.java b/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/TypesResource.java index 90c6bd5b..d8e2a7e8 100644 --- a/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/TypesResource.java +++ b/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/TypesResource.java @@ -2,6 +2,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import nl.knaw.huc.api.FormType; import nl.knaw.huc.api.ResultType; import nl.knaw.huc.core.Type; @@ -41,6 +43,7 @@ public TypesResource(TypeService typeService) { @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Create type") + @ApiResponses(value = {@ApiResponse(code = 200, response = ResultType.class, message = "OK")}) public Response createType( @Valid @NotNull FormType form ) { @@ -54,6 +57,8 @@ public Response createType( @GET @Produces(APPLICATION_JSON) @ApiOperation(value = "Retrieve types") + @ApiResponses(value = {@ApiResponse(code = 200, response = ResultType.class, responseContainer = "List", + message = "OK")}) public Response getTypes() { log.debug("Retrieve all types"); var all = typeService @@ -68,7 +73,8 @@ public Response getTypes() { @GET @Path("/{id}") @Produces(APPLICATION_JSON) - @ApiOperation(value = "Retrieve types") + @ApiOperation(value = "Retrieve type") + @ApiResponses(value = {@ApiResponse(code = 200, response = ResultType.class, message = "OK")}) public Response getType( @NotNull @PathParam("id") Short id ) { @@ -83,6 +89,7 @@ public Response getType( @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Create or update type") + @ApiResponses(value = {@ApiResponse(code = 200, response = ResultType.class, message = "OK")}) public Response putType( @NotNull @PathParam("id") Short id, @NotNull @Valid FormType form @@ -98,6 +105,7 @@ public Response putType( @DELETE @Path("/{id}") @ApiOperation(value = "Delete type") + @ApiResponses(value = {@ApiResponse(code = 200, message = "OK")}) public Response deleteType( @NotNull @PathParam("id") Short id ) { From 7b14370e1fd5e7f73581fc84de66f3a4045af9f8 Mon Sep 17 00:00:00 2001 From: Bram Buitendijk Date: Thu, 11 Mar 2021 08:57:13 +0100 Subject: [PATCH 2/2] rename method for swagger --- .../java/nl/knaw/huc/resources/rest/FileMetadataResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/FileMetadataResource.java b/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/FileMetadataResource.java index d43fa250..e7c2f93f 100644 --- a/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/FileMetadataResource.java +++ b/textrepo-app/src/main/java/nl/knaw/huc/resources/rest/FileMetadataResource.java @@ -47,7 +47,7 @@ public FileMetadataResource(FileMetadataService fileMetadataService) { @Produces(APPLICATION_JSON) @ApiOperation(value = POST_ERROR_MSG) @ApiResponses(value = {@ApiResponse(code = 405, message = POST_ERROR_MSG)}) - public Response postFileMetadata() { + public Response postFileMetadataIsNotAllowed() { throw new MethodNotAllowedException(POST_ERROR_MSG); }