swagger-parser icon indicating copy to clipboard operation
swagger-parser copied to clipboard

[OpenAPI v3.1] Arrays now (incorrectly?) parse to JsonSchema rather than ArraySchema

Open dominic-jones opened this issue 6 months ago • 0 comments

In attempted to use swagger-codegen to read a 3.1.0 schema vs a 3.0.x schema, a notable change has occurred in how arrays are handled.

For example when provided the following path:

  /pets:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Pet'
        required: true
      responses:
        '204':
          description: 'No Content'

This parses to an ArraySchema in 3.0.x, but now parses to JsonSchema in 3.1.0. This could be intentional, as it sounds like some changes occurred in the structure of these objects for 3.1.0, but I'm not yet sure. I'm already multiple layers deep from my organisation, and our change will be to use 3.0.x for the time being, but leaving a report here.

swagger-codegen relies on this ArraySchema usage. The resultant codegen defaults to Object instead.

Example displaying this issue: https://github.com/dominic-jones/swagger-parser/commit/bec6fab4e4458e4294b97df488139d70261136f7

dominic-jones avatar Apr 25 '25 03:04 dominic-jones