mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-18 21:39:22 -04:00
✨ Enable Pydantic's serialization mode for responses, add support for Pydantic's computed_field, better OpenAPI for response models, proper required attributes, better generated clients (#10011)
* ✨ Enable Pydantic's serialization mode for responses * ✅ Update tests with new Pydantic v2 serialization mode * ✅ Add a test for Pydantic v2's computed_field
This commit is contained in:
committed by
GitHub
parent
d943e02232
commit
19a2c3bb54
@@ -1,3 +1,4 @@
|
||||
from dirty_equals import IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.extra_models.tutorial003 import app
|
||||
@@ -76,7 +77,11 @@ def test_openapi_schema():
|
||||
"schemas": {
|
||||
"PlaneItem": {
|
||||
"title": "PlaneItem",
|
||||
"required": ["description", "size"],
|
||||
"required": IsOneOf(
|
||||
["description", "type", "size"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["description", "size"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {"title": "Description", "type": "string"},
|
||||
@@ -86,7 +91,11 @@ def test_openapi_schema():
|
||||
},
|
||||
"CarItem": {
|
||||
"title": "CarItem",
|
||||
"required": ["description"],
|
||||
"required": IsOneOf(
|
||||
["description", "type"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["description"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {"title": "Description", "type": "string"},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
from dirty_equals import IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py310
|
||||
@@ -86,7 +87,11 @@ def test_openapi_schema(client: TestClient):
|
||||
"schemas": {
|
||||
"PlaneItem": {
|
||||
"title": "PlaneItem",
|
||||
"required": ["description", "size"],
|
||||
"required": IsOneOf(
|
||||
["description", "type", "size"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["description", "size"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {"title": "Description", "type": "string"},
|
||||
@@ -96,7 +101,11 @@ def test_openapi_schema(client: TestClient):
|
||||
},
|
||||
"CarItem": {
|
||||
"title": "CarItem",
|
||||
"required": ["description"],
|
||||
"required": IsOneOf(
|
||||
["description", "type"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["description"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {"title": "Description", "type": "string"},
|
||||
|
||||
Reference in New Issue
Block a user