From 5fd83c5fa486687c495a0cab53ebccd948799f4a Mon Sep 17 00:00:00 2001 From: dmontagu <35119617+dmontagu@users.noreply.github.com> Date: Fri, 4 Oct 2019 13:08:41 -0700 Subject: [PATCH] :sparkles: Sort schemas alphabetically (#554) Modify openapi spec generation to include schemas in alphabetical order. --- fastapi/openapi/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index ee35d61fc..89954f5b1 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -283,7 +283,7 @@ def get_openapi( if path_definitions: definitions.update(path_definitions) if definitions: - components.setdefault("schemas", {}).update(definitions) + components["schemas"] = {k: definitions[k] for k in sorted(definitions)} if components: output["components"] = components output["paths"] = paths