(self, obj, field)
return schema
Get schema and validators for field.
Get schema and validators for field.
Get schema and validators for field .
def _get_schema_for_field(self, obj, field):
        """Get schema and validators for field."""
        if hasattr(field, "_jsonschema_type_mapping"):
            schema = field._jsonschema_type_mapping()
        elif "_jsonschema_type_mapping" in field.metadata:
            schema = field.metadata["_jsonschema_type_mapping"]
        else:
            if isinstance(field, fields.Nested):
                # Special treatment for nested fields.
                schema = self._from_nested_schema(obj, field)
            elif ALLOW_UNIONS and isinstance(field, Union):
                schema = self._from_union_schema(obj, field)
            else:
                pytype = self._get_python_type(field)
                schema = self._from_python_type(obj, field, pytype)
        # Apply any and all validators that field may have
        for validator in field.validators:
            if validator.__class__ in FIELD_VALIDATORS:
                schema = FIELD_VALIDATORS[validator.__class__](
                    schema, field, validator, obj
                )
            else:
                base_class = getattr(
                    validator, "_jsonschema_base_validator_class", None
                )
                if base_class is not None and base_class in FIELD_VALIDATORS:
                    schema = FIELD_VALIDATORS[base_class](schema, field, validator, obj)
        return schema
def _get_schema_for_field ( self , obj , field ) : if hasattr ( field , "_jsonschema_type_mapping" ) : schema = field . _jsonschema_type_mapping ( ) elif "_jsonschema_type_mapping" in field . metadata : schema = field . metadata [ "_jsonschema_type_mapping" ] else : if isinstance ( field , fields . Nested ) : # Special treatment for nested fields. schema = self . _from_nested_schema ( obj , field ) elif ALLOW_UNIONS and isinstance ( field , Union ) : schema = self . _from_union_schema ( obj , field ) else : pytype = self . _get_python_type ( field ) schema = self . _from_python_type ( obj , field , pytype ) # Apply any and all validators that field may have for validator in field . validators : if validator . __class__ in FIELD_VALIDATORS : schema = FIELD_VALIDATORS [ validator . __class__ ] ( schema , field , validator , obj ) else : base_class = getattr ( validator , "_jsonschema_base_validator_class" , None ) if base_class is not None and base_class in FIELD_VALIDATORS : schema = FIELD_VALIDATORS [ base_class ] ( schema , field , validator , obj ) return schema