go-restful-openapi icon indicating copy to clipboard operation
go-restful-openapi copied to clipboard

Is there a way to generate openapi v3?

Open SVilgelm opened this issue 2 years ago • 9 comments

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?

SVilgelm avatar Oct 14 '21 17:10 SVilgelm

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.

emicklei avatar Oct 14 '21 19:10 emicklei

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

SVilgelm avatar Oct 16 '21 02:10 SVilgelm

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

  • package name go-restful-openapi does not change ; devs won't leave the project
  • maintaining code is easier, a fix in v2 can be cherry picked into v3
  • v3 branch changes does not affect master or v2.

emicklei avatar Nov 21 '21 08:11 emicklei

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 avatar Nov 22 '21 04:11 SVilgelm

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

SVilgelm avatar Nov 22 '21 05:11 SVilgelm

so kin for v3 is still a reasonable choice?

emicklei avatar May 25 '22 20:05 emicklei

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

SVilgelm avatar Jun 02 '22 22:06 SVilgelm

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

EvenChang avatar Sep 27 '23 03:09 EvenChang

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.

SVilgelm avatar Sep 27 '23 04:09 SVilgelm