]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
✅ Update internal tests for latest Pydantic, including CI tweaks to install the lates...
authorSebastián Ramírez <tiangolo@gmail.com>
Fri, 6 Sep 2024 15:57:43 +0000 (17:57 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Sep 2024 15:57:43 +0000 (15:57 +0000)
.github/workflows/test.yml
tests/test_openapi_examples.py

index e9db49b51fd306c75ebd64e36f35751c05318483..fb4b083c4e0c1875d5deebce5622843bbdb37809 100644 (file)
@@ -37,7 +37,7 @@ jobs:
         if: steps.cache.outputs.cache-hit != 'true'
         run: pip install -r requirements-tests.txt
       - name: Install Pydantic v2
-        run: pip install "pydantic>=2.0.2,<3.0.0"
+        run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
       - name: Lint
         run: bash scripts/lint.sh
 
@@ -79,7 +79,7 @@ jobs:
         run: pip install "pydantic>=1.10.0,<2.0.0"
       - name: Install Pydantic v2
         if: matrix.pydantic-version == 'pydantic-v2'
-        run: pip install "pydantic>=2.0.2,<3.0.0"
+        run: pip install --upgrade "pydantic>=2.0.2,<3.0.0"
       - run: mkdir coverage
       - name: Test
         run: bash scripts/test.sh
index 6597e5058bfedae168b17d4415dea6db956b99cd..b3f83ae237ff84fd8841116a56d68a59d00018ab 100644 (file)
@@ -155,13 +155,26 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {
-                                    "allOf": [{"$ref": "#/components/schemas/Item"}],
-                                    "title": "Item",
-                                    "examples": [
-                                        {"data": "Data in Body examples, example1"}
-                                    ],
-                                },
+                                "schema": IsDict(
+                                    {
+                                        "$ref": "#/components/schemas/Item",
+                                        "examples": [
+                                            {"data": "Data in Body examples, example1"}
+                                        ],
+                                    }
+                                )
+                                | IsDict(
+                                    {
+                                        # TODO: remove when deprecating Pydantic v1
+                                        "allOf": [
+                                            {"$ref": "#/components/schemas/Item"}
+                                        ],
+                                        "title": "Item",
+                                        "examples": [
+                                            {"data": "Data in Body examples, example1"}
+                                        ],
+                                    }
+                                ),
                                 "examples": {
                                     "Example One": {
                                         "summary": "Example One Summary",