mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-13 18:25:49 -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,4 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.security.tutorial005 import (
|
||||
@@ -267,7 +267,11 @@ def test_openapi_schema():
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.security.tutorial005_an import (
|
||||
@@ -267,7 +267,11 @@ def test_openapi_schema():
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py310
|
||||
@@ -295,7 +295,11 @@ def test_openapi_schema(client: TestClient):
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py39
|
||||
@@ -295,7 +295,11 @@ def test_openapi_schema(client: TestClient):
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py310
|
||||
@@ -295,7 +295,11 @@ def test_openapi_schema(client: TestClient):
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from dirty_equals import IsDict, IsOneOf
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from ...utils import needs_py39
|
||||
@@ -295,7 +295,11 @@ def test_openapi_schema(client: TestClient):
|
||||
"schemas": {
|
||||
"User": {
|
||||
"title": "User",
|
||||
"required": ["username"],
|
||||
"required": IsOneOf(
|
||||
["username", "email", "full_name", "disabled"],
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
["username"],
|
||||
),
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {"title": "Username", "type": "string"},
|
||||
|
||||
Reference in New Issue
Block a user