Sonja
Sonja

Reputation: 103

In springfox 3 (swagger) how do i get useful documentation for a requestbody of a list of objects?

This seems like a very basic functionality for springfox swagger, yet I cannot find how to make it work.

What I would like to see:

@GetMapping('foos')
public ResponseEntity updateFoo(@RequestBody @Parameter List<Foo> foos) {
// do stuff
}

Should Result in something like

"paths": {
  "/foos": {
    (...)
    "parameters": [
      {
        "name": "foo",
        "in": "query",
        "description": "foo",
        "required": false,
        "type": "array",
        "items": {
        "type": "Foo"
      },

However i'm getting

"paths": {
  "/foos": {
    (...)
    "parameters": [
      {
        "name": "foo",
        "in": "query",
        "description": "foo",
        "required": false,
        "type": "string"
      }
    },

So the list is recognized as a type string. This means that for any readers of the swagger doc it is completely unclear that they actually need to supply a list of specific foo objects.

How can I get springfox to make the correct documentation for a list?

Edit: For this project we have decided to move over to SpringDoc to circumvent the issue.

Upvotes: 1

Views: 199

Answers (0)

Related Questions