-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Serialize model query parameters with style=form, explode=true
BNCH-18023
#39
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,11 +33,12 @@ params: Dict[str, Any] = { | |||||||||
} | ||||||||||
{% for property in endpoint.query_parameters %} | ||||||||||
{% if not property.required %} | ||||||||||
if {{ property.python_name }} is not UNSET: | ||||||||||
{% if property.template %} | ||||||||||
params["{{ property.name }}"] = {{ "json_" + property.python_name }} | ||||||||||
{% set property_name = "json_" + property.python_name if property.template else property.python_name %} | ||||||||||
if {% if not property.required %}not isinstance({{ property_name }}, Unset) and {% endif %}{{ property_name }} is not None: | ||||||||||
{% if property.json_is_dict %} | ||||||||||
params.update({{ property_name }}) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this do the prefixing as expected? I think I would expect something like
Suggested change
in order for it to build the params with e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not handle the prefixing. According to the OpenAPI spec, the parameter name itself does not show up at all in the serialization. See https://swagger.io/specification/ under "Style Examples" |
||||||||||
{% else %} | ||||||||||
params["{{ property.name }}"] = {{ property.python_name }} | ||||||||||
params["{{ property.name }}"] = {{ property_name }} | ||||||||||
{% endif %} | ||||||||||
{% endif %} | ||||||||||
{% endfor %} | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add this classvar to the parent class to be consistent:
It's not erroring now because Jinja is permissive, but if you were to do
property.json_is_dict
outside of a template, it would error for non-model properties.