-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
bugSomething isn't workingSomething isn't working
Description
No type case
InputModules = Module1 | Module2
class ResponseSchema(BaseModel):
content: InputModules
...Generated pydantic schema looks like
{
'components': {
'schemas': {
'ResponseSchema': {
'properties': {
'content': {
'anyOf': [
{'$ref': '#/components/schemas/Module1'},
{'$ref': '#/components/schemas/Module2'},
],
'title': 'Content',
},
},
'type': 'object',
'required': ['content', ...],
'title': 'ResponseSchema',
},
}
}
}type case
type InputModules = Module1 | Module2
class ResponseSchema(BaseModel):
content: InputModules
...Generated pydantic schema looks like
{
'components': {
'schemas': {
'InputModules': {
'anyOf': [
{'$ref': '#/components/schemas/Module1'},
{'$ref': '#/components/schemas/Module2'},
],
},
'ResponseSchema': {
'properties': {
'content': {'$ref': '#/components/schemas/InputModules'},
},
'type': 'object',
'required': ['content', ...],
'title': 'ResponseSchema',
},
}
}
}And app fails with exception
File ".../fastapi/applications.py", line 1009, in openapi
return JSONResponse(self.openapi())
^^^^^^^^^^^^^^
File ".../fastapi_jsonrpc/__init__.py", line 1436, in openapi
self._restore_json_schema_fine_component_names(result)
File ".../fastapi_jsonrpc/__init__.py", line 1425, in _restore_json_schema_fine_component_names
fine_schema_name = key[:-len(schema['title'].replace('.', '__'))].replace('__', '.') + schema['title']
~~~~~~^^^^^^^^^
KeyError: 'title'
Environment:
fastapi~=0.116.1
pydantic~=2.11.7
fastapi-jsonrpc~=3.4.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working