Closed griggsca91 closed 9 months ago
There are several angles on this:
yq
or jq
could make sense hereEither way, what we'd want to end up with is a way to control these settings: https://swagger.io/docs/specification/authentication/. You can already add this to the 'base' YAML:
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
But then you'd need to somehow dictate which paths uses it. We're missing this right now:
paths:
/billing_info:
get:
summary: Gets the account billing info
security:
- BearerAuth: []
It does look like google.api/auth.proto
allows you to annotate these kinds of authentication details. Maybe this is the way.
https://github.com/googleapis/googleapis/blob/master/google/api/auth.proto
I also just took a look at what GRPC Gateway does, and they specify auth as an option in the protofiles. It looks like it's not specific to auth, but it just allows you to override whatever value gets generated in the openapi output.
which kind of falls under option 2? The options could be the same, it would just fall under the namespace of this plugin.
gRPC in general doesn't specify any direction though in regards to authentication, and the google authentication proto looks like it's specific to google client authentication. I couldn't find a way to use for annotating.
It will be a good amount of work but I think supporting the https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/options/openapiv2.proto protobuf file. This would remove the need for having a "base" openapi file.
I decided to use google/gnostic's openapiv3 protobuf annotations for this instead of grpc-gateway... but I did just add some support for these annotations:
Only the document-level and (some) method-level options are respected now. The rest can be supported in time.
I won't count this issue as complete until it's properly documented
Okay, I found some time today to work on this. I've updated the README outlining which annotations are supported. If support for more annotations are added I'll more this to a different document so that the README isn't too hard to navigate.
Awesome thanks! Didn't expect this so quickly. Appreciate it!
Usecase: Routes require authentication and want to be able to paste in a token so we can make requests from Swagger or RapiDoc UI.
Question: Is there any way to identify that a route requires authentication?