Summary
Right now this happens for this code sample:
from litestar import Litestar, get
from typing import TypedDict
from typing_extensions import ReadOnly
class Model(TypedDict):
id: ReadOnly[str]
@get('/')
async def test_route() -> Model:
return {'id': 'test'}
app = Litestar(
route_handlers=[test_route],
)
/schema endpoint raises:
500: Parameter 'id' with type 'typing.ReadOnly[str]' could not be mapped to an Open API type. This can occur if a user-defined generic type is resolved as a parameter. If 'id' should not be documented as a parameter, annotate it using the `Dependency` function, e.g., `id: ... = Dependency(...)`.
Note that OpenAPI has readOnly: true property, see https://swagger.io/docs/specification/v3_0/data-models/data-types/#read-only-and-write-only-properties But! It is not the same ReadOnly as in Python. Our ReadOnly means that the key in TypeDict can't be changed. I think the proper solution here is to just unwrap ReadOnly[T] to T
I will send a PR.
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
Summary
Right now this happens for this code sample:
/schemaendpoint raises:Note that OpenAPI has
readOnly: trueproperty, see https://swagger.io/docs/specification/v3_0/data-models/data-types/#read-only-and-write-only-properties But! It is not the sameReadOnlyas in Python. OurReadOnlymeans that the key inTypeDictcan't be changed. I think the proper solution here is to just unwrapReadOnly[T]toTI will send a PR.
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response