swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
781 stars 527 forks source link

3.1.0 spec parsing, $defs information omitted #1970

Open spacether opened 1 year ago

spacether commented 1 year ago

3.1.0 spec parsing, $defs information omitted

When parsing a spec like this:

# OAS document that uses 3.1 features:
# 'null' type
# type array
openapi: 3.1.0
info:
  version: 1.0.0
  title: Example
  license:
    name: MIT
    identifier: MIT
servers:
  - url: http://api.example.xyz/v1
paths:
  /somePath:
    get:
      operationId: getSomePath
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema: {}
components:
  schemas:
    AnyTypeWithDefs:
      properties:
        firstName:
          $ref: "#/components/schemas/AnyTypeWithDefs/$defs/name"
        lastName:
          $ref: "#/components/schemas/AnyTypeWithDefs/$defs/name"
      $defs:
        name:
          type: string
    ObjectWithDefs:
      properties:
        firstName:
          $ref: "#/components/schemas/ObjectWithDefs/$defs/name"
        lastName:
          $ref: "#/components/schemas/ObjectWithDefs/$defs/name"
      $defs:
        name:
          type: string

This prevents downstream users of this library from being able to implement the openapi 3.1.0 and 2020-12 json schema $defs feature