-
Notifications
You must be signed in to change notification settings - Fork 365
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
REST API: Provide a way to add extra JSON to generated OpenAPI schema endpoints #4035
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hello @rubenfonseca! I would like to hear your opinion here. |
@leandrodamascena Yes, you can add custom keys prefixed with "x-" in an OpenAPI schema while still maintaining its validity. These keys, also known as "vendor extensions," allow you to include additional metadata or vendor-specific information in the schema without violating the OpenAPI specification. The OpenAPI specification allows for the use of vendor extensions, which are properties that begin with the prefix "x-". These extensions can be added at various levels of the schema, such as the root level, object definitions, operation objects, and more. So this would break anything. It's a nice feature that is heavily explorer by @aws/pdk for instance |
@nlykkei I was thinking adding a new optional parameter to all the HTTP method annotations, for instance:
Question: does this make sense to you? I'm also considering what levels should this be added to. Documentation says:
Following the same approach, we could add a |
Thank you, Ruben.
Which documentation are you referring to? Yes, it would sense to add It could also be used to inject other means of authentication, like API key, HTTP Basic, etc. OAuth 2.0 doesn't cover all use cases :) |
Sorry, forgot the link to the documentation! I would prefer not to abuse this mechanism to just add random things to the schema :P For security specifically, please see the plan I shared in the other thread! If you want to take 1 (or more) of this tasks, please let me know :D otherwise I'll be happy to help |
@nlykkei I'm planning to work on this tomorrow if that's ok :) |
@rubenfonseca Thank you 🎉 Consider Pydantic's
https://docs.pydantic.dev/latest/api/fields/ Such customizability is important for injecting e.g. AWS API Gateway specific objects into the generated OpenAPI spec. Furthermore, depending on the
I wouldn't think to much about abusing this mechanism, as neither does Pydantic. It's a mean for users to extend Powertools for AWS Lambda OpenAPI generation capabilities. I'm really sorry that I haven't had more time. I'm an open source developer by heart, thus my current job takes too much of my time |
It shows an example of embedding API Gateway authorizer extension to have API Gateway create a custom Lambda authorizer using the OpenAPI spec |
I think your point of using |
I'm happy you found it useful! :) I think Pydantic serves as a good reference |
Hello, is there any news about this issue? |
Hi @EricOddz! Not yet, I'm working on some v3 issues, but I'll try to look into it next Monday, ok? |
Use case
It would be helpful, if you would support adding extra JSON to generated OpenAPI schema endpoints.
We would like to use the generated OpenAPI scheme to provision an AWS API Gateway REST API using a OpenAPI 3.0 spec. For this, we need to add e.g. x-amazon-apigateway-integration objects.
The only way to accomplish this is by mutating the generated API spec using a post-processing?
https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#customizing-api-operations
Example:
Solution/User Experience
I would like to add extra JSON at the endpoint level, using e.g.
extra_json
, to embed custom AWS API Gateway objects, where they are usedAlternative solutions
Acknowledgment
The text was updated successfully, but these errors were encountered: