Skip to content

SchemaGenerator.registry refers to Dataclass not to DataclassSerializer in hooks #1343

@HansAarneLiblik

Description

@HansAarneLiblik

Describe the bug
We have POSTPROCESSING hook, that changes the schema, based on the serializer. We're using our own @extend_schema_serializer decorator to add title to the generated schema. This implementation is copied from the original hook, as sadly title support is not available in the original.

In the hook we're

  • iterating over components.schemas
  • Retrieving the actual component from SchemaGenerator.registry
  • Accessing the "serializer" via component.object

After upgrading from 0.27.2 to 0.28.0, it seems that this does not work for DataclassSerializers anymore, as the component.object now refers to the actual Dataclass, while it used to refer to the DataclassSerializer, which we had decorated and customized

I can make a repro case if the problem is not obvious, but that takes some time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions