1.15.1 broke support for Optional type hinting schema generation.
Optional was added in #272 Python versions on which the problem as been reproduced:
To reproduce, create a Serializer like:
from typing import Optional
class MySerializer(Serializer):
x = SerializerMethodField()
def get_x(self, instance) -> Optional[int]:
pass
In 1.15.0, this is properly detected in the generated schema as an integer.
In 1.16.0 (I couldn't get 1.15.1 to run properly), it is incorrectly detected as a string.
I think you're right, it looks like it was broken in 69b628a by removing the if not inspect.isclass(hint_class) and hasattr(hint_class, '__args__'): check in SerializerMethodFieldInspector. I have a PR coming up.
Most helpful comment
I think you're right, it looks like it was broken in 69b628a by removing the
if not inspect.isclass(hint_class) and hasattr(hint_class, '__args__'):check inSerializerMethodFieldInspector. I have a PR coming up.