]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:sparkles: Sort schemas alphabetically (#554)
authordmontagu <35119617+dmontagu@users.noreply.github.com>
Fri, 4 Oct 2019 20:08:41 +0000 (13:08 -0700)
committerSebastián Ramírez <tiangolo@gmail.com>
Fri, 4 Oct 2019 20:08:41 +0000 (15:08 -0500)
Modify openapi spec generation to include schemas in alphabetical order.

fastapi/openapi/utils.py

index ee35d61fcf476a6634ad338b29c4b5cba0ef9854..89954f5b188016a707712dc7c0e16ee2d69ca50c 100644 (file)
@@ -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