Search code examples
javaspringspring-mvcswagger

@ModelAttribute show in Swagger like body


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?


Solution

  • Found a solution that suits me:

    @GetMapping
    public ResponseEntity<String> getApplications(@ParameterObject @ModelAttribute ApplicationFilter applicationFilter){return null;}
    

    add annotation @ParameterObject