File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1818default_role = "py:obj"
1919
2020intersphinx_mapping = {
21- "python" : ("http://python.readthedocs.io/en/latest/" , None ),
22- "marshmallow" : ("http://marshmallow.readthedocs.io/en/latest/" , None ),
21+ "python" : ("https://python.readthedocs.io/en/latest/" , None ),
22+ "marshmallow" : ("https://marshmallow.readthedocs.io/en/latest/" , None ),
23+ "webargs" : ("https://webargs.readthedocs.io/en/latest/" , None ),
2324}
2425
2526issues_github_path = "marshmallow-code/apispec"
Original file line number Diff line number Diff line change @@ -295,6 +295,32 @@ method. Continuing from the example above:
295295 The function passed to `add_attribute_function ` will be bound to the converter.
296296It must accept the converter instance as first positional argument.
297297
298+ In some rare cases, typically with container fields such as fields derived from
299+ :class: `List <marshmallow.fields.List> `, documenting the parameters using this
300+ field require some more customization.
301+ This can be achieved using the `add_parameter_attribute_function
302+ <apispec.ext.marshmallow.openapi.OpenAPIConverter.add_parameter_attribute_function> `
303+ method.
304+
305+ For instance, when documenting webargs's
306+ :class: `DelimitedList <webargs.fields.DelimitedList> ` field, one may register
307+ this function:
308+
309+ .. code-block :: python
310+
311+ def delimited_list2param (self , field , ** kwargs ):
312+ ret: dict = {}
313+ if isinstance (field, DelimitedList):
314+ if self .openapi_version.major < 3 :
315+ ret[" collectionFormat" ] = " csv"
316+ else :
317+ ret[" explode" ] = False
318+ ret[" style" ] = " form"
319+ return ret
320+
321+
322+ ma_plugin.converter.add_parameter_attribute_function(delimited_list2param)
323+
298324 Next Steps
299325----------
300326
You can’t perform that action at this time.
0 commit comments