Skip to content

Dispatch Serializable subclasses of registered types to themselves#56

Open
renan-r-santos wants to merge 1 commit into
drhagen:masterfrom
renan-r-santos:dispatch-serializable-subclasses
Open

Dispatch Serializable subclasses of registered types to themselves#56
renan-r-santos wants to merge 1 commit into
drhagen:masterfrom
renan-r-santos:dispatch-serializable-subclasses

Conversation

@renan-r-santos

Copy link
Copy Markdown
Contributor

A Serializable subclass that also inherits a type with a registered serializer, for example, class UUID7(UUID, Serializable), class Tag(str, Serializable), used to silently dispatch to the base's serializer (the MRO walk found UuidSerializer/StringSerializer first), so its own from_data/to_data were ignored. This makes such a class win as its own serializer, which is what enables defining custom scalar types.

An explicit serializer.register(...) still takes precedence over this rule, and the same handling applies to generic origins (Box[int], TypedList[int]). Since a custom scalar typically isn't an OpenAPI component, its schema is inlined into the owning model rather than emitted as a separate $ref.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant