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): Uses openrewrite to convert swagger to openapi annotations (backport #1813) #1859

Merged
merged 1 commit into from
Jan 7, 2025
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
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ plugins {
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false
id "org.jetbrains.kotlin.plugin.allopen" version "$kotlinVersion" apply false
id "org.jetbrains.dokka" version "0.10.1" apply false

}

allprojects {
apply plugin: 'io.spinnaker.project'

group = "io.spinnaker.gate"

if ([korkVersion, fiatVersion].find { it.endsWith('-SNAPSHOT') }) {
repositories {
mavenLocal()
Expand All @@ -26,6 +26,7 @@ allprojects {
}

dependencies {

implementation enforcedPlatform("io.spinnaker.kork:kork-bom:$korkVersion")
annotationProcessor platform("io.spinnaker.kork:kork-bom:$korkVersion")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
Expand Down
1 change: 1 addition & 0 deletions gate-bom/gate-bom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
api("io.spinnaker.fiat:fiat-api:$fiatVersion")
api("io.spinnaker.fiat:fiat-core:$fiatVersion")


rootProject
.subprojects
.findAll { it != project }
Expand Down
2 changes: 2 additions & 0 deletions gate-integrations-gremlin/gate-integrations-gremlin.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dependencies {
implementation project(":gate-core")
implementation "io.swagger.core.v3:swagger-annotations"

implementation "io.spinnaker.kork:kork-swagger"
implementation "io.spinnaker.kork:kork-web"
implementation "com.netflix.spectator:spectator-api"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.netflix.spinnaker.gate.controllers.gremlin;

import com.netflix.spinnaker.gate.services.gremlin.GremlinService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,14 +24,14 @@ public GremlinController(GremlinService gremlinService) {
this.gremlinService = gremlinService;
}

@ApiOperation(value = "Retrieve a list of gremlin command templates")
@Operation(summary = "Retrieve a list of gremlin command templates")
@RequestMapping(value = "/templates/command", method = RequestMethod.POST)
List listCommandTemplates(@RequestBody(required = true) Map apiKeyMap) {
String apiKeyValue = (String) apiKeyMap.get(APIKEY_KEY);
return gremlinService.getCommandTemplates("Key " + apiKeyValue);
}

@ApiOperation(value = "Retrieve a list of gremlin target templates")
@Operation(summary = "Retrieve a list of gremlin target templates")
@RequestMapping(value = "/templates/target", method = RequestMethod.POST)
List listTargetTemplates(@RequestBody(required = true) Map apiKeyMap) {
String apiKeyValue = (String) apiKeyMap.get(APIKEY_KEY);
Expand Down
3 changes: 2 additions & 1 deletion gate-plugins/gate-plugins.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ apply from: "${project.rootDir}/gradle/kotlin.gradle"
apply from: "${project.rootDir}/gradle/kotlin-test.gradle"

dependencies {
implementation platform(project(":gate-bom"))
implementation project(":gate-api")
implementation project(":gate-core")

Expand All @@ -28,7 +29,7 @@ dependencies {
implementation "io.spinnaker.kork:kork-retrofit"
implementation "io.spinnaker.kork:kork-web"

implementation "io.swagger:swagger-annotations"
implementation "io.swagger.core.v3:swagger-annotations"

implementation "org.springframework:spring-web"
implementation "org.pf4j:pf4j-update"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
package com.netflix.spinnaker.gate.plugins.deck

import com.netflix.spinnaker.kork.web.exceptions.NotFoundException
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation

import java.util.concurrent.TimeUnit
import javax.servlet.http.HttpServletResponse
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
Expand All @@ -36,13 +37,13 @@ class DeckPluginsController(
private val deckPluginService: DeckPluginService
) {

@ApiOperation(value = "Retrieve a plugin manifest")
@Operation(summary = "Retrieve a plugin manifest")
@GetMapping("/plugin-manifest.json")
fun getPluginManifest(): List<DeckPluginVersion> {
return deckPluginService.getPluginsManifests()
}

@ApiOperation(value = "Retrieve a single plugin asset by version")
@Operation(summary = "Retrieve a single plugin asset by version")
@GetMapping("/{pluginId}/{pluginVersion}/{asset:.*}")
fun getPluginAsset(
@PathVariable pluginId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.netflix.spinnaker.gate.plugins.web.PluginService
import com.netflix.spinnaker.gate.plugins.web.SpinnakerExtensionsConfigProperties
import com.netflix.spinnaker.gate.services.internal.Front50Service
import com.netflix.spinnaker.kork.plugins.update.internal.SpinnakerPluginInfo
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.security.access.prepost.PreAuthorize
Expand All @@ -42,7 +42,7 @@ class PluginInfoController(
private val spinnakerExtensionsConfigProperties: SpinnakerExtensionsConfigProperties
) {

@ApiOperation(value = "Persist plugin metadata information")
@Operation(summary = "Persist plugin metadata information")
@RequestMapping(
method = [RequestMethod.POST, RequestMethod.PUT],
consumes = [MediaType.APPLICATION_JSON_VALUE]
Expand All @@ -52,7 +52,7 @@ class PluginInfoController(
return pluginService.upsertPluginInfo(pluginInfo)
}

@ApiOperation(value = "Delete plugin info with the provided Id")
@Operation(summary = "Delete plugin info with the provided Id")
@PreAuthorize("hasPermission(#this.this.appName, 'APPLICATION', 'WRITE')")
@RequestMapping(
value = ["/{id:.+}"],
Expand All @@ -64,7 +64,7 @@ class PluginInfoController(
return pluginService.deletePluginInfo(id)
}

@ApiOperation(value = "Get all plugin info objects")
@Operation(summary = "Get all plugin info objects")
@RequestMapping(method = [RequestMethod.GET])
fun getAllPluginInfo(@RequestParam(value = "service", required = false) service: String?): List<*> {
return front50Service.getPluginInfo(service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.netflix.spinnaker.kork.plugins.SpinnakerPluginManager
import com.netflix.spinnaker.kork.plugins.update.SpinnakerUpdateManager
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerServerException
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation
import java.util.stream.Collectors
import org.pf4j.PluginWrapper
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -44,7 +44,7 @@ class PluginsInstalledController(

private val log by lazy { LoggerFactory.getLogger(javaClass) }

@ApiOperation(value = "Get all installed Spinnaker plugins")
@Operation(summary = "Get all installed Spinnaker plugins")
@RequestMapping(method = [RequestMethod.GET])
fun getInstalledPlugins(@RequestParam(value = "service", required = false) service: String?): Map<String, List<SpinnakerPluginDescriptor>> {
return when (service) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import com.netflix.spinnaker.gate.plugins.web.PluginService
import com.netflix.spinnaker.kork.exceptions.SystemException
import com.netflix.spinnaker.kork.plugins.update.internal.SpinnakerPluginInfo
import com.netflix.spinnaker.security.AuthenticatedRequest
import io.swagger.annotations.ApiOperation
import io.swagger.v3.oas.annotations.Operation

import java.lang.String.format
import lombok.SneakyThrows
import okhttp3.MediaType
Expand Down Expand Up @@ -55,7 +56,7 @@ class PluginPublishController(
private val okHttpClient: OkHttpClient = okHttpClientProvider.getClient(DefaultServiceEndpoint("front50", front50Url))

@SneakyThrows
@ApiOperation(value = "Publish a plugin binary and the plugin info metadata.")
@Operation(summary = "Publish a plugin binary and the plugin info metadata.")
@PostMapping("/{pluginId}/{pluginVersion}", consumes = [MULTIPART_FORM_DATA_VALUE])
fun publishPlugin(
@RequestPart("plugin") body: MultipartFile,
Expand Down
2 changes: 1 addition & 1 deletion gate-web/gate-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
force = true // Unpin it after adoption of spring-boot-starter-graphql
}

implementation "io.springfox:springfox-swagger2"
implementation "org.springdoc:springdoc-openapi-ui:1.8.0"

implementation "io.cloudevents:cloudevents-spring:2.5.0"
implementation "io.cloudevents:cloudevents-json-jackson:2.5.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class CloudEventHandlerConfiguration implements WebMvcConfigurer {

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(cloudEventHttpMessageConverter());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import com.netflix.spinnaker.gate.services.ExecutionHistoryService
import com.netflix.spinnaker.gate.services.TaskService
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException
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.core.env.Environment
import org.springframework.http.HttpEntity
Expand Down Expand Up @@ -59,13 +61,13 @@ class ApplicationController {
@Autowired
Environment environment

@ApiOperation(value = "Retrieve a list of applications", response = List.class)
@Operation(summary = "Retrieve a list of applications")
@RequestMapping(method = RequestMethod.GET)
@PostFilter("hasPermission(filterObject.get('name'), 'APPLICATION', 'READ')")
List<HashMap<String, Object>> getAllApplications(
@ApiParam(name = "account", required = false, value = "filters results to only include applications deployed in the specified account")
@Parameter(name = "account", required = false, description = "filters results to only include applications deployed in the specified account")
@RequestParam(value = "account", required = false) String account,
@ApiParam(name = "owner", required = false, value = "filters results to only include applications owned by the specified email")
@Parameter(name = "owner", required = false, description = "filters results to only include applications owned by the specified email")
@RequestParam(value = "owner", required = false) String owner) {
return applicationService.getAllApplications()
.findAll {
Expand All @@ -82,7 +84,7 @@ class ApplicationController {
}
}

@ApiOperation(value = "Retrieve an application's details", response = HashMap.class)
@Operation(summary = "Retrieve an application's details")
@RequestMapping(value = "/{application:.+}", method = RequestMethod.GET)
Map getApplication(@PathVariable("application") String application, @RequestParam(value = "expand", defaultValue = "true") boolean expand) {
def result = applicationService.getApplication(application, expand)
Expand All @@ -96,14 +98,14 @@ class ApplicationController {
result
}

@ApiOperation(value = "Retrieve a list of an application's configuration revision history", response = List.class)
@Operation(summary = "Retrieve a list of an application's configuration revision history")
@RequestMapping(value = "/{application}/history", method = RequestMethod.GET)
List<Map> getApplicationHistory(@PathVariable("application") String application,
@RequestParam(value = "limit", defaultValue = "20") int limit) {
return applicationService.getApplicationHistory(application, limit)
}

@ApiOperation(value = "Retrieve a list of an application's tasks", response = List.class)
@Operation(summary = "Retrieve a list of an application's tasks")
@RequestMapping(value = "/{application}/tasks", method = RequestMethod.GET)
List getTasks(@PathVariable("application") String application,
@RequestParam(value = "page", required = false) Integer page,
Expand All @@ -112,7 +114,7 @@ class ApplicationController {
executionHistoryService.getTasks(application, page, limit, statuses)
}

@ApiOperation(value = "Retrieve a list of an application's pipeline executions", response = List.class)
@Operation(summary = "Retrieve a list of an application's pipeline executions")
@RequestMapping(value = "/{application}/pipelines", method = RequestMethod.GET)
List getPipelines(@PathVariable("application") String application,
@RequestParam(value = "limit", required = false) Integer limit,
Expand All @@ -126,21 +128,21 @@ class ApplicationController {
* @deprecated There is no reason to provide an app name, use PipelineController instead for pipeline operations.
*/
@Deprecated
@ApiOperation(value = "Cancel pipeline", response = HashMap.class)
@Operation(summary = "Cancel pipeline")
@RequestMapping(value = "/{application}/pipelines/{id}/cancel", method = RequestMethod.PUT)
Map cancelPipeline(@PathVariable("id") String id,
@RequestParam(required = false) String reason) {
taskService.cancelPipeline(id, reason)
}

@ApiOperation(value = "Retrieve a list of an application's pipeline configurations", response = List.class)
@Operation(summary = "Retrieve a list of an application's pipeline configurations")
@RequestMapping(value = "/{application}/pipelineConfigs", method = RequestMethod.GET)
List getPipelineConfigsForApplication(@PathVariable("application") String application,
@RequestParam(required = false, value="pipelineNameFilter") String pipelineNameFilter) {
applicationService.getPipelineConfigsForApplication(application, pipelineNameFilter)
}

@ApiOperation(value = "Retrieve a pipeline configuration", response = HashMap.class)
@Operation(summary = "Retrieve a pipeline configuration")
@RequestMapping(value = "/{application}/pipelineConfigs/{pipelineName:.+}", method = RequestMethod.GET)
Map getPipelineConfig(
@PathVariable("application") String application, @PathVariable("pipelineName") String pipelineName) {
Expand All @@ -154,13 +156,13 @@ class ApplicationController {
config
}

@ApiOperation(value = "Retrieve a list of an application's pipeline strategy configurations", response = List.class)
@Operation(summary = "Retrieve a list of an application's pipeline strategy configurations")
@RequestMapping(value = "/{application}/strategyConfigs", method = RequestMethod.GET)
List getStrategyConfigsForApplication(@PathVariable("application") String application) {
applicationService.getStrategyConfigsForApplication(application)
}

@ApiOperation(value = "Retrieve a pipeline strategy configuration", response = HashMap.class)
@Operation(summary = "Retrieve a pipeline strategy configuration")
@RequestMapping(value = "/{application}/strategyConfigs/{strategyName}", method = RequestMethod.GET)
Map getStrategyConfig(@PathVariable("application") String application,
@PathVariable("strategyName") String strategyName) {
Expand All @@ -178,7 +180,7 @@ class ApplicationController {
* @deprecated Use PipelineController instead for pipeline operations.
*/
@Deprecated
@ApiOperation(value = "Invoke pipeline config", response = HttpEntity.class)
@Operation(summary = "Invoke pipeline config")
@RequestMapping(value = "/{application}/pipelineConfigs/{pipelineName:.+}", method = RequestMethod.POST)
HttpEntity invokePipelineConfig(@PathVariable("application") String application,
@PathVariable("pipelineName") String pipelineName,
Expand All @@ -191,7 +193,7 @@ class ApplicationController {
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@ApiOperation(value = "Get task", response = HashMap.class)
@Operation(summary = "Get task")
@RequestMapping(value = "/{application}/tasks/{id}", method = RequestMethod.GET)
Map getTask(@PathVariable("id") String id) {
taskService.getTask(id)
Expand All @@ -201,7 +203,7 @@ class ApplicationController {
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@ApiOperation(value = "Cancel task", response = HashMap.class)
@Operation(summary = "Cancel task")
@RequestMapping(value = "/{application}/tasks/{id}/cancel", method = RequestMethod.PUT)
Map cancelTask(@PathVariable("id") String id) {
taskService.cancelTask(id)
Expand All @@ -211,7 +213,7 @@ class ApplicationController {
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@ApiOperation(value = "Get task details", response = HashMap.class)
@Operation(summary = "Get task details")
@RequestMapping(value = "/{application}/tasks/{id}/details/{taskDetailsId}", method = RequestMethod.GET)
Map getTaskDetails(@PathVariable("id") String id,
@PathVariable("taskDetailsId") String taskDetailsId,
Expand All @@ -223,7 +225,7 @@ class ApplicationController {
* @deprecated There is no reason to provide an app name, use TaskController instead for task operations.
*/
@Deprecated
@ApiOperation(value = "Create task", response = HashMap.class)
@Operation(summary = "Create task")
@RequestMapping(value = "/{application}/tasks", method = RequestMethod.POST)
Map task(@PathVariable String application, @RequestBody Map map) {
taskService.createAppTask(application, map)
Expand Down
Loading
Loading