Skip to content

Supports OpenAPi spec v2.0 / v1.2 #53

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

Closed
viclovsky opened this issue Jul 24, 2018 · 18 comments
Closed

Supports OpenAPi spec v2.0 / v1.2 #53

viclovsky opened this issue Jul 24, 2018 · 18 comments

Comments

@viclovsky
Copy link

Thanks a lot for a great tool. I really want to use it in my projects but it is impossible because there is no support of older versions of OpenAPi spec: 1.2 and 2.0. Is there any plans to fix it?

@viclovsky viclovsky changed the title Supports OpenAPi spec v2.0 / v.1.2 ? Supports OpenAPi spec v2.0 / v1.2 Jul 24, 2018
@quen2404
Copy link
Member

Hello viclovsky,
this is not currently scheduled but you can create a merge request if you need it quickly.
Else, i will try to do this by the end of week, but i'm not sure if i will have enough time to do that. And after, it's my holiday during two weeks.

@viclovsky
Copy link
Author

viclovsky commented Jul 24, 2018

Yes, sounds good for me. It would be great if you make this task! Moreover, I will be able to do Maven plugin for easiest way for using your library in any project. I'll create separate ticket for that.

@viclovsky viclovsky reopened this Jul 24, 2018
quen2404 added a commit that referenced this issue Jul 25, 2018
@quen2404
Copy link
Member

@viclovsky i made a PR #53 to add the support but it seems there is a problem with swagger-parser-v2-converter.
I opened an issue in this project.
But you can already try to use it if you checkout the branch feature/support-swagger2

@jmini
Copy link
Member

jmini commented Jul 25, 2018

This will be a big limitation of this approach: When parsing an old spec, you compare the result of the Swagger-Parser-Converter, which does an on the fly conversation to OAS3.

I work a lot with the Parser (and the converter module) for the OpenAPI-Generator project and there are a lot corner cases that needs to be fixed... But it gets better and better (one issue at the time).

@quen2404
Copy link
Member

Ok :) Thank you for your feedback @jmini !

@viclovsky
Copy link
Author

Thanks a lot,
Yep, I have already tried it but sounds like I have some problems with it: it fails cause it can't translate my v2.0 spec into v3.0. Converter fails => diff fails.

  1. java.lang.IllegalArgumentException: Two path items have the same signature: /some/api/method/{}
    But I don't have such signature at all!!! I have /some/api/method/{id}, /some/api/method/{searchId}, /some/api/method/{id}/email
  2. java.lang.NullPointerException
    at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:422)
    If there is no 'info' in specification

@quen2404
Copy link
Member

quen2404 commented Jul 25, 2018

Your contract seems invalid.

  1. /some/api/method/{id} & /some/api/method/{searchId} is the same rest endpoint.
  2. According to specification, info is required

@viclovsky
Copy link
Author

viclovsky commented Jul 25, 2018

  1. Yep, /some/api/method/{id} & /some/api/method/{searchId} is the same rest endpoint, but they have different methods. First GET, second DELETE.
  2. It was my fault — never mind

@quen2404
Copy link
Member

Your contract isn't correctly designed.
You should have one path with two operations:

paths:
  /some/api/method/{id}:
    GET:
      #...
    DELETE:
      #...

@jmini
Copy link
Member

jmini commented Jul 25, 2018

  1. java.lang.NullPointerException
    at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:422)
    If there is no 'info' in specification

is already reported as swagger-api/swagger-parser#755, will be fixed in the next version of Swagger-Parser.

@viclovsky
Copy link
Author

viclovsky commented Jul 25, 2018

Your contract isn't correctly designed.
You should have one path with two operations:

Yep, thanks a lot!! I've found swagger-api/swagger-editor#1677 ... Thus I'm planning to change my spec to fit it ))

@jmini
Copy link
Member

jmini commented Jul 31, 2018

If you are interested, I have published an in-between release of 2.0.2-SNAPSHOT that can be used until 2.0.2 is officially released:
https://github.com/OpenAPITools/swagger-parser/releases/tag/v2.0.2-OpenAPITools.org-1

Some v2-to-v3 conversions issues are fixed.

@peterwa82
Copy link

Hello, is there any activity to support v2.0 Open API still or has this been abandoned?

@quen2404
Copy link
Member

Hi @peterwa82, i can try again :) But last time, there was some issues in the project swagger-parser-v2-converter

@peterwa82
Copy link

There may still be issues with it. I tried converting a 2.0 spec but noticed the required attribute of my query parameters was left null, which is wrong and results in a null pointer exception later.

@jmini
Copy link
Member

jmini commented Dec 5, 2018

@peterwa82 you need to report the issue you get in the https://github.com/swagger-api/swagger-parser project. With a simple example (OpenAPI v2.0) as input and with your expectation if the OpenAPI v3 is not the one you are expecting.

Here you will see a really simple java program to run swagger-parser independently:
https://j2r2b.github.io/2018/05/18/from-oas2-to-oas3.html

@hellboy81
Copy link

See screenshot

@joschi
Copy link
Contributor

joschi commented Aug 27, 2020

Fixed in 7734db0.

@joschi joschi closed this as completed Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants