Skip to content
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

Marking a service or method as requiring bearer authentication in proto/grpc definition #308

Closed
SoftMemes opened this issue Feb 13, 2022 · 3 comments · Fixed by #324
Closed

Comments

@SoftMemes
Copy link

I'm comparing the grcp-gateway protoc plugin for openapi (v2) with the one from here for openapi v3. While the built in functionality seems to "just work", I'm not sure how to customise the openapi output further, such as for specifying the security schemes.

I have seen examples of this in the grpc-gateway plugin using custom annotations, e.g. grpc-ecosystem/grpc-gateway#1089

Is there something similar for using the gnostic openapi codegen plugin?

@morphar
Copy link
Collaborator

morphar commented Feb 14, 2022

Currently there is no custom annotations, but what you can do, is to use gnostic for the conversion, then have another step in your build process, where you read the generated OpenAPI, add e.g. security descriptions and then save it again.

@SoftMemes
Copy link
Author

Thank you for the reply @morphar, I know that this is a feature request rather than bug report so appreciate your time. I'm very keen to be able to use the protobuf definitions as the source of truth for all aspects of our services (data contracts but also documentation, including the Swagger UI, etc), and not all of our endpoints would require authentication.

Is what you are proposing to have some other type of annotation in the protos to tag a service as requiring authentication and then to selectively post-process the openapi output to update the security descriptions for these?

@morphar
Copy link
Collaborator

morphar commented Feb 14, 2022

You're very welcome :)

I personally use protobuf as source of truth for everything and generate all else from there.
For OpenAPI / Swagger, I let gnostic do the generation and then have another step after that with the following steps:

  • Read the OpenAPI yaml generated by gnostic
  • Add auth and server definitions
  • Overwrite the OpenAPI yaml

This helps me generate documentation that works across environments - e.g. local dev, test envrionments and live.

Hope that helps :)

timburks pushed a commit that referenced this issue Mar 30, 2022
…ions for File/Document and Method/Operation (#324)

* support fully qualified schema names. fixes #309
* add support for file/document and method/operation annotations. fixes #308
* fix the package name in my tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants