Fix same function names in different modules with composite bodies #347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix same function names in different modules with composite bodies.
Currently, if two path operation functions are named the same, in two separate modules, and receive several body parameters, they are converted into a composite body JSON Schema for OpenAPI.
But the names are generated based on the path operation name, and if the name is not assigned but autogenerated (based on the function name), two JSON Schemas could have the same name, breaking the OpenAPI generation.
This PR re-implements the name generation for composite bodies and response JSON Schemas in OpenAPI.
An explicit example can be found in the added tests.
This also means that it's now possible to use
.include_router
multiple times with the same router, under differentprefix
es, and it will work. For example, it can be used to expose the same router under different API prefixes (e.g./api/v2
and/api/latest
).This fixes #284