-
-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Description
When using user-defined fields ( such as EnumField as requested in #506 or Union from marshmallow-union) it would be nice to be able to hook directly into apispec.ext.marshmallow.field_converter.FieldConverterMixin.field2property
by defining a specific method.
I'm currently using this simple code for that purpose:
def customfield2properties(self: OpenAPIConverter, field: fields.Field, ret: Dict[str, Any]) -> Dict[str, Any]:
"""
A field attribute function to allow field classes to declare
how to generate/add parameters to their jsonschema representation
"""
if hasattr(field, "apispec_field2properties"):
field.apispec_field2properties(self, ret)
return ret
Once added to the converter with any field defining the apispec_field2properties
method can describe itself without having to add a specific attribute_function to the Marshmallow plugin.
Is this something you would be interested in having in apispec? I can work on a pull request.
mwgamble
Metadata
Metadata
Assignees
Labels
No labels