-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
marshmallow/swagger.py - custom field mapping #88
Comments
Well, since nothing prevents me from importing from apispec.ext.marshmallow.swagger import FIELD_MAPPING
class MyDocClass(object):
def register_field(self, field, field_type, field_format):
FIELD_MAPPING[field] = (field_type, field_format) |
One last thing, though: is it safe to import and modify I believe the use case is valid, so it would make sense to consider this object part of the API, and consider its modification/removal as a breaking change (or alternatively provide a function in the API to wrap it). More generally, is there some sort of convention in Python about what objects in a lib are part of the API and can be safely imported? Any way to know for sure? Like,
|
It is perfectly valid to modify
I'm not sure there's any documented convention, but the list you have above is a good rule of thumb. |
Hi.
Assuming a model uses custom Marshmallow fields, those do not appear in
FIELD_MAPPING
and therefore are not documented properly: default (type, format) is ('string', None).If
_get_json_type_for_field
usedisinstance
rather thantype
, fields inheriting from Marshmallow fields would at least be treated like their parent, but this wouldn't be totally satisfying.OpenAPI spec allows custom formats for fields, like apispec does
Email
, for instance,Is there a way to pass custom field mappings to apispec?
If not, would this be considered a relevant feature request?
A list of custom types ((
CUSTOM_FIELD_MAPPING
) could be appended toFIELD_MAPPING
. Or better,CUSTOM_FIELD_MAPPING
would be checked first, so as to allow overriding existing mappings inFIELD_MAPPING
.The text was updated successfully, but these errors were encountered: