]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:white_check_mark: Add test from @dmontagu in #333 for duplicate models (#385)
authorSebastián Ramírez <tiangolo@gmail.com>
Sat, 13 Jul 2019 00:13:28 +0000 (19:13 -0500)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2019 00:13:28 +0000 (19:13 -0500)
tests/test_duplicate_models_openapi.py [new file with mode: 0644]

diff --git a/tests/test_duplicate_models_openapi.py b/tests/test_duplicate_models_openapi.py
new file mode 100644 (file)
index 0000000..ad4f1e7
--- /dev/null
@@ -0,0 +1,23 @@
+from fastapi import FastAPI
+from pydantic import BaseModel
+
+
+def test_get_openapi():
+    app = FastAPI()
+
+    class Model(BaseModel):
+        pass
+
+    class Model2(BaseModel):
+        a: Model
+
+    class Model3(BaseModel):
+        c: Model
+        d: Model2
+
+    @app.get("/", response_model=Model3)
+    def f():
+        pass  # pragma: no cover
+
+    openapi = app.openapi()
+    assert isinstance(openapi, dict)