Skip to content

Commit ec28083

Browse files
fix(openapi): Rewrite Swagger to OpenAPI annotations (#6309) (#6330)
* fix(openapi): Rewrite Swagger to OpenAPI annotations * Update gradle.properties (cherry picked from commit 0cc36f8) Co-authored-by: Christos Arvanitis <christos.arvanitis@armory.io>
1 parent 7daeb3b commit ec28083

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

clouddriver-kubernetes/clouddriver-kubernetes.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ dependencies {
8585
implementation "org.springframework.cloud:spring-cloud-config-server"
8686
implementation "io.github.resilience4j:resilience4j-retry"
8787
implementation "io.github.resilience4j:resilience4j-micrometer"
88+
implementation "io.swagger.core.v3:swagger-annotations"
8889

8990
testImplementation "io.spinnaker.kork:kork-test"
9091
testImplementation "org.apache.commons:commons-exec"

clouddriver-kubernetes/src/main/java/com/netflix/spinnaker/clouddriver/kubernetes/controllers/PodController.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package com.netflix.spinnaker.clouddriver.kubernetes.controllers;
1818

1919
import com.netflix.spinnaker.clouddriver.kubernetes.provider.view.KubernetesJobProvider;
20-
import io.swagger.annotations.ApiOperation;
21-
import io.swagger.annotations.ApiParam;
20+
import io.swagger.v3.oas.annotations.Operation;
21+
import io.swagger.v3.oas.annotations.Parameter;
2222
import java.util.Collections;
2323
import java.util.Map;
2424
import org.springframework.security.access.prepost.PreAuthorize;
@@ -38,18 +38,25 @@ public PodController(KubernetesJobProvider jobProvider) {
3838

3939
@PreAuthorize(
4040
"hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
41-
@ApiOperation(value = "Collect a file from a pod", notes = "Collects the file result of a pod.")
41+
@Operation(
42+
summary = "Collect a file from a pod",
43+
description = "Collects the file result of a pod.")
4244
@RequestMapping(
4345
value = "/{account}/{namespace}/{podName}/{fileName:.+}",
4446
method = RequestMethod.GET)
4547
Map<String, Object> getFileContents(
46-
@ApiParam(value = "Application name", required = true) @PathVariable String application,
47-
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
48-
@ApiParam(value = "Namespace in which the pod is running in", required = true) @PathVariable
48+
@Parameter(description = "Application name", required = true) @PathVariable
49+
String application,
50+
@Parameter(description = "Account job was created by", required = true) @PathVariable
51+
String account,
52+
@Parameter(description = "Namespace in which the pod is running in", required = true)
53+
@PathVariable
4954
String namespace,
50-
@ApiParam(value = "Unique identifier of pod being looked up", required = true) @PathVariable
55+
@Parameter(description = "Unique identifier of pod being looked up", required = true)
56+
@PathVariable
5157
String podName,
52-
@ApiParam(value = "File name to look up", required = true) @PathVariable String fileName) {
58+
@Parameter(description = "File name to look up", required = true) @PathVariable
59+
String fileName) {
5360
Map<String, Object> results =
5461
kubernetesJobProvider.getFileContentsFromPod(account, namespace, podName, fileName);
5562

clouddriver-web/clouddriver-web.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
implementation "io.spinnaker.kork:kork-moniker"
3333
implementation "commons-io:commons-io"
3434
implementation "io.reactivex:rxjava"
35-
implementation "io.swagger:swagger-annotations"
35+
implementation "io.swagger.core.v3:swagger-annotations"
3636
implementation "org.apache.groovy:groovy"
3737
implementation "org.slf4j:slf4j-api"
3838
implementation "org.springframework.boot:spring-boot-starter-actuator"

clouddriver-web/src/main/groovy/com/netflix/spinnaker/clouddriver/controllers/JobController.groovy

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package com.netflix.spinnaker.clouddriver.controllers
1919
import com.netflix.spinnaker.clouddriver.model.JobProvider
2020
import com.netflix.spinnaker.clouddriver.model.JobStatus
2121
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException
22-
import io.swagger.annotations.ApiOperation
23-
import io.swagger.annotations.ApiParam
22+
import io.swagger.v3.oas.annotations.Operation
23+
import io.swagger.v3.oas.annotations.Parameter
2424
import org.springframework.beans.factory.annotation.Autowired
2525
import org.springframework.context.MessageSource
2626
import org.springframework.security.access.prepost.PreAuthorize
@@ -42,12 +42,12 @@ class JobController {
4242
MessageSource messageSource
4343

4444
@PreAuthorize("hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
45-
@ApiOperation(value = "Collect a JobStatus", notes = "Collects the output of the job.")
45+
@Operation(summary = "Collect a JobStatus", description = "Collects the output of the job.")
4646
@RequestMapping(value = "/{account}/{location}/{id:.+}", method = RequestMethod.GET)
47-
JobStatus collectJob(@ApiParam(value = "Application name", required = true) @PathVariable String application,
48-
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
49-
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
50-
@ApiParam(value = "Unique identifier of job being looked up", required = true) @PathVariable String id) {
47+
JobStatus collectJob(@Parameter(description = "Application name", required = true) @PathVariable String application,
48+
@Parameter(description = "Account job was created by", required = true) @PathVariable String account,
49+
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
50+
@Parameter(description = "Unique identifier of job being looked up", required = true) @PathVariable String id) {
5151
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
5252
Collection<JobStatus> jobMatches = jobProviders.findResults {
5353
return it.collectJob(account, location, id)
@@ -59,26 +59,26 @@ class JobController {
5959
}
6060

6161
@PreAuthorize("hasPermission(#application, 'APPLICATION', 'EXECUTE') and hasPermission(#account, 'ACCOUNT', 'WRITE')")
62-
@ApiOperation(value = "Cancel a Job", notes = "Cancels the job.")
62+
@Operation(summary = "Cancel a Job", description = "Cancels the job.")
6363
@RequestMapping(value = "/{account}/{location}/{id:.+}", method = RequestMethod.DELETE)
64-
void cancelJob(@ApiParam(value = "Application name", required = true) @PathVariable String application,
65-
@ApiParam(value = "Account job is running in", required = true) @PathVariable String account,
66-
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
67-
@ApiParam(value = "Unique identifier of job to be canceled", required = true) @PathVariable String id) {
64+
void cancelJob(@Parameter(description = "Application name", required = true) @PathVariable String application,
65+
@Parameter(description = "Account job is running in", required = true) @PathVariable String account,
66+
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
67+
@Parameter(description = "Unique identifier of job to be canceled", required = true) @PathVariable String id) {
6868
jobProviders.forEach {
6969
it.cancelJob(account, location, id)
7070
}
7171
}
7272

7373
@PreAuthorize("hasPermission(#application, 'APPLICATION', 'READ') and hasPermission(#account, 'ACCOUNT', 'READ')")
74-
@ApiOperation(value = "Collect a file from a job", notes = "Collects the file result of a job.")
74+
@Operation(summary = "Collect a file from a job", description = "Collects the file result of a job.")
7575
@RequestMapping(value = "/{account}/{location}/{id}/{fileName:.+}", method = RequestMethod.GET)
7676
Map<String, Object> getFileContents(
77-
@ApiParam(value = "Application name", required = true) @PathVariable String application,
78-
@ApiParam(value = "Account job was created by", required = true) @PathVariable String account,
79-
@ApiParam(value = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
80-
@ApiParam(value = "Unique identifier of job being looked up", required = true) @PathVariable String id,
81-
@ApiParam(value = "File name to look up", required = true) @PathVariable String fileName
77+
@Parameter(description = "Application name", required = true) @PathVariable String application,
78+
@Parameter(description = "Account job was created by", required = true) @PathVariable String account,
79+
@Parameter(description = "Namespace, region, or zone job is running in", required = true) @PathVariable String location,
80+
@Parameter(description = "Unique identifier of job being looked up", required = true) @PathVariable String id,
81+
@Parameter(description = "File name to look up", required = true) @PathVariable String fileName
8282
) {
8383
Collection<Map<String, Object>> results = jobProviders.findResults {
8484
it.getFileContents(account, location, id, fileName)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
korkVersion=7.245.0
1+
korkVersion=7.247.0
22
fiatVersion=1.51.0
33
org.gradle.parallel=true
44
spinnakerGradleVersion=8.32.1

0 commit comments

Comments
 (0)