properties' custom_formatters don't work unless the containing shema is strictly Object
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- openapi, python
- Domain
- api, backend-api-design
Research direction
Start with _unmarshal_any and its call to get_cast_mapping, then trace how custom_formatters and custom validators are propagated for SchemaType.ANY. Reproduce the MediaType example with the url format and verify that custom formatting and validation work for properties within an ANY schema.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 368
- Forks
- 140
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-openapi/openapi-core
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-openapi/openapi-core#1188 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1225 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Openkind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Difficulty 3/5 1-2 days Newbie friendliness 58/100
python-openapi/openapi-core#1180 · 3 comments ·
All issues in python-openapi/openapi-core
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·