fix(type-safe-api): fix syntax error for python runtime request parameters with descriptions #610
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.
Descriptions in Python request parameters would previously render invalid python syntax as quotes were escaped as
"
. Use triple curly braces ({{{vendorExtensions.x-py-typing}}}
) to ensure these are rendered correctly.Additionally, field references can only be used once per field in a pydantic model, and since fields with descriptions include the field in the type annotation these would fail at runtime when another field is used in the assignment, ie:
The above causes a runtime error (
ValueError: `Field` default cannot be set in `Annotated` for ...
- pydantic/pydantic#3991 )We therefore remove the assignment of a
Field
value, which is ok since the alias is not required as the handler wrapper already constructs a dict with theparamName
s as keys rather than thebaseName
s which are in the raw request. ie we already do:Which means we even load renamed parameters (like a header
x-foo-bar
from a dictionary which names it asx_foo_bar
).Fixes #609