Skip to content

OpenAPI v2 converter - Two identical schemas are not equals #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
quen2404 opened this issue Jul 25, 2018 · 1 comment
Open

OpenAPI v2 converter - Two identical schemas are not equals #779

quen2404 opened this issue Jul 25, 2018 · 1 comment

Comments

@quen2404
Copy link

Hello,
first, thank you very much for this tool.

I'm trying to parse two equivalent schemas, one in swagger 2.0, the other in openapi 3.0 :
swagger 2.0 : https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/yaml/petstore.yaml
openapi 3.0 : https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/petstore.yaml

I'm using this dependencies :

        <dependency>
            <groupId>io.swagger.parser.v3</groupId>
            <artifactId>swagger-parser-v3</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.parser.v3</groupId>
            <artifactId>swagger-parser-v2-converter</artifactId>
            <version>2.0.1</version>
        </dependency>

But it seems that the two OpenAPI are not equals.
For example, in POST /pets operation, query parameters limit are differents :
the swagger 2.0 parameter class is io.swagger.v3.oas.models.parameters.Parameter but the openapi 3.0 parameter class is io.swagger.v3.oas.models.parameters.QueryParameter.
And there is same kind of problem with Schemas : ObjectSchema vs Schema.

It is a normal behavior ?

@jmini
Copy link
Contributor

jmini commented Jul 25, 2018

This is an interesting question. In OpenAPI-Generator (the instance created by Swagger-Parser is the input), we have decided to no rely on instanceOf. Example: To decide if a io.swagger.v3.oas.models.parameters.Parameter is a QueryParameter or a PathParameter, we just go for Parameter#getIn().

That said, the v2-to-v3-converter could be improved. The correct instance could be created during conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants