|
|
@ -3,6 +3,7 @@ from typing import Annotated |
|
|
import pytest |
|
|
import pytest |
|
|
from fastapi import FastAPI, File, UploadFile |
|
|
from fastapi import FastAPI, File, UploadFile |
|
|
from fastapi.testclient import TestClient |
|
|
from fastapi.testclient import TestClient |
|
|
|
|
|
from inline_snapshot import Is, snapshot |
|
|
|
|
|
|
|
|
from .utils import get_body_model_name |
|
|
from .utils import get_body_model_name |
|
|
|
|
|
|
|
|
@ -35,7 +36,8 @@ def test_optional_list_schema(path: str): |
|
|
openapi = app.openapi() |
|
|
openapi = app.openapi() |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
|
|
|
|
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == { |
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == snapshot( |
|
|
|
|
|
{ |
|
|
"properties": { |
|
|
"properties": { |
|
|
"p": { |
|
|
"p": { |
|
|
"anyOf": [ |
|
|
"anyOf": [ |
|
|
@ -43,6 +45,7 @@ def test_optional_list_schema(path: str): |
|
|
"type": "array", |
|
|
"type": "array", |
|
|
"items": { |
|
|
"items": { |
|
|
"type": "string", |
|
|
"type": "string", |
|
|
|
|
|
"format": "binary", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
@ -51,9 +54,10 @@ def test_optional_list_schema(path: str): |
|
|
"title": "P", |
|
|
"title": "P", |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"title": body_model_name, |
|
|
"title": Is(body_model_name), |
|
|
"type": "object", |
|
|
"type": "object", |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
@pytest.mark.parametrize( |
|
|
@ -113,7 +117,8 @@ def test_optional_list_alias_schema(path: str): |
|
|
openapi = app.openapi() |
|
|
openapi = app.openapi() |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
|
|
|
|
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == { |
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == snapshot( |
|
|
|
|
|
{ |
|
|
"properties": { |
|
|
"properties": { |
|
|
"p_alias": { |
|
|
"p_alias": { |
|
|
"anyOf": [ |
|
|
"anyOf": [ |
|
|
@ -121,6 +126,7 @@ def test_optional_list_alias_schema(path: str): |
|
|
"type": "array", |
|
|
"type": "array", |
|
|
"items": { |
|
|
"items": { |
|
|
"type": "string", |
|
|
"type": "string", |
|
|
|
|
|
"format": "binary", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
@ -129,9 +135,10 @@ def test_optional_list_alias_schema(path: str): |
|
|
"title": "P Alias", |
|
|
"title": "P Alias", |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"title": body_model_name, |
|
|
"title": Is(body_model_name), |
|
|
"type": "object", |
|
|
"type": "object", |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
@pytest.mark.parametrize( |
|
|
@ -205,7 +212,8 @@ def test_optional_validation_alias_schema(path: str): |
|
|
openapi = app.openapi() |
|
|
openapi = app.openapi() |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
|
|
|
|
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == { |
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == snapshot( |
|
|
|
|
|
{ |
|
|
"properties": { |
|
|
"properties": { |
|
|
"p_val_alias": { |
|
|
"p_val_alias": { |
|
|
"anyOf": [ |
|
|
"anyOf": [ |
|
|
@ -213,6 +221,7 @@ def test_optional_validation_alias_schema(path: str): |
|
|
"type": "array", |
|
|
"type": "array", |
|
|
"items": { |
|
|
"items": { |
|
|
"type": "string", |
|
|
"type": "string", |
|
|
|
|
|
"format": "binary", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
@ -221,9 +230,10 @@ def test_optional_validation_alias_schema(path: str): |
|
|
"title": "P Val Alias", |
|
|
"title": "P Val Alias", |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"title": body_model_name, |
|
|
"title": Is(body_model_name), |
|
|
"type": "object", |
|
|
"type": "object", |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
@pytest.mark.parametrize( |
|
|
@ -304,7 +314,8 @@ def test_optional_list_alias_and_validation_alias_schema(path: str): |
|
|
openapi = app.openapi() |
|
|
openapi = app.openapi() |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
body_model_name = get_body_model_name(openapi, path) |
|
|
|
|
|
|
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == { |
|
|
assert app.openapi()["components"]["schemas"][body_model_name] == snapshot( |
|
|
|
|
|
{ |
|
|
"properties": { |
|
|
"properties": { |
|
|
"p_val_alias": { |
|
|
"p_val_alias": { |
|
|
"anyOf": [ |
|
|
"anyOf": [ |
|
|
@ -312,6 +323,7 @@ def test_optional_list_alias_and_validation_alias_schema(path: str): |
|
|
"type": "array", |
|
|
"type": "array", |
|
|
"items": { |
|
|
"items": { |
|
|
"type": "string", |
|
|
"type": "string", |
|
|
|
|
|
"format": "binary", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
"contentMediaType": "application/octet-stream", |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
@ -320,9 +332,10 @@ def test_optional_list_alias_and_validation_alias_schema(path: str): |
|
|
"title": "P Val Alias", |
|
|
"title": "P Val Alias", |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
"title": body_model_name, |
|
|
"title": Is(body_model_name), |
|
|
"type": "object", |
|
|
"type": "object", |
|
|
} |
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize( |
|
|
@pytest.mark.parametrize( |
|
|
|