'Swagger Codegen generates nested Lists by using array as response for spring server stub

I am using the cloud SwaggerHub Codegen Editor and wrote API like this:

  /foodlogs:
get:
  tags:
  - foodlog
  summary: searches food logs
  operationId: searchFoodLog
  description: |
    By passing in the appropriate options, you can search for
    available food logs in the system
  produces:
  - application/json
  parameters:
  - in: query
    name: searchString
    description: pass an optional search string for looking up food log
    required: false
    type: string
  - in: query
    name: skip
    description: number of records to skip for pagination
    type: integer
    format: int32
    minimum: 0
  - in: query
    name: limit
    description: maximum number of records to return
    type: integer
    format: int32
    minimum: 0
    maximum: 50
  responses:
    200:
      description: search results matching criteria
      schema:
        type: array
        items:
          $ref: '#/definitions/FoodLog'
    400:
      description: bad input parameter

It should response an array with FoodLog Objects model like this:

FoodLog:
type: object
required: 
- id
- created
- foods
properties:
  id:
    type: integer
    example: 14
  created:
    type: string
    format: date
    example: "2021-12-22"
  foods:
    type: array
    items:
      $ref: '#/definitions/Food'

When I generates the spring server stub then it generates return type as nested List:

default ResponseEntity<List<java.util.List<FoodLog>>> searchFoodLog(...) {
    ...
}

So the response as Json is a nested array:

[[{"id":1,"created":"2021-12-23","foods":[{...}]}]]

But I am expecting return type List< FoodLog > for the api response definition am I wrong? because on the client side for the same api definition it produce code like this:

public searchFoodLog(...): Observable<Array<FoodLog>>;

Not nested Array as return type. Is my api definiton wrong? I want to generate spring server stub which should response a List< FoodLog >.

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source