Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openapi): Rewrite Swagger to OpenAPI annotations #1126

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
korkVersion=7.245.0
korkVersion=7.247.0
org.gradle.parallel=true
spinnakerGradleVersion=8.32.1
targetJava17=true
Expand Down
1 change: 1 addition & 0 deletions rosco-core/rosco-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<Artifact> 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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rosco-web/rosco-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)

Expand Down
Loading