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
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:
defcustomfield2properties(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 """ifhasattr(field, "apispec_field2properties"):
field.apispec_field2properties(self, ret)
returnret
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.
The text was updated successfully, but these errors were encountered:
I missed this before. I tend to think it would be more convenient overall for the people creating custom fields to also control their schema representation. Just not sure that they would want to take that on.
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:
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.
The text was updated successfully, but these errors were encountered: