From 12e2b0d4f0f9104b970c406048321a1abf160359 Mon Sep 17 00:00:00 2001 From: Darko Date: Fri, 15 Nov 2024 12:04:09 -0400 Subject: [PATCH] I18N-1322 - Generate & document OpenAPI Specification Removed unnecessary @ApiResponses annotations --- webapp/pom.xml | 3 ++- .../com/box/l10n/mojito/SwaggerConfiguration.java | 6 +++++- .../box/l10n/mojito/rest/asset/VirtualAssetWS.java | 14 -------------- .../mojito/rest/repository/BranchStatisticWS.java | 14 -------------- .../l10n/mojito/rest/screenshot/ScreenshotWS.java | 2 -- 5 files changed, 7 insertions(+), 32 deletions(-) diff --git a/webapp/pom.xml b/webapp/pom.xml index 4ffa071573..fcb8366968 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -20,6 +20,7 @@ 1.11.0 v20.18.0 8.2.0 + 2.6.0 @@ -143,7 +144,7 @@ org.springdoc springdoc-openapi-starter-webmvc-ui - 2.6.0 + ${springdoc.version} diff --git a/webapp/src/main/java/com/box/l10n/mojito/SwaggerConfiguration.java b/webapp/src/main/java/com/box/l10n/mojito/SwaggerConfiguration.java index 5cea421960..bb6c9bb8b6 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/SwaggerConfiguration.java +++ b/webapp/src/main/java/com/box/l10n/mojito/SwaggerConfiguration.java @@ -2,18 +2,22 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class SwaggerConfiguration { + @Value("${build.version}") + private String buildVersion; + @Bean public OpenAPI openAPI() { return new OpenAPI() .info( new Info() .title("Mojito API") - .version("0.111-SNAPSHOT") + .version(buildVersion) .description("Mojito API Documentation")); } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/rest/asset/VirtualAssetWS.java b/webapp/src/main/java/com/box/l10n/mojito/rest/asset/VirtualAssetWS.java index 077eec9e50..3a383a0ecf 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/rest/asset/VirtualAssetWS.java +++ b/webapp/src/main/java/com/box/l10n/mojito/rest/asset/VirtualAssetWS.java @@ -10,8 +10,6 @@ import com.box.l10n.mojito.service.asset.VirutalAssetMissingTextUnitException; import com.box.l10n.mojito.service.pollableTask.PollableFuture; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,10 +45,6 @@ public VirtualAsset createOrUpdateVirtualAsset(@RequestBody VirtualAsset virtual } @Operation(summary = "Create Text Units for a specific Virtual Asset asynchronously") - @ApiResponses( - value = { - @ApiResponse(responseCode = "200", description = "Successfully created a Pollable Task") - }) @RequestMapping( value = "/api/virtualAssets/{assetId}/textUnits", method = RequestMethod.POST, @@ -67,10 +61,6 @@ public PollableTask addTextUnits( } @Operation(summary = "Update Text Units for a specific Virtual Asset asynchronously") - @ApiResponses( - value = { - @ApiResponse(responseCode = "200", description = "Successfully created a Pollable Task") - }) @RequestMapping( value = "/api/virtualAssets/{assetId}/textUnits", method = RequestMethod.PUT, @@ -97,10 +87,6 @@ public void deleteTextUnit( } @Operation(summary = "Create Text Units for a specific Virtual Asset asynchronously") - @ApiResponses( - value = { - @ApiResponse(responseCode = "200", description = "Successfully created a Pollable Task") - }) @RequestMapping( value = "/api/virtualAssets/{assetId}/locale/{localeId}/textUnits", method = RequestMethod.POST, diff --git a/webapp/src/main/java/com/box/l10n/mojito/rest/repository/BranchStatisticWS.java b/webapp/src/main/java/com/box/l10n/mojito/rest/repository/BranchStatisticWS.java index 4c93f803d9..4b0fcfd1d5 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/rest/repository/BranchStatisticWS.java +++ b/webapp/src/main/java/com/box/l10n/mojito/rest/repository/BranchStatisticWS.java @@ -23,8 +23,6 @@ import com.box.l10n.mojito.service.branch.SparseBranchStatisticRepository; import com.fasterxml.jackson.annotation.JsonView; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import java.time.ZonedDateTime; import java.util.List; import java.util.stream.Collectors; @@ -60,12 +58,6 @@ public class BranchStatisticWS { @Autowired BranchTextUnitStatisticRepository branchTextUnitStatisticRepository; @Operation(summary = "Get paginated Branch Statistics for a given set of parameters") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "Successfully retrieved paginated Branch Statistics") - }) @JsonView(View.BranchStatistic.class) @RequestMapping( value = "/api/branchStatistics", @@ -136,12 +128,6 @@ public Page getBranchesOfRepository( } @Operation(summary = "Get Branch Text Unit Statistics paginated for a specific Branch Statistic") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "Successfully retrieved paginated Branch Text Unit Statistics") - }) @JsonView(View.BranchTextUnitStatistic.class) @RequestMapping( value = "/api/branchStatistics/{id}/branchTextUnitStatistics", diff --git a/webapp/src/main/java/com/box/l10n/mojito/rest/screenshot/ScreenshotWS.java b/webapp/src/main/java/com/box/l10n/mojito/rest/screenshot/ScreenshotWS.java index 267de95c61..ee9cf9a8d2 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/rest/screenshot/ScreenshotWS.java +++ b/webapp/src/main/java/com/box/l10n/mojito/rest/screenshot/ScreenshotWS.java @@ -10,8 +10,6 @@ import com.box.l10n.mojito.service.tm.search.SearchType; import com.fasterxml.jackson.annotation.JsonView; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger;