From 6cec77062d3d5422bce5916239df841f99464e6c Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Thu, 1 Aug 2024 21:17:29 +0200 Subject: [PATCH] fix: return type in openapi for mappings that return strings (closes #1394) --- .../controller/api/v1/interfaces/IApiKeysController.java | 2 +- .../controller/api/v1/interfaces/IPagesController.java | 6 ++++-- .../controller/api/v1/interfaces/IVersionsController.java | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IApiKeysController.java b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IApiKeysController.java index 45e860680..a24fe101b 100644 --- a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IApiKeysController.java +++ b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IApiKeysController.java @@ -32,7 +32,7 @@ public interface IApiKeysController { tags = "API Keys" ) @ApiResponses({ - @ApiResponse(responseCode = "201", description = "Key created", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "201", description = "Key created", content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "401", description = "Api session missing, invalid or expired"), @ApiResponse(responseCode = "403", description = "Not enough permissions to use this endpoint")}) @PostMapping(path = "/keys", produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) diff --git a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IPagesController.java b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IPagesController.java index 8007bcb56..28c03818e 100644 --- a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IPagesController.java +++ b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IPagesController.java @@ -4,6 +4,8 @@ import io.papermc.hangar.model.internal.api.requests.StringContent; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +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.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -27,7 +29,7 @@ public interface IPagesController { tags = "Pages" ) @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "401", description = "Api session missing, invalid or expired"), @ApiResponse(responseCode = "403", description = "Not enough permissions to use this endpoint") }) @@ -48,7 +50,7 @@ default String getMainPage(@Parameter(description = "The author of the project t tags = "Pages" ) @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "401", description = "Api session missing, invalid or expired"), @ApiResponse(responseCode = "403", description = "Not enough permissions to use this endpoint") }) diff --git a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IVersionsController.java b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IVersionsController.java index c7c6259f0..82d14397c 100644 --- a/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IVersionsController.java +++ b/backend/src/main/java/io/papermc/hangar/controller/api/v1/interfaces/IVersionsController.java @@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Encoding; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -124,7 +125,7 @@ default PaginatedResult getVersions(@Parameter(description = "The autho tags = "Versions" ) @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "401", description = "Api session missing, invalid or expired"), @ApiResponse(responseCode = "403", description = "Not enough permissions to use this endpoint") }) @@ -146,7 +147,7 @@ default String getLatestReleaseVersion(@Parameter(description = "The author of t tags = "Versions" ) @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Ok"), + @ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.TEXT_PLAIN_VALUE, schema = @Schema(type = "string"))), @ApiResponse(responseCode = "401", description = "Api session missing, invalid or expired"), @ApiResponse(responseCode = "403", description = "Not enough permissions to use this endpoint") })