|
|
@ -3,6 +3,7 @@ from typing import Annotated |
|
|
from dirty_equals import IsList |
|
|
from dirty_equals import IsList |
|
|
from fastapi import FastAPI, Query |
|
|
from fastapi import FastAPI, Query |
|
|
from fastapi.testclient import TestClient |
|
|
from fastapi.testclient import TestClient |
|
|
|
|
|
from inline_snapshot import snapshot |
|
|
from pydantic import Field |
|
|
from pydantic import Field |
|
|
|
|
|
|
|
|
MaxSizedSet = Annotated[set[str], Field(max_length=3)] |
|
|
MaxSizedSet = Annotated[set[str], Field(max_length=3)] |
|
|
@ -33,7 +34,8 @@ def test_endpoint_valid(): |
|
|
def test_endpoint_too_long(): |
|
|
def test_endpoint_too_long(): |
|
|
response = client.get("/", params={"foo": ["a", "b", "c", "d"]}) |
|
|
response = client.get("/", params={"foo": ["a", "b", "c", "d"]}) |
|
|
assert response.status_code == 422 |
|
|
assert response.status_code == 422 |
|
|
assert response.json() == { |
|
|
assert response.json() == snapshot( |
|
|
|
|
|
{ |
|
|
"detail": [ |
|
|
"detail": [ |
|
|
{ |
|
|
{ |
|
|
"type": "too_long", |
|
|
"type": "too_long", |
|
|
@ -48,16 +50,20 @@ def test_endpoint_too_long(): |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_openapi(): |
|
|
def test_openapi(): |
|
|
assert app.openapi() == { |
|
|
assert app.openapi() == snapshot( |
|
|
|
|
|
{ |
|
|
"components": { |
|
|
"components": { |
|
|
"schemas": { |
|
|
"schemas": { |
|
|
"HTTPValidationError": { |
|
|
"HTTPValidationError": { |
|
|
"properties": { |
|
|
"properties": { |
|
|
"detail": { |
|
|
"detail": { |
|
|
"items": {"$ref": "#/components/schemas/ValidationError"}, |
|
|
"items": { |
|
|
|
|
|
"$ref": "#/components/schemas/ValidationError" |
|
|
|
|
|
}, |
|
|
"title": "Detail", |
|
|
"title": "Detail", |
|
|
"type": "array", |
|
|
"type": "array", |
|
|
}, |
|
|
}, |
|
|
@ -134,3 +140,4 @@ def test_openapi(): |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|