-
Notifications
You must be signed in to change notification settings - Fork 639
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(openapi): Rewrite Swagger to OpenAPI annotations (#1514)
* fix(openapi): Rewrite Swagger to OpenAPI annotations * chore(deps): bump latest kork version --------- Co-authored-by: Edgar Garcia <[email protected]>
- Loading branch information
1 parent
38e9529
commit 2826f24
Showing
8 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
import com.netflix.spinnaker.front50.model.application.ApplicationPermissionDAO; | ||
import com.netflix.spinnaker.front50.model.application.ApplicationService; | ||
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
@@ -30,7 +30,7 @@ | |
|
||
@RestController | ||
@RequestMapping("/v2/applications") | ||
@Api(value = "application", description = "Application API") | ||
@Tag(name = "application", description = "Application API") | ||
public class ApplicationsController { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ApplicationsController.class); | ||
|
@@ -62,9 +62,9 @@ public ApplicationsController( | |
|
||
@PreAuthorize("#restricted ? @fiatPermissionEvaluator.storeWholePermission() : true") | ||
@PostFilter("#restricted ? hasPermission(filterObject.name, 'APPLICATION', 'READ') : true") | ||
@ApiOperation( | ||
value = "", | ||
notes = | ||
@Operation( | ||
summary = "", | ||
description = | ||
"Fetch all applications.\n\nSupports filtering by one or more attributes:\n- [email protected]\n- [email protected]&name=flex") | ||
@RequestMapping(method = RequestMethod.GET) | ||
public List<Application> applications( | ||
|
@@ -113,7 +113,7 @@ public List<Application> applications( | |
} | ||
|
||
@PreAuthorize("@fiatPermissionEvaluator.canCreate('APPLICATION', #app)") | ||
@ApiOperation(value = "", notes = "Create an application") | ||
@Operation(summary = "", description = "Create an application") | ||
@RequestMapping(method = RequestMethod.POST) | ||
public Application create(@RequestBody final Application app) { | ||
if (applicationService.findByName(app.getName()) != null) { | ||
|
@@ -135,15 +135,15 @@ public Application create(@RequestBody final Application app) { | |
} | ||
|
||
@PreAuthorize("hasPermission(#applicationName, 'APPLICATION', 'WRITE')") | ||
@ApiOperation(value = "", notes = "Delete an application") | ||
@Operation(summary = "", description = "Delete an application") | ||
@RequestMapping(method = RequestMethod.DELETE, value = "/{applicationName:.+}") | ||
public void delete(@PathVariable String applicationName, HttpServletResponse response) { | ||
applicationService.delete(applicationName); | ||
response.setStatus(HttpStatus.NO_CONTENT.value()); | ||
} | ||
|
||
@PreAuthorize("hasPermission(#app.name, 'APPLICATION', 'WRITE')") | ||
@ApiOperation(value = "", notes = "Update an existing application by merging the attributes") | ||
@Operation(summary = "", description = "Update an existing application by merging the attributes") | ||
@RequestMapping(method = RequestMethod.PATCH, value = "/{applicationName:.+}") | ||
public Application update( | ||
@PathVariable final String applicationName, @RequestBody final Application app) { | ||
|
@@ -158,7 +158,9 @@ public Application update( | |
} | ||
|
||
@PreAuthorize("hasPermission(#app.name, 'APPLICATION', 'WRITE')") | ||
@ApiOperation(value = "", notes = "Update an existing application by replacing all attributes") | ||
@Operation( | ||
summary = "", | ||
description = "Update an existing application by replacing all attributes") | ||
@RequestMapping(method = RequestMethod.PUT, value = "/{applicationName:.+}") | ||
public Application replace( | ||
@PathVariable final String applicationName, @RequestBody final Application app) { | ||
|
@@ -173,7 +175,7 @@ public Application replace( | |
} | ||
|
||
@PostAuthorize("hasPermission(#applicationName, 'APPLICATION', 'READ')") | ||
@ApiOperation(value = "", notes = "Fetch a single application by name") | ||
@Operation(summary = "", description = "Fetch a single application by name") | ||
@RequestMapping(method = RequestMethod.GET, value = "/{applicationName:.+}") | ||
public Application get(@PathVariable final String applicationName) { | ||
Application app = applicationDAO.findByName(applicationName.toUpperCase()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ | |
import com.netflix.spinnaker.front50.model.project.Project; | ||
import com.netflix.spinnaker.front50.model.project.ProjectDAO; | ||
import com.netflix.spinnaker.kork.web.exceptions.NotFoundException; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.*; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
@@ -38,7 +38,7 @@ | |
|
||
@RestController | ||
@RequestMapping(value = "/v2/projects", produces = MediaType.APPLICATION_JSON_VALUE) | ||
@Api(value = "projects", description = "Project API") | ||
@Tag(name = "projects", description = "Project API") | ||
public class ProjectsController { | ||
|
||
private static final Splitter COMMA_SPLITTER = Splitter.on(','); | ||
|
@@ -50,9 +50,9 @@ public ProjectsController(ProjectDAO projectDAO) { | |
} | ||
|
||
@RequestMapping(value = "/search", method = RequestMethod.GET) | ||
@ApiOperation( | ||
value = "", | ||
notes = | ||
@Operation( | ||
summary = "", | ||
description = | ||
"Search for projects given one or more attributes.\n\n- /search?q=ProjectName\n- /search?q=ApplicationName\n") | ||
public Set<Project> search(@RequestParam("q") final String query) { | ||
return projectDAO.all().stream() | ||
|
@@ -64,9 +64,9 @@ public Set<Project> search(@RequestParam("q") final String query) { | |
.collect(Collectors.toSet()); | ||
} | ||
|
||
@ApiOperation( | ||
value = "", | ||
notes = | ||
@Operation( | ||
summary = "", | ||
description = | ||
"Fetch all projects.\n\n Support filtering by one or more attributes:\n - ?name=projectName\n - [email protected]") | ||
@RequestMapping(method = RequestMethod.GET) | ||
public List<Project> projects( | ||
|
@@ -78,7 +78,7 @@ public List<Project> projects( | |
return (pageSize == null) ? projects : projects.subList(0, Math.min(pageSize, projects.size())); | ||
} | ||
|
||
@ApiOperation(value = "", notes = "Fetch a single project") | ||
@Operation(summary = "", description = "Fetch a single project") | ||
@RequestMapping(method = RequestMethod.GET, value = "/{projectId}") | ||
public Project project(@PathVariable String projectId) { | ||
try { | ||
|
@@ -88,7 +88,7 @@ public Project project(@PathVariable String projectId) { | |
} | ||
} | ||
|
||
@ApiOperation(value = "", notes = "Update an existing project") | ||
@Operation(summary = "", description = "Update an existing project") | ||
@RequestMapping(method = RequestMethod.PUT, value = "/{projectId}") | ||
public Project put(@PathVariable final String projectId, @RequestBody final Project project) { | ||
Project existingProject = projectDAO.findById(projectId); | ||
|
@@ -110,7 +110,7 @@ public Project put(@PathVariable final String projectId, @RequestBody final Proj | |
return project; | ||
} | ||
|
||
@ApiOperation(value = "", notes = "Create a project") | ||
@Operation(summary = "", description = "Create a project") | ||
@RequestMapping(method = RequestMethod.POST) | ||
public Project create(@RequestBody final Project project) { | ||
project.setCreateTs(System.currentTimeMillis()); | ||
|
@@ -202,7 +202,7 @@ private static boolean clusterHasMatchingApplication( | |
.orElse(false); | ||
} | ||
|
||
@ApiOperation(value = "", notes = "Delete a project") | ||
@Operation(summary = "", description = "Delete a project") | ||
@RequestMapping(method = RequestMethod.DELETE, value = "/{projectId}") | ||
public void delete(@PathVariable String projectId, HttpServletResponse response) { | ||
projectDAO.delete(projectId); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters