I'm trying to use @Parameter
for a path parameter in a @RestController
, but it ignores the parameter.
Note: All works well if I use @PathVariable
instead (commented). However, @PathVariable
does not produce the OpenAPI yaml file with all properties like "description", "references", etc, that the springdoc-openapi-maven-plugin
produces automatically.
Is it possible to use @Parameter
in a REST controller?
Here's my code:
@RequestMapping("/channels") @RestController public class ChannelRESTController { @PostMapping("{channelId}/connect") @Operation(summary = "Initiates a session to a channel", tags = { "session" }) @ResponseBody ResponseEntity<?> connect( // @Parameter(name = "channelId", in = ParameterIn.PATH, required = true, description = "The channel id") String channelId, // @PathVariable(required = true) String channelId, @Parameter(description = "Credentials' username") String username, @Parameter(description = "Credentials' password") String password ) { System.out.println( "Starting channel #" + channelId); // displays null :( return ... }
https://stackoverflow.com/questions/66880320/is-it-possible-to-use-parameter-in-a-rest-controller March 31, 2021 at 09:07AM
没有评论:
发表评论