I use org.springdoc:springdoc-openapi-ui:1.6.9
I have controller:
@GetMapping
public ResponseEntity<String> getApplications(@ModelAttribute ApplicationFilter applicationFilter){return null;}
And have class param:
@Getter
@Setter
@NoArgsConstructor
public class ApplicationFilter {
@Parameter(name = "ids", required = true)
private List<Long> ids;
}
I need ModelAttribute to be displayed as parameter fields in Swagger.
But is real show in the form of body
If add @Schema(name = "This is field")
over field - result
Please tell me. What do I need to do so that my @ModelAttribute is displayed as parameter fields?
CodePudding user response:
So You are aiming for (in controller):
@Operation(parameters = {
@Parameter(name = "ids,
description = "This is id field")})
@GetMapping
public ResponseEntity<String> getApplications(@ModelAttribute ApplicationFilter applicationFilter)
And in your Body:
@Schema(name = "This is id field", hidden=true)
@Parameter(name = "ids", required = true)
private List<Long> ;
CodePudding user response:
Found a solution that suits me:
@GetMapping
public ResponseEntity<String> getApplications(@ParameterObject @ModelAttribute ApplicationFilter applicationFilter){return null;}
add annotation @ParameterObject