From: dmontagu <35119617+dmontagu@users.noreply.github.com> Date: Fri, 4 Oct 2019 20:08:41 +0000 (-0700) Subject: :sparkles: Sort schemas alphabetically (#554) X-Git-Tag: 0.40.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5fd83c5fa486687c495a0cab53ebccd948799f4a;p=thirdparty%2Ffastapi%2Ffastapi.git :sparkles: Sort schemas alphabetically (#554) Modify openapi spec generation to include schemas in alphabetical order. --- diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index ee35d61fcf..89954f5b18 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