Skip to content

Conversation

@philvarner
Copy link
Contributor

@philvarner philvarner commented Dec 23, 2025

What I'm changing

A existing problem with the typing for various methods is that an implementer could not create their own implementation of OrderStatus and have additional properties in it be serialized in server responses. This is due to fastapi's use of type annotations for determining what serializer to use when returning an object from an endpoint. As defined, any object returned as the status (either with an Order or from the Order statuses endpoint) will be serialized as an Order Status, so any additional provider-specific attributes are not included. However, by adding the correct generic typing, a provider can redefine these endpoints so their own custom OrderStatus class will be serialized correctly.

How I did it

  1. Refactored the Callable aliases GetOrders, GetOrder, GetOrderStatuses as classes that implement dunder call, so that they can have generic parameters
  2. Refactor the uses of RootRouter in ProductRouter to have two protocols (ConformancesSupport and RootProvider), to decouple the actual (generified) RootRouter from the uses in that class.

Checklist

  • Tests pass: ./scripts/run-tests.sh
  • Checks pass: uv run pre-commit run --all-files
  • CHANGELOG is updated (if necessary)

@philvarner philvarner changed the title add typing to support variable OrderStatus objects Add better typing to support variable OrderStatus objects Dec 31, 2025
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.

2 participants