Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[marshmallow plugin] Inspect validators #66
Many of marshmallow's validators can be inspected to provide additional data when constructing OpenAPI entities.
from marshmallow import fields, validate from apispec.ext.marshmallow.swagger import field2property field = fields.Int(validate=validate.Range(min=3, max=42)) prop = field2property(field) assert prop['minimum'] == 3 assert prop['maximum'] == 42
There are 3 objects in the OpenAPI spec that support validation fields:
The header object only supports simple types, so there is no marshmallow schema to validate.
Unsupported marshmallow validators:
It should be possible to design this mapping in such a way that user defined marshmallow validators could register their own OpenAPI validator mapping with apispec.
Unsupported OpenAPI validators:
Maybe there should be an issue for marshmallow to support these validators, so that there can be a subset of marshmallow validators that completely cover the OpenAPI spec.
It would map to
Should we introduce
Right now, the workaround is to specify both