-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support is missing for some field types, particularly Boolean, Date, and DateTime #15
Comments
Looking at the code, it seems there is also no support for various validation qualifiers such as min_length, max_length, pattern, minimum, maximum, etc. These would probably translate from validators. For example:
Taken from https://marshmallow.readthedocs.io/en/stable/quickstart.html?highlight=length#validation I think it will be quite a lot of work to get this into a fully featured tool, but I'd be glad to help. The apispec project has a Marshmallow Plugin that converts Marshmallow schemas to json schema. It does a pretty good job and you might want to have a look at that. The json schema validation qualifiers are similar to what flask-restplus models use. One thing that is missing from their translation is default values. |
Good points. Easy to add the additional types where there is a straightforward match. I only skipped them because I didn't need them at the time and figured if/when anybody else was interested they could be implemented at that time. As for the validator conversion, are you referring to converting the validators from the schema into something that can be documented in Swagger? The actual validation functionality can be used as-is because the marshmallow schema is used to perform the validation when a schema is provided (not a converted api.Model). The converted model only exists in the documentation. |
Example here |
Supporting the validations within Swagger like here from the RESTplus docs could be done via a direct translation. There are likely some cases that don't have a counterpart, and that would probably require something more custom. |
Closing as the title issue has been resolved. Will open a separate thread for validator discussion. |
As in the title, it would be very useful to support the Date, DateTime, and Boolean field types. These don't come through in the registered model, and I can see that they are not in the type_map dict in utils.py. There are a great many field types in Marshmallow, some of which may not be relevant to this conversion exercise, but the three I've listed are arguably essential. Where a type is not supported in flask-accepts, I'd say it should default to Raw.
The text was updated successfully, but these errors were encountered: