emicklei / go-restful-openapi

OpenAPI extension in Go for the go-restful package
MIT License
135 stars 72 forks source link

Is there a way to generate openapi v3? #76

Open SVilgelm opened 2 years ago

SVilgelm commented 2 years ago

I see that this projects heavily uses Swagger v2, but is there a way to generate v3? Maybe you can recommend a project that we can use instead of go-restful-openapi but which works with go-restful?

emicklei commented 2 years ago

hi, I am not aware of other projects that can generate a v3 document with data available in go-restful.

With contributors , we can start creating a v3 branch in this project and modify the code such it is conform the v3 spec.

SVilgelm commented 2 years ago

ok, thank you! I think it would be better to create another project to keep v2 available for other

emicklei commented 2 years ago

@SVilgelm I can think of a couple of reasons to introduce v3 branch instead:

SVilgelm commented 2 years ago

I did some research and seems only this https://github.com/getkin/kin-openapi/tree/master/openapi3 project is alive, so v3 branch will require to use kin lib instead of swagger Is it OK?

I'm not sure how good the https://github.com/getkin/kin-openapi/tree/master/openapi2, but maybe it worth to use it instead of swagger as well for v2?

SVilgelm commented 2 years ago

forget about my last suggestion about using kin for v2, it will break existent code for all users for sure

emicklei commented 2 years ago

so kin for v3 is still a reasonable choice?

SVilgelm commented 2 years ago

it is up to you, but seems it supports v3 pretty well. I have created my own lib for v3.1, but it depends on go v1.18, because of generics: https://github.com/sv-tools/openapi

EvenChang commented 11 months ago

I'm confusing... How can I use go-restful-openapi to generate openAPI v3 ?

SVilgelm commented 11 months ago

it is not supported yet, I used kin-openapi to convert v2 to v3, worked well, with some hacks of course. It really depends what you want from the v3 API. If you need just some basic features, that are supported by v2, then kin library will work for you, but if you need something like oneOf, then you will need to modify the v3 spec after the conversion.