Skip to content

Commit 5fd83c5

Browse files
dmontagutiangolo
authored andcommitted
✨ Sort schemas alphabetically (fastapi#554)
Modify openapi spec generation to include schemas in alphabetical order.
1 parent 14daaf4 commit 5fd83c5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fastapi/openapi/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def get_openapi(
283283
if path_definitions:
284284
definitions.update(path_definitions)
285285
if definitions:
286-
components.setdefault("schemas", {}).update(definitions)
286+
components["schemas"] = {k: definitions[k] for k in sorted(definitions)}
287287
if components:
288288
output["components"] = components
289289
output["paths"] = paths

0 commit comments

Comments
 (0)