Commit 13e65a2
committed
Add missing STRING_FORMAT_CALLABLE_GETTER: SchemaFormat.PASSWORD
`password` is a valid OpenAPIv3 string format, that is used as a UI hint
for frontend clients to mask the input field.
It was already present in the `SchemaFormat` enum, but it was not
handled in `_unmarshal_string` that uses `STRING_FORMAT_CALLABLE_GETTER`
to decide how to unmarshal a string, which would result in an error like
this one:
```
Traceback (most recent call last):
[... snip ...]
File ".venv/lib/python3.7/site-packages/openapi_core/validation/request/validators.py", line 37, in validate
body, body_errors = self._get_body(request, operation)
File ".venv/lib/python3.7/site-packages/openapi_core/validation/request/validators.py", line 82, in _get_body
body = media_type.unmarshal(raw_body, self.custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/media_types/models.py", line 45, in unmarshal
unmarshalled = self.schema.unmarshal(deserialized, custom_formatters=custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
return cast_callable(value)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 295, in _unmarshal_object
value, custom_formatters=custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 335, in _unmarshal_properties
prop_value, custom_formatters=custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
return cast_callable(value)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 295, in _unmarshal_object
value, custom_formatters=custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 335, in _unmarshal_properties
prop_value, custom_formatters=custom_formatters)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 189, in unmarshal
casted = self.cast(value, custom_formatters=custom_formatters, strict=strict)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 179, in cast
return cast_callable(value)
File ".venv/lib/python3.7/site-packages/openapi_core/schema/schemas/models.py", line 215, in _unmarshal_string
formatstring = self.STRING_FORMAT_CALLABLE_GETTER[schema_format]
KeyError: <SchemaFormat.PASSWORD: 'password'>
```1 parent f274836 commit 13e65a2
File tree
2 files changed
+9
-0
lines changed- openapi_core/schema/schemas
- tests/unit/schema
2 files changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
0 commit comments