Browse Source

Add extra snapshot

pull/14864/head
Sebastián Ramírez 5 months ago
parent
commit
3fdee73144
  1. 185
      tests/test_tutorial/test_query_params/test_tutorial004.py

185
tests/test_tutorial/test_query_params/test_tutorial004.py

@ -2,6 +2,7 @@ import importlib
import pytest import pytest
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from ...utils import needs_py310 from ...utils import needs_py310
@ -55,104 +56,108 @@ def test_read_user_item(client: TestClient, path, expected_json):
def test_openapi_schema(client: TestClient): def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json") response = client.get("/openapi.json")
assert response.status_code == 200 assert response.status_code == 200
assert response.json() == { assert response.json() == snapshot(
"openapi": "3.1.0", {
"info": {"title": "FastAPI", "version": "0.1.0"}, "openapi": "3.1.0",
"paths": { "info": {"title": "FastAPI", "version": "0.1.0"},
"/users/{user_id}/items/{item_id}": { "paths": {
"get": { "/users/{user_id}/items/{item_id}": {
"summary": "Read User Item", "get": {
"operationId": "read_user_item_users__user_id__items__item_id__get", "summary": "Read User Item",
"parameters": [ "operationId": "read_user_item_users__user_id__items__item_id__get",
{ "parameters": [
"required": True, {
"schema": {"title": "User Id", "type": "integer"}, "required": True,
"name": "user_id", "schema": {"title": "User Id", "type": "integer"},
"in": "path", "name": "user_id",
}, "in": "path",
{
"required": True,
"schema": {"title": "Item Id", "type": "string"},
"name": "item_id",
"in": "path",
},
{
"required": False,
"schema": {
"title": "Q",
"anyOf": [
{
"type": "string",
},
{
"type": "null",
},
],
}, },
"name": "q", {
"in": "query", "required": True,
}, "schema": {"title": "Item Id", "type": "string"},
{ "name": "item_id",
"required": False, "in": "path",
"schema": {
"title": "Short",
"type": "boolean",
"default": False,
}, },
"name": "short", {
"in": "query", "required": False,
}, "schema": {
], "title": "Q",
"responses": { "anyOf": [
"200": { {
"description": "Successful Response", "type": "string",
"content": {"application/json": {"schema": {}}}, },
}, {
"422": { "type": "null",
"content": { },
"application/json": { ],
"schema": { },
"$ref": "#/components/schemas/HTTPValidationError", "name": "q",
"in": "query",
},
{
"required": False,
"schema": {
"title": "Short",
"type": "boolean",
"default": False,
},
"name": "short",
"in": "query",
},
],
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError",
},
}, },
}, },
"description": "Validation Error",
}, },
"description": "Validation Error",
}, },
}, }
} }
} },
}, "components": {
"components": { "schemas": {
"schemas": { "ValidationError": {
"ValidationError": { "title": "ValidationError",
"title": "ValidationError", "required": ["loc", "msg", "type"],
"required": ["loc", "msg", "type"], "type": "object",
"type": "object", "properties": {
"properties": { "loc": {
"loc": { "title": "Location",
"title": "Location", "type": "array",
"type": "array", "items": {
"items": { "anyOf": [{"type": "string"}, {"type": "integer"}]
"anyOf": [{"type": "string"}, {"type": "integer"}] },
}, },
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
"input": {"title": "Input"},
"ctx": {"title": "Context", "type": "object"},
}, },
"msg": {"title": "Message", "type": "string"},
"type": {"title": "Error Type", "type": "string"},
"input": {"title": "Input"},
"ctx": {"title": "Context", "type": "object"},
}, },
}, "HTTPValidationError": {
"HTTPValidationError": { "title": "HTTPValidationError",
"title": "HTTPValidationError", "type": "object",
"type": "object", "properties": {
"properties": { "detail": {
"detail": { "title": "Detail",
"title": "Detail", "type": "array",
"type": "array", "items": {
"items": {"$ref": "#/components/schemas/ValidationError"}, "$ref": "#/components/schemas/ValidationError"
} },
}
},
}, },
}, }
} },
}, }
} )

Loading…
Cancel
Save