swag icon indicating copy to clipboard operation
swag copied to clipboard

Proposal swag 2.0 using open api 3.0

Open Nerzal opened this issue 5 years ago • 43 comments

Hey everyone. As the support of Swagger 2.0 is pretty stable now, we should start to make a list of all features / changes we need to support Open Api 3.0.

We might create a new 2.0 milestone and move/create Open Api 3.0 support issues in there.

Nerzal avatar Oct 29 '19 15:10 Nerzal

I would love this, we've been holding off on it at work because it's not OpenAPI 3. What's best for me to help?

superdave avatar Feb 25 '20 22:02 superdave

@superdave PR is always welcome.

ubogdan avatar Feb 26 '20 10:02 ubogdan

Would love this to get access to the oneOf functionality for schema responses

tylfin avatar Jun 26 '20 17:06 tylfin

Does it support OpenAPI Specification 3 now?

alandtsang avatar Dec 11 '20 02:12 alandtsang

nope. The spec lib which is used under the hood does only support Swagger 2.0.

We'd need to switch to a spec lib that supports OpenAPI 3, if there is such a lib by now

Nerzal avatar Dec 11 '20 10:12 Nerzal

@Nerzal maybe just try https://github.com/getkin/kin-openapi

ipfans avatar Dec 16 '20 06:12 ipfans

I've found a way to generate openapi3 specs from the output of this project

https://github.com/swaggo/swag/issues/386#issuecomment-833913287

OneCricketeer avatar May 08 '21 20:05 OneCricketeer

upppppppppppppppppppppppppppppppppppppp!

hotrungnhan avatar Sep 17 '21 21:09 hotrungnhan

Any progress with this? Except for workaround

vtopc avatar Sep 23 '21 10:09 vtopc

I don't think It will happen any time soon.

ubogdan avatar Sep 23 '21 13:09 ubogdan

i have a branch, where i refactore swaggo to use open api 3.0 specs, but will still take some weeks/months until it is finished, as i do not have that much time at hand to complete it

Nerzal avatar Sep 23 '21 14:09 Nerzal

We can't support this kind of change overnight. More than that, this will introduce breaking changes, and this has to go with v2. On the other hand, we see many requests regarding improvements and bug fixes for the current parser. Working on a new version too early will introduce the additional overhead of merging the v1 fixes in the new branch.

ubogdan avatar Sep 24 '21 06:09 ubogdan

i have a branch, where i refactore swaggo to use open api 3.0 specs, but will still take some weeks/months until it is finished, as i do not have that much time at hand to complete it

Could you share the branch?

vtopc avatar Sep 24 '21 16:09 vtopc

Still lots of work to do, but "soon" i'll have some time.

https://github.com/Nerzal/swag/tree/feature/openapi3

Here is the comparison: https://github.com/Nerzal/swag/commit/a9628192bf1e857e210bd9b5c85c6953bb7b1f6c

Nerzal avatar Sep 27 '21 10:09 Nerzal

@Nerzal How Can I help you to finish your work?

guiyomh avatar Mar 11 '22 09:03 guiyomh

Is there any alternative project which supports OpenAPI v3? I think we are way behind.

santosh avatar Aug 24 '22 04:08 santosh

@santosh eventually we should offer support on how to migrate from swag.

ubogdan avatar Aug 24 '22 06:08 ubogdan

I started a new attempt.

I'm making pretty good progress here. I can already parse general API info + lots of the operation parts.

https://github.com/Nerzal/swag/pull/5

Nerzal avatar Mar 21 '23 16:03 Nerzal

I can make v2 branch for openapi v3 if you want.

ubogdan avatar Mar 21 '23 17:03 ubogdan

Sounds good. My current goal is to implement everything we have now in the OpenAPI 3.1 spec. As soon as this is working i'll make a PR to the new V2 branch.

Nerzal avatar Mar 23 '23 10:03 Nerzal

Done. Please make the PR against this branch https://github.com/swaggo/swag/tree/v2

ubogdan avatar Mar 23 '23 10:03 ubogdan

Okay, i'll open a Work in Progress PR now. We can use that to potentially discuss implementation details.

Some comments like host, basepath and some more do not exist anymore and need a new swag comment syntax. There are some more examples. I guess some of them could need some discussion, when i come to the point.

I'm currently working full time on this project, so that will happen pretty soon

Nerzal avatar Mar 23 '23 11:03 Nerzal

@Nerzal Let's keep it simple. This doesn't mean it has to be done in 1 single PR. We first need an MVP and we will do a beta release. So the community will have the chance to test and provide feedback.

ubogdan avatar Mar 23 '23 12:03 ubogdan

would love anyOf to support multiple body schemas

hookenz avatar Mar 24 '23 00:03 hookenz

I guess we could call it an MVP as soon as response objects and request bodies are correctly parsed, which is what i am working on currently.

My next step is Adding some Tests, as parsing a real world documentation while debugging tends to get pretty complicated.

Nerzal avatar Mar 24 '23 14:03 Nerzal

image

Yes implementing tests helps. More or less i try to adapt all existing tests

Nerzal avatar Mar 24 '23 15:03 Nerzal

The first throw of the implementation is now on the V2 branch. It needs testing, feel free to report issues. I'll try to fix them

Nerzal avatar Apr 05 '23 16:04 Nerzal

v2.0.0-beta is avail for testing ...

ubogdan avatar Apr 05 '23 23:04 ubogdan

Hi,

I see that a lot of work is being done to implement open API 3.0 specifications, (there are commits dating from last week on branch v2). Is there an issue or discussion that I could follow to get updated on how this goes and even what needs to be done so that I could even try to help implement certain things?

Breigner01 avatar Jun 08 '23 19:06 Breigner01

@Nerzal thanks for adding the ability to generate OpenAPI v3.1! Any plans to support generation of OpenAPI 3.0 spec?

eliyahus avatar Jul 16 '23 11:07 eliyahus