Exception thrown generating OpenAPI Schema when representing LargeBinary as base64
See original GitHub issueIssue Description
Describe the bug
Exception thrown generating OpenAPI Schema when representing LargeBinary as base64
To Reproduce
Create Model
like:
class BaseMessageModel(Model):
class Meta:
abstract = True
metadata = metadata
database = database
id: int = Integer(primary_key=True)
data: str = LargeBinary(
max_length=SQLITE_MAX_BLOB_SIZE,
represent_as_base64_str=True,
)
Navigate to the /docs
URL:
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 398, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
return await self.app(scope, receive, send)
File "venv/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
await super().__call__(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "venv/lib/python3.9/site-packages/starlette/middleware/cors.py", line 78, in __call__
await self.app(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "venv/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "venv/lib/python3.9/site-packages/starlette/routing.py", line 580, in __call__
await route.handle(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/routing.py", line 390, in handle
await self.app(scope, receive, send)
File "venv/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
await super().__call__(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "venv/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "venv/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "venv/lib/python3.9/site-packages/starlette/routing.py", line 580, in __call__
await route.handle(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
File "venv/lib/python3.9/site-packages/starlette/routing.py", line 52, in app
response = await func(request)
File "venv/lib/python3.9/site-packages/fastapi/applications.py", line 152, in openapi
return JSONResponse(self.openapi())
File "venv/lib/python3.9/site-packages/fastapi/applications.py", line 130, in openapi
self.openapi_schema = get_openapi(
File "venv/lib/python3.9/site-packages/fastapi/openapi/utils.py", line 363, in get_openapi
definitions = get_model_definitions(
File "venv/lib/python3.9/site-packages/fastapi/utils.py", line 24, in get_model_definitions
m_schema, m_definitions, m_nested_models = model_process_schema(
File "pydantic/schema.py", line 539, in pydantic.schema.model_process_schema
File "venv/lib/python3.9/site-packages/ormar/models/helpers/validation.py", line 298, in schema_extra
overwrite_binary_format(schema=schema, model=model)
File "venv/lib/python3.9/site-packages/ormar/models/helpers/validation.py", line 255, in overwrite_binary_format
base64.b64encode(choice).decode() for choice in prop["enum"]
KeyError: 'enum'
Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):
- Database backend used (mysql/sqlite/postgress): sqlite
- Python version: 3.9.5
ormar
version: 0.10.8pydantic
version: 1.7.4- if applicable
fastapi
version: 0.65.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
[oas3] base64 vs byte #1547 - OAI/OpenAPI-Specification
Oh, it's valid, it's just that the defined data types section defines {format: 'byte'} as "base64 encoded characters". It seems weird to define ......
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML...
Read more >An adventure in OpenAPI V3 code generation | Mux blog
We wanted to give our users a better experience by throwing more specific exceptions based on the status code we receive from the...
Read more >Using OpenAPI and Swagger UI - Quarkus
Architecture. In this guide, we create a straightforward REST application to demonstrate how fast you can expose your API specification and benefit from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@collerek I tested 0.10.10 and everything worked perfectly.
Confirmed,
master
working as expected. Thanks!