Right now, it is not easy to use a custom naming scheme for a generic models. But I think this could be useful in some cases.
I recently faced this problem when I realized that the generated schema for List[Optional[T]] types doesn't actually mark the value type as optional (strangely/sadly I think there isn't currently a well-supported way to do this under OpenAPI).
My workaround was to create a wrapper class for optionals:
But I wanted to override the cls.__name__ since that is used by FastAPI when generating the openapi spec. (For example, I wanted to see OptionalInt instead of OptionalWrapper[int].)
Given how small a code change this requires, I think it should be reasonable, but I figured I'd create an issue for discussion just in case.
The text was updated successfully, but these errors were encountered:
dmontagu commentedOct 3, 2019
•
edited
Feature Request
Right now, it is not easy to use a custom naming scheme for a generic models. But I think this could be useful in some cases.
I recently faced this problem when I realized that the generated schema for
List[Optional[T]]
types doesn't actually mark the value type as optional (strangely/sadly I think there isn't currently a well-supported way to do this under OpenAPI).My workaround was to create a wrapper class for optionals:
But I wanted to override the
cls.__name__
since that is used by FastAPI when generating the openapi spec. (For example, I wanted to seeOptionalInt
instead ofOptionalWrapper[int]
.)Given how small a code change this requires, I think it should be reasonable, but I figured I'd create an issue for discussion just in case.
The text was updated successfully, but these errors were encountered: