Browse Source

Update snapshots for Pydantic v1 and v2

pull/14168/head
Sebastián Ramírez 10 months ago
parent
commit
803ca5f735
  1. 55
      tests/test_pydantic_v1_v2_multifile/test_multifile.py

55
tests/test_pydantic_v1_v2_multifile/test_multifile.py

@ -1,6 +1,8 @@
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot from inline_snapshot import snapshot
from tests.utils import pydantic_snapshot
from .main import app from .main import app
client = TestClient(app) client = TestClient(app)
@ -237,14 +239,23 @@ def test_openapi_schema():
"requestBody": { "requestBody": {
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": pydantic_snapshot(
"allOf": [ v2=snapshot(
{
"allOf": [
{
"$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item"
}
],
"title": "Data",
}
),
v1=snapshot(
{ {
"$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item" "$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item"
} }
], ),
"title": "Data", )
}
} }
}, },
"required": True, "required": True,
@ -318,14 +329,23 @@ def test_openapi_schema():
"requestBody": { "requestBody": {
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": pydantic_snapshot(
"allOf": [ v2=snapshot(
{
"allOf": [
{
"$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item"
}
],
"title": "Data",
}
),
v1=snapshot(
{ {
"$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item" "$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv1__Item"
} }
], ),
"title": "Data", )
}
} }
}, },
"required": True, "required": True,
@ -639,10 +659,17 @@ def test_openapi_schema():
"properties": { "properties": {
"new_title": {"type": "string", "title": "New Title"}, "new_title": {"type": "string", "title": "New Title"},
"new_size": {"type": "integer", "title": "New Size"}, "new_size": {"type": "integer", "title": "New Size"},
"new_description": { "new_description": pydantic_snapshot(
"anyOf": [{"type": "string"}, {"type": "null"}], v2=snapshot(
"title": "New Description", {
}, "anyOf": [{"type": "string"}, {"type": "null"}],
"title": "New Description",
}
),
v1=snapshot(
{"type": "string", "title": "New Description"}
),
),
"new_sub": { "new_sub": {
"$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv2__SubItem" "$ref": "#/components/schemas/tests__test_pydantic_v1_v2_multifile__modelsv2__SubItem"
}, },

Loading…
Cancel
Save