Skip to content
Discussion options

You must be logged in to vote

hey @mattalexanderhill,

OpenAPI spec generation should be deterministic. You are correct on that. Even though modern Python preserves insertion order, reliance on dictionary iteration order during complex recursive schema mapping is fragile and frequently breaks CI pipelines like yours.

Since you have already identified the loop causing the non-determinism (field_mapping.items()), I strongly encourage you to submit a PR to sort it.
Simply changing the iteration to sorted(field_mapping.items(), key=lambda x: x[0].__name__) (or a similar stable key) would likely solve this for the whole community. It is a valid bug that the spec generation fluctuates.

The issue is triggered because FastAPI …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mattalexanderhill
Comment options

@mattalexanderhill
Comment options

Comment options

You must be logged in to vote
1 reply
@mattalexanderhill
Comment options

Answer selected by mattalexanderhill

This comment was marked as disruptive content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
4 participants