Skip to content

KeyError: <SchemaFormat.BYTE: 'byte'> #110

@mnboos

Description

@mnboos

We encounter the following error because we use a string property with format 'byte' (for base64 strings, according to the OpenAPI specification (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types).

The properties part of the OpenAPI schema looks like this:

"properties": {
	"data": {
		"type": "string",
		"format": "byte"
	}
  File "/venv/lib/python3.6/site-packages/openapi_core/validation/request/validators.py", line 37, in validate
    body, body_errors = self._get_body(request, operation)
  File "/venv/lib/python3.6/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.6/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.6/site-packages/openapi_core/schema/schemas/models.py", line 183, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 173, in cast
    return cast_callable(value)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 263, in _unmarshal_object
    value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 302, in _unmarshal_properties
    prop_value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 183, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 173, in cast
    return cast_callable(value)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 263, in _unmarshal_object
    value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 302, in _unmarshal_properties
    prop_value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 183, in unmarshal
    casted = self.cast(value, custom_formatters=custom_formatters)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 173, in cast
    return cast_callable(value)
  File "/venv/lib/python3.6/site-packages/openapi_core/schema/schemas/models.py", line 206, in _unmarshal_string
    formatstring = self.STRING_FORMAT_CALLABLE_GETTER[schema_format]
KeyError: <SchemaFormat.BYTE: 'byte'>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions