From 2d0a73a458d83821716a5286939e079e903bf642 Mon Sep 17 00:00:00 2001 From: christosarvanitis Date: Tue, 26 Nov 2024 15:54:49 +0200 Subject: [PATCH 1/2] fix(openapi): Rewrite Swagger to OpenAPI annotations --- gradle.properties | 2 +- rosco-core/rosco-core.gradle | 1 + .../netflix/spinnaker/rosco/api/Bake.groovy | 4 +-- .../spinnaker/rosco/api/BakeRequest.groovy | 34 +++++++++---------- .../spinnaker/rosco/api/BakeStatus.groovy | 6 ++-- rosco-web/rosco-web.gradle | 2 +- .../rosco/controllers/BakeryController.groovy | 22 ++++++------ 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/gradle.properties b/gradle.properties index 8fb17b695..110fcd2be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -korkVersion=7.245.0 +korkVersion=7.246.0 org.gradle.parallel=true spinnakerGradleVersion=8.32.1 targetJava17=true diff --git a/rosco-core/rosco-core.gradle b/rosco-core/rosco-core.gradle index 7021b2019..8df286d94 100644 --- a/rosco-core/rosco-core.gradle +++ b/rosco-core/rosco-core.gradle @@ -6,6 +6,7 @@ dependencies { implementation "com.netflix.frigga:frigga" implementation "io.spinnaker.kork:kork-jedis" implementation "io.spinnaker.kork:kork-retrofit" + implementation "io.swagger.core.v3:swagger-annotations" implementation "io.spinnaker.kork:kork-swagger" implementation "io.spinnaker.kork:kork-web" implementation "com.squareup.retrofit2:converter-jackson" diff --git a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/Bake.groovy b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/Bake.groovy index 2dfd70d95..9bcd83faa 100644 --- a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/Bake.groovy +++ b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/Bake.groovy @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude import groovy.transform.CompileStatic import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema import com.netflix.spinnaker.kork.artifacts.model.Artifact /** @@ -32,7 +32,7 @@ import com.netflix.spinnaker.kork.artifacts.model.Artifact @EqualsAndHashCode(includes = "id") @ToString(includeNames = true) class Bake { - @ApiModelProperty(value="The id of the bake job.") + @Schema(description ="The id of the bake job.") String id String ami String image_name diff --git a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeRequest.groovy b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeRequest.groovy index dd521685e..b083bfd41 100644 --- a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeRequest.groovy +++ b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeRequest.groovy @@ -25,7 +25,7 @@ import com.netflix.spinnaker.rosco.providers.util.packagespecific.NupkgPackageUt import com.netflix.spinnaker.rosco.providers.util.packagespecific.RpmPackageUtil import groovy.transform.CompileStatic import groovy.transform.Immutable -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema /** * A request to bake a new machine image. @@ -37,30 +37,30 @@ import io.swagger.annotations.ApiModelProperty class BakeRequest { // A generated uuid which will identify the request and be used as the jobId when running the bake - @ApiModelProperty(value = "A generated UUID which will be used to identify the effective packer bake", accessMode = ApiModelProperty.AccessMode.READ_ONLY) + @Schema(description= "A generated UUID which will be used to identify the effective packer bake", accessMode = Schema.AccessMode.READ_ONLY) String request_id = UUID.randomUUID().toString() String user - @ApiModelProperty("The package(s) to install, as a space-delimited string") @JsonProperty("package") @SerializedName("package") + @Schema(description="The package(s) to install, as a space-delimited string") @JsonProperty("package") @SerializedName("package") String package_name - @ApiModelProperty("The package(s) to install, as Spinnaker artifacts") + @Schema(description="The package(s) to install, as Spinnaker artifacts") List package_artifacts - @ApiModelProperty("The CI server") + @Schema(description="The CI server") String build_host - @ApiModelProperty("The CI job") + @Schema(description="The CI job") String job - @ApiModelProperty("The CI build number") + @Schema(description="The CI build number") String build_number - @ApiModelProperty("The commit hash of the CI build") + @Schema(description="The commit hash of the CI build") String commit_hash - @ApiModelProperty("The CI Build Url") + @Schema(description="The CI Build Url") String build_info_url - @ApiModelProperty("The target platform") + @Schema(description="The target platform") CloudProviderType cloud_provider_type Label base_label - @ApiModelProperty("The named base image to resolve from rosco's configuration") + @Schema(description="The named base image to resolve from rosco's configuration") String base_os String base_name - @ApiModelProperty("The explicit machine image to use, instead of resolving one from rosco's configuration") + @Schema(description="The explicit machine image to use, instead of resolving one from rosco's configuration") String base_ami VmType vm_type StoreType store_type @@ -69,17 +69,17 @@ class BakeRequest { String ami_suffix Boolean upgrade String instance_type - @ApiModelProperty("The image owner organization") + @Schema(description="The image owner organization") String organization - @ApiModelProperty("The explicit packer template to use, instead of resolving one from rosco's configuration") + @Schema(description="The explicit packer template to use, instead of resolving one from rosco's configuration") String template_file_name - @ApiModelProperty("A map of key/value pairs to add to the packer command") + @Schema(description="A map of key/value pairs to add to the packer command") Map extended_attributes - @ApiModelProperty("The name of a json file containing key/value pairs to add to the packer command (must be in the same location as the template file)") + @Schema(description="The name of a json file containing key/value pairs to add to the packer command (must be in the same location as the template file)") String var_file_name - @ApiModelProperty("The name of a configured account to use when baking the image") + @Schema(description="The name of a configured account to use when baking the image") String account_name String spinnaker_execution_id diff --git a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeStatus.groovy b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeStatus.groovy index 15c2f3b38..01e29000b 100644 --- a/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeStatus.groovy +++ b/rosco-core/src/main/groovy/com/netflix/spinnaker/rosco/api/BakeStatus.groovy @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore import groovy.transform.CompileStatic import groovy.transform.EqualsAndHashCode import groovy.transform.ToString -import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema /** * The state of a bake as returned by the Bakery API when a bake is created. Once complete it provides a link to the @@ -34,7 +34,7 @@ class BakeStatus implements Serializable { /** * The bake status id. */ - @ApiModelProperty(value="The id of the bake request.") + @Schema(description="The id of the bake request.") String id State state @@ -46,7 +46,7 @@ class BakeStatus implements Serializable { * * @see BakeryController#lookupBake */ - @ApiModelProperty(value="The id of the bake job. Can be passed to lookupBake() to retrieve the details of the newly-baked image.") + @Schema(description="The id of the bake job. Can be passed to lookupBake() to retrieve the details of the newly-baked image.") String resource_id @JsonIgnore diff --git a/rosco-web/rosco-web.gradle b/rosco-web/rosco-web.gradle index e13f2d1b8..3cdc02e24 100644 --- a/rosco-web/rosco-web.gradle +++ b/rosco-web/rosco-web.gradle @@ -11,7 +11,7 @@ dependencies { implementation project(":rosco-core") implementation project(":rosco-manifests") implementation "io.spinnaker.kork:kork-web" - implementation "io.swagger:swagger-annotations" + implementation "io.swagger.core.v3:swagger-annotations" implementation "org.apache.groovy:groovy" implementation "io.spinnaker.kork:kork-artifacts" diff --git a/rosco-web/src/main/groovy/com/netflix/spinnaker/rosco/controllers/BakeryController.groovy b/rosco-web/src/main/groovy/com/netflix/spinnaker/rosco/controllers/BakeryController.groovy index 048a04496..201120f56 100644 --- a/rosco-web/src/main/groovy/com/netflix/spinnaker/rosco/controllers/BakeryController.groovy +++ b/rosco-web/src/main/groovy/com/netflix/spinnaker/rosco/controllers/BakeryController.groovy @@ -31,8 +31,8 @@ import com.netflix.spinnaker.rosco.providers.registry.CloudProviderBakeHandlerRe import com.netflix.spinnaker.security.AuthenticatedRequest import groovy.transform.InheritConstructors import groovy.util.logging.Slf4j -import io.swagger.annotations.ApiOperation -import io.swagger.annotations.ApiParam +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.Parameter import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.http.HttpStatus @@ -222,10 +222,10 @@ class BakeryController { } } - @ApiOperation(value = "Look up bake request status") + @Operation(summary = "Look up bake request status") @RequestMapping(value = "/api/v1/{region}/status/{statusId}", method = RequestMethod.GET) - BakeStatus lookupStatus(@ApiParam(value = "The region of the bake request to lookup", required = true) @PathVariable("region") String region, - @ApiParam(value = "The id of the bake request to lookup", required = true) @PathVariable("statusId") String statusId) { + BakeStatus lookupStatus(@Parameter(description = "The region of the bake request to lookup", required = true) @PathVariable("region") String region, + @Parameter(description = "The id of the bake request to lookup", required = true) @PathVariable("statusId") String statusId) { def bakeStatus = bakeStore.retrieveBakeStatusById(statusId) if (bakeStatus) { @@ -235,10 +235,10 @@ class BakeryController { throw new IllegalArgumentException("Unable to retrieve status for '$statusId'.") } - @ApiOperation(value = "Look up bake details") + @Operation(summary = "Look up bake details") @RequestMapping(value = "/api/v1/{region}/bake/{bakeId}", method = RequestMethod.GET) - Bake lookupBake(@ApiParam(value = "The region of the bake to lookup", required = true) @PathVariable("region") String region, - @ApiParam(value = "The id of the bake to lookup", required = true) @PathVariable("bakeId") String bakeId) { + Bake lookupBake(@Parameter(description = "The region of the bake to lookup", required = true) @PathVariable("region") String region, + @Parameter(description = "The id of the bake to lookup", required = true) @PathVariable("bakeId") String bakeId) { def bake = bakeStore.retrieveBakeDetailsById(bakeId) if (bake) { @@ -317,10 +317,10 @@ class BakeryController { } // TODO(duftler): Synchronize this with existing bakery api. - @ApiOperation(value = "Cancel bake request") + @Operation(summary = "Cancel bake request") @RequestMapping(value = "/api/v1/{region}/cancel/{statusId}", method = RequestMethod.GET) - String cancelBake(@ApiParam(value = "The region of the bake request to cancel", required = true) @PathVariable("region") String region, - @ApiParam(value = "The id of the bake request to cancel", required = true) @PathVariable("statusId") String statusId) { + String cancelBake(@Parameter(description = "The region of the bake request to cancel", required = true) @PathVariable("region") String region, + @Parameter(description = "The id of the bake request to cancel", required = true) @PathVariable("statusId") String statusId) { if (bakeStore.cancelBakeById(statusId)) { jobExecutor.cancelJob(statusId) From 0704d3ecd66fe983d341b2051d4bf86417b4a149 Mon Sep 17 00:00:00 2001 From: Edgar Garcia Date: Wed, 27 Nov 2024 11:55:58 -0600 Subject: [PATCH 2/2] chore(deps): bump latest kork version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 110fcd2be..947443557 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -korkVersion=7.246.0 +korkVersion=7.247.0 org.gradle.parallel=true spinnakerGradleVersion=8.32.1 targetJava17=true