properties' custom_formatters don't work unless the containing shema is strictly Object
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- openapi, python
- Bereich
- api, backend-api-design
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Python
- Sterne
- 368
- Forks
- 140
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-openapi/openapi-core
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python-openapi/openapi-core#1188 · 2 Kommentare ·
-
kind/bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
python-openapi/openapi-core#1225 · 2 Kommentare ·
-
kind/bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Offenkind/bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
python-openapi/openapi-core#1180 · 3 Kommentare ·
Alle Issues in python-openapi/openapi-core
Ähnliche Issues
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
canonical/paas-charm#368 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
tech debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
StevenBlack/hosts#3256 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
qualcomm/qai-appbuilder#275 ·