Skip to content

OpenAPI v2 converter - ref is not updated in requestBodies #647

@jmini

Description

@jmini

Given this Swagger Spec as input:

swagger: '2.0'
info:
  title: some title
  version: '1.0'
host: 'localhost:8000'
schemes:
  - http
  - https
paths: {}
definitions:
  A:
    type: string
parameters:
  b:
    name: e
    in: body
    schema:
      $ref: '#/definitions/A'

The converted output is expected to be:

{
  "openapi" : "3.0.1",
  "info" : {
    "title" : "some title",
    "version" : "1.0"
  },
  "servers" : [ {
    "url" : "http://localhost:8000/"
  }, {
    "url" : "https://localhost:8000/"
  } ],
  "paths" : { },
  "components" : {
    "schemas" : {
      "A" : {
        "type" : "string"
      }
    },
    "requestBodies" : {
      "b" : {
        "content" : {
          "*/*" : {
            "schema" : {
              "$ref" : "#/components/schemas/A"
            }
          }
        },
        "required" : false
      }
    }
  }
}

But for the moment $ref is #/definitions/A instead of #/components/schemas/A


Conversion made with:

OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
OpenAPI openAPI = openApiParser.read(file, null, options);

With following libraries on the Classpath:

  • io.swagger.parser.v3:swagger-parser-v3:2.0.0-rc3
  • io.swagger.parser.v3:swagger-parser-v2-converter:2.0.0-rc3

I have reproduced it with the last SNAPSHOT version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions