It is possible to document query parameters in OpenAPI/Swagger using @RequestParam
.
// Example from https://www.baeldung.com/spring-request-param#a-simple-mapping
@GetMapping("/api/foos")
@ResponseBody
public String getFoos(@RequestParam String id) {
return "ID: " + id;
}
Given that every endpoint in every controller allows this same query parameter:
/api/foos?id={id}
/api/bars?id={id}
/api/different-controller/foos?id={id}
How can we add global documentation so that OpenAPI knows that every endpoint can accept this query param (without @RequestParam String id
in every endpoint)?
1