Open c4milo opened 7 years ago
@c4milo, Can you elaborate on what it is you're interested in that isn't available today?
@achew22, feature wise, nothing. What's concerning to me right now is that https://github.com/swagger-api/swagger-js/tree/2.x is no longer active. Most development effort is going towards supporting OpenAPI v3.
+1
The OpenAPI 3.0 spec has added support for Authentication (JWT, Oath, HTTP Basic), which is something that is missing from 2.0. I think this would make it worthwhile to migrate to generating 3.0 compliant definitions.
Also oneof
?
I suppose https://github.com/go-openapi/spec3 will be needed first.
@johanbrandhorst Strictly speaking, that's not something that makes v3 support a must and a requirement. Consider that OpenAPI v2 does support OAuth2 authentication, Basic authentication and API keys.
I don't see in that PR where OpenAPI v3 adds JWT, and I suppose you meant OAuth2 and not OATH (different thigns)?
What I see as a new thing in that PR you quoted is "HTTP Bearer" and "Multiple Flows", which both may be useful. (Even though Bearer will be usually used with OAuth2, anyway, there might be people out there not using it that way.)
@tamalsaha That would be the right way to go, but protoc-gen-swagger
has OpenAPI v2 schema, so that's not a blocker either.
OpenAPI v3.0.0 adds support for specifying multiple servers (hosts).
oneof
sematics is a pain point for us
OpenAPI 3.0 adds support for nullable types, 2.0 doesn't support them: https://github.com/swagger-api/swagger-editor/issues/1364#issuecomment-309530250
I'm pretty sure there's an extension for V2 (x-nullable
?).
https://github.com/grpc-ecosystem/grpc-gateway/issues/900 is a real issue that would be covered by this.
FTR I will be very happy to review forks of the swagger generator, or elegant refactors of the swagger generator that allow for both openapiv2 and openapiv3.
+1
+1
Hey everyone,
So we are actually doing this (at least I am going to try). I pushed the first bits of OPENAPI v3 support and attached the WIP PR to this issue for all to review.
I'd love everyone to go have a look at the proto and WIP if they can. I WANT YOUR FEEDBACK ON THIS. Would love to know what sort of fields are required missing from the next version of this generator.
@zachgersh I still have the notification email for your comment marked as 'unread' in my inbox, this is exciting and I hope to take a look soon.
is this done, if not, do we have any ETA?
I am not doing this myself and I have not seen activity on #1059. @JugrajSripalJain, you can review my comments there and see if they align with the way you'd like to implement this.
It's not done and no ETA as of yet. I put this down for a bit as other work jumped my queue. We do plan to come back to this some point in Q1 next year but I'd be happy to see someone else grab it if they have time now.
hi, is there any news about this feature?
Looking forwards OAS3 support, could you share your current plans about?
I think this is on ice again unfortunately. If someone would like to pick this up please let me know.
ℹ️ Should we want to do this, here's an auto-generated protobuf model of OpenAPI v3 (and v2, for that matter): https://github.com/googleapis/gnostic/blob/master/openapiv3/OpenAPIv3.proto
Coming here from https://github.com/googleapis/gnostic/issues/162
@srenatus https://github.com/googleapis/gnostic doesn't inter-convert between proto files and open API specs, it uses message buffers instead (binary serialized data). More over, the open API specs to proto files conversion does not exploit the newest oneOf feature as expected. I have posted some use cases in the issues there. And lastly, the better use case is to manually write proto files and then generate both gRPC and REST clients/servers from it.
It would be great to have it in grpc-gateway itself. Happy to contribute.
We'd love to have openapi 3 support! Please know that it may be a lot of work. Please have a look at the v2 branch and you can probably use protoc-gen-openapiv2 as a starting point.
@johanbrandhorst @krishna-birla I'm willing to contribute where I can as well, tho my time is limited, and at present time I'm able to get away with v2 generation and conversion using https://github.com/getkin/kin-openapi/tree/master/openapi2conv . @johanbrandhorst if you able to provide any context on the gist of the work as you understand it that'd be helpful. At present time it's not entirely clear to me why we define openapiv2.proto
files and what we would define a v3 variant to achieve. Of course I'm sure once I dig into the code that'll be clearer.
Thanks! Frankly, I'm not sure what the need is either, I've been getting by with v2 wherever I've needed it. I'll be happy to help answer questions about the code but I'm no expert on openapi.
There are several significant changes to OAS3:
oneOf
, anyOf
, and not
all of which are not supported in OAS2. In OAS2 we only get allOf
which limits the options we have for dealing with polymorph types in REST.4xx
where in OAS2 we need to define each error code individually, even if the output is the same (except for the status code).As I've been involved in go-swagger, I know that https://github.com/go-openapi/spec3 is probably not going to see involvement from the original author. He stated in an issue that he does not intend to work on this any more as it is too much work.
I know that this is a lot of work to implement, but given previous comments around what actually changed I thought it's a good idea to provide a short list of interesting changes. I think supporting OAS3 spec generation could help a lot of OSS projects in their API documentation and REST client generation!
@aeneasr I don't think anyone is saying that the request is invalid or a bad idea. In reading the scrollback it sounds like the problem is that the marginal effort to adopt OpenAPI v3 is not worth the marginal effort for existing maintainers.
It sounds like the calculus might be different for you. How can I/we help you in the process of bringing OpenAPI v3 support into grpc-gateway?
@achew22 I think the first few steps should include:
Once we are sound with the required changes, we can start assigning issues and creating PRs.
@krishna-birla,
OpenAPI v3
it should be possible when filing a new issue to tag it with that.@krishna-birla,
Here is our slack channel if you'd like to get in there
Sounds great. Please post the link to your design document in here when it's ready.
I've created a tag for this called
OpenAPI v3
it should be possible when filing a new issue to tag it with that.
Getting
krishnabirla16@gmail.com doesn’t have an account on this workspace
. Can you add me please.
It's just a link to the #grpc-gateway room inside the gopher slack. You can sign up here.
i'm read issue topic, what the problem now? incomplete spec or incomplete go representation of needed struct in spec? offtopic: does gnostic now supports all oneof/allof/anyof features from openapi v3?
Looking at their latest examples, https://github.com/google/gnostic/tree/master/openapiv3, I think they do what we expect. But still not sure it is stable, at least not the last time I tried it (there was data loss in inter conversion).
Hi, just to let you know that I started working on protoc-gen-openapiv3
which will support openapi v3. Will create WIP PR as soon as I add most important bits to template.go
Any update regarding this issue?
To my knowledge, no one is actively working on this.
Any update regarding this issue?
To share some insight, in our project http://github.com/clouditor/clouditor we are basically using a combination of grpc-gateway to generate the REST server as well as gnostic (> 0.6.0) to generate OpenAPI files and so far we had no problems with external clients.
You just have to make sure that your style for properties matches, gnostic seems to use camelCase, which also seems to be the default for grpc-gateway now, but this ca be configured: https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_your_gateway/#using-proto-names-in-json
I would love to see this feature and would be happy to contribute to it a bit if someone who knows what they are doing can get the ball rolling and point me at the right bits :)
This is a big task. We've had a few users try to contribute this over the years. I think the only thing that will be successful is a from-scratch written generator with a minimal amount of features from OpenAPIv3 that can be extended by the community.
FWIW my current approach is to use grpc-gateway to produce files in OpenAPI 2 format (via the standard -openapiv2_out
option) and then convert those to OpenAPI 3 format via https://github.com/swagger-api/swagger-codegen:
java -jar /swagger/swagger-codegen-cli.jar generate -l openapi -i "$INFILE" -o "$TEMPDIR"
still waiting for this feature
Looking at this problem at work right now. I used gnostic to generate OpenAPI spec from proto. I'll be adding grpc-gateway soon. I'll report back how it works.
In the meantime, I found this: https://github.com/sv-tools/openapi
Bunch of other libs listed on this site: https://github.com/OAI/OpenAPI-Specification/blob/main/IMPLEMENTATIONS.md
As far as I understand the real challenge is not the OpenAPI generation part (some of the libraries on the above linked page should be able to do that), but mapping proto (particularly all of its types, including well-known types) to OpenAPI.
I have high hopes for gnostic, but the governance model for that project is a bit vague (eg. it's an important dependency for Kubernetes, so some changes are held back until they get prepared; it looks like it's primary role is to serve google API purposes).
A community governed project would certainly have some advantages.
Anyway, fingers crossed that gnostic "just works". 😄
any news on this topic? @sagikazarmark did you solved the problem?
I also hope this gets implemented anytime in the future. Sounds really like a big task, though.
Based on @ianrose14 comment I worked around it with this semi-automatic make target for now. It uses the docker image of swaggerapi/swagger-codegen-cli-v3
to generate openapi v3 files from the swagger.json that's generated by the openapiv2 plugin. Just leaving it here in case anyone needs the same.
like @DGuhr mentioned
To convert you can use this: (execute where YOURTARGET.json is)
docker run --rm --name swagger_codegen -v $PWD:/opt/mnt:Z -w /opt/mnt swaggerapi/swagger-codegen-cli-v3:3.0.41 generate -i ./YOURTARGET.json -l openapi -o .
This would be pretty cool to add to our docs, would you be willing to create a PR for this? Maybe a new section in https://github.com/grpc-ecosystem/grpc-gateway/blob/main/docs/docs/mapping/customizing_openapi_output.md?
As of openapi-generator v6.6.0, the Python generator no longer supports OpenAPI 2.
Your spec version of 2.0 is too low. python only works with specs with version >= 3.X.X. Please use a tool like Swagger Editor or Swagger Converter to convert your spec to v3
What would be required to update to OpenAPI 3?
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md