You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To describe the parameter contents, you can use either the schema or content keyword.
[...]
content is used in complex serialization scenarios that are not covered by style and explode.
apispec assumes schema:
def_field2parameter(
self, field: marshmallow.fields.Field, *, name: str, location: str
) ->dict:
"""Return an OpenAPI parameter as a `dict`, given a marshmallow :class:`Field <marshmallow.Field>`. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameterObject """ret: dict= {"in": location, "name": name}
prop=self.field2property(field)
ifself.openapi_version.major<3:
ret.update(prop)
else:
if"description"inprop:
ret["description"] =prop.pop("description")
if"deprecated"inprop:
ret["deprecated"] =prop.pop("deprecated")
ret["schema"] =prop# <------------------------ hereforparam_attr_funcinself.parameter_attribute_functions:
ret.update(param_attr_func(field, ret=ret))
returnret
In my code, I had to override that method to document a field that expects a JSON object and deserializes it into a dict:
We already added parameter_attribute_functions in #778 for specific cases that couldn't be addressed in field2property. Unfortunately, those functions only add stuff to the doc (their return value is fed to ret.update), so they can't do what is required above.
We could change that to let parameter attribute functions mutate ret for more customization (breaking change). It makes me cringe a bit because if several functions apply to the same field, they may interfere with each other and cause a crash. But after all, we're all grown-ups and I expect those kinds of exceptions to be scarce, so it shouldn't be an issue.
I'll try to carve some time to investigate this. Meanwhile, better ideas welcome.
The text was updated successfully, but these errors were encountered:
https://swagger.io/docs/specification/describing-parameters/
apispec assumes
schema
:In my code, I had to override that method to document a field that expects a JSON object and deserializes it into a
dict
:We already added
parameter_attribute_functions
in #778 for specific cases that couldn't be addressed infield2property
. Unfortunately, those functions only add stuff to the doc (their return value is fed toret.update
), so they can't do what is required above.We could change that to let parameter attribute functions mutate
ret
for more customization (breaking change). It makes me cringe a bit because if several functions apply to the same field, they may interfere with each other and cause a crash. But after all, we're all grown-ups and I expect those kinds of exceptions to be scarce, so it shouldn't be an issue.I'll try to carve some time to investigate this. Meanwhile, better ideas welcome.
The text was updated successfully, but these errors were encountered: