Skip to content

Fix extend_schema_field type hint to allow a Field type #569

@johnthagen

Description

@johnthagen

def extend_schema_field(
field: Union[_SerializerType, Field, OpenApiTypes, Dict],

I would suggest also allowing Type[Field] to be passed in. I tried it out and it seems to work, but type checking will fail unless you pass an instance.

@extend_schema_field(field=_CustomField)
class CustomJSONField(JSONField):
    ...

Perhaps it would make more sense to only allow passing in Type[Field]? Not sure why an instance would make sense in this context (but Serializer instances are also currently allowed, so to be consistent it should probably allow Field instances too).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfix confirmation pendingissue has been fixed and confirmation from issue reporter is pending

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions