properties' custom_formatters don't work unless the containing shema is strictly Object
Found this issue while investigating the code for #147
I noticed that custom_formatters are not being user for unmarshalling and validating properties, unless their containing Schema is strictly defined.
That is, if the Schema is of type SchemaType.ANY, custom_validators will not work. That's because the _unmarshal_any object fails to propagate the attributes to get_cast_mapping:
def _unmarshal_any(self, value, custom_formatters=None, strict=True):
types_resolve_order = [
SchemaType.OBJECT, SchemaType.ARRAY, SchemaType.BOOLEAN,
SchemaType.INTEGER, SchemaType.NUMBER, SchemaType.STRING,
]
cast_mapping = self.get_cast_mapping()
...
This is specifically sensitive for defining MediaType objects:
paths:
/test:
get:
operationId: test
responses:
'200':
description: ok
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/DefaultResponse'
components:
schemas:
DefaultResponse:
type: object
properties:
url:
type: string
format: url
The shema type for that MediaType will be Any (See #147), so that 'url' format will not unmarshal, even though you may define a custom formatter.
As a work around, you may add a type declaration alongside that allOf:
paths:
/test:
get:
operationId: test
responses:
'200':
description: ok
content:
application/json:
schema:
type: object
allOf:
- $ref: '#/components/schemas/DefaultResponse'
components:
schemas:
DefaultResponse:
type: object
properties:
url:
type: string
format: url
@p1c2u Would you mind reviewing this?