from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/foo": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/foo": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Foo",
+ "operationId": "foo_foo_post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Items"}
}
},
+ "required": True,
},
- },
- "summary": "Foo",
- "operationId": "foo_foo_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Items"}
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "Items": {
+ "title": "Items",
+ "required": ["items"],
+ "type": "object",
+ "properties": {
+ "items": {
+ "title": "Items",
+ "type": "object",
+ "additionalProperties": {"type": "integer"},
}
},
- "required": True,
},
- }
- }
- },
- "components": {
- "schemas": {
- "Items": {
- "title": "Items",
- "required": ["items"],
- "type": "object",
- "properties": {
- "items": {
- "title": "Items",
- "type": "object",
- "additionalProperties": {"type": "integer"},
- }
- },
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post",
- "operationId": "post__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "anyOf": [
- {"$ref": "#/components/schemas/Foo"},
- {"type": "null"},
- ],
- "title": "Foo",
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post",
+ "operationId": "post__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "anyOf": [
+ {"$ref": "#/components/schemas/Foo"},
+ {"type": "null"},
+ ],
+ "title": "Foo",
}
}
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Foo": {
- "properties": {},
- "additionalProperties": False,
- "type": "object",
- "title": "Foo",
- },
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ },
+ "components": {
+ "schemas": {
+ "Foo": {
+ "properties": {},
+ "additionalProperties": False,
+ "type": "object",
+ "title": "Foo",
+ },
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
router = APIRouter()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Item",
- "operationId": "read_item_items__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Item",
+ "operationId": "read_item_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a/{id}": {
- "get": {
- "responses": {
- "422": {
- "description": "Error",
- "content": {
- "application/vnd.api+json": {
- "schema": {
- "$ref": "#/components/schemas/JsonApiError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a/{id}": {
+ "get": {
+ "responses": {
+ "422": {
+ "description": "Error",
+ "content": {
+ "application/vnd.api+json": {
+ "schema": {
+ "$ref": "#/components/schemas/JsonApiError"
+ }
}
- }
+ },
+ },
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/vnd.api+json": {"schema": {}}},
},
},
- "200": {
- "description": "Successful Response",
- "content": {"application/vnd.api+json": {"schema": {}}},
- },
- },
- "summary": "A",
- "operationId": "a_a__id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Id"},
- "name": "id",
- "in": "path",
- }
- ],
+ "summary": "A",
+ "operationId": "a_a__id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Id"},
+ "name": "id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Error": {
- "title": "Error",
- "required": ["status", "title"],
- "type": "object",
- "properties": {
- "status": {"title": "Status", "type": "string"},
- "title": {"title": "Title", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Error": {
+ "title": "Error",
+ "required": ["status", "title"],
+ "type": "object",
+ "properties": {
+ "status": {"title": "Status", "type": "string"},
+ "title": {"title": "Title", "type": "string"},
+ },
},
- },
- "JsonApiError": {
- "title": "JsonApiError",
- "required": ["errors"],
- "type": "object",
- "properties": {
- "errors": {
- "title": "Errors",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Error"},
- }
+ "JsonApiError": {
+ "title": "JsonApiError",
+ "required": ["errors"],
+ "type": "object",
+ "properties": {
+ "errors": {
+ "title": "Errors",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Error"},
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a/{id}": {
- "get": {
- "responses": {
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a/{id}": {
+ "get": {
+ "responses": {
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
+ },
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- },
- "summary": "A",
- "operationId": "a_a__id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Id"},
- "name": "id",
- "in": "path",
- }
- ],
+ "summary": "A",
+ "operationId": "a_a__id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Id"},
+ "name": "id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a": {
- "get": {
- "responses": {
- "500": {
- "description": "Error",
- "content": {
- "application/vnd.api+json": {
- "schema": {
- "$ref": "#/components/schemas/JsonApiError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a": {
+ "get": {
+ "responses": {
+ "500": {
+ "description": "Error",
+ "content": {
+ "application/vnd.api+json": {
+ "schema": {
+ "$ref": "#/components/schemas/JsonApiError"
+ }
}
- }
+ },
+ },
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/vnd.api+json": {"schema": {}}},
},
},
- "200": {
- "description": "Successful Response",
- "content": {"application/vnd.api+json": {"schema": {}}},
+ "summary": "A",
+ "operationId": "a_a_get",
+ }
+ },
+ "/b": {
+ "get": {
+ "responses": {
+ "500": {
+ "description": "Error",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Error"}
+ }
+ },
+ },
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- },
- "summary": "A",
- "operationId": "a_a_get",
- }
+ "summary": "B",
+ "operationId": "b_b_get",
+ }
+ },
},
- "/b": {
- "get": {
- "responses": {
- "500": {
- "description": "Error",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Error"}
- }
- },
+ "components": {
+ "schemas": {
+ "Error": {
+ "title": "Error",
+ "required": ["status", "title"],
+ "type": "object",
+ "properties": {
+ "status": {"title": "Status", "type": "string"},
+ "title": {"title": "Title", "type": "string"},
},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ },
+ "JsonApiError": {
+ "title": "JsonApiError",
+ "required": ["errors"],
+ "type": "object",
+ "properties": {
+ "errors": {
+ "title": "Errors",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Error"},
+ }
},
},
- "summary": "B",
- "operationId": "b_b_get",
}
},
- },
- "components": {
- "schemas": {
- "Error": {
- "title": "Error",
- "required": ["status", "title"],
- "type": "object",
- "properties": {
- "status": {"title": "Status", "type": "string"},
- "title": {"title": "Title", "type": "string"},
- },
- },
- "JsonApiError": {
- "title": "JsonApiError",
- "required": ["errors"],
- "type": "object",
- "properties": {
- "errors": {
- "title": "Errors",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Error"},
- }
- },
- },
- }
- },
- }
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a": {
- "get": {
- "responses": {
- "501": {"description": "Error 1"},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a": {
+ "get": {
+ "responses": {
+ "501": {"description": "Error 1"},
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- },
- "summary": "A",
- "operationId": "a_a_get",
- }
- },
- "/b": {
- "get": {
- "responses": {
- "502": {"description": "Error 2"},
- "4XX": {"description": "Error with range, upper"},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "summary": "A",
+ "operationId": "a_a_get",
+ }
+ },
+ "/b": {
+ "get": {
+ "responses": {
+ "502": {"description": "Error 2"},
+ "4XX": {"description": "Error with range, upper"},
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- },
- "summary": "B",
- "operationId": "b_b_get",
- }
- },
- "/c": {
- "get": {
- "responses": {
- "400": {"description": "Error with str"},
- "5XX": {"description": "Error with range, lower"},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "summary": "B",
+ "operationId": "b_b_get",
+ }
+ },
+ "/c": {
+ "get": {
+ "responses": {
+ "400": {"description": "Error with str"},
+ "5XX": {"description": "Error with range, lower"},
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "default": {"description": "A default response"},
},
- "default": {"description": "A default response"},
- },
- "summary": "C",
- "operationId": "c_c_get",
- }
- },
- "/d": {
- "get": {
- "responses": {
- "400": {"description": "Error with str"},
- "5XX": {
- "description": "Server Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseModel"
+ "summary": "C",
+ "operationId": "c_c_get",
+ }
+ },
+ "/d": {
+ "get": {
+ "responses": {
+ "400": {"description": "Error with str"},
+ "5XX": {
+ "description": "Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseModel"
+ }
}
- }
+ },
},
- },
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "default": {
- "description": "Default Response",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseModel"
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "default": {
+ "description": "Default Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseModel"
+ }
}
- }
+ },
},
},
- },
- "summary": "D",
- "operationId": "d_d_get",
- }
+ "summary": "D",
+ "operationId": "d_d_get",
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "ResponseModel": {
- "title": "ResponseModel",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
+ "components": {
+ "schemas": {
+ "ResponseModel": {
+ "title": "ResponseModel",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/route1": {
- "get": {
- "summary": "Route1",
- "operationId": "route1_route1_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {
- "anyOf": [
- {"$ref": "#/components/schemas/ModelA"},
- {"$ref": "#/components/schemas/ModelB"},
- ],
- "title": "Response 500 Route1 Route1 Get",
- },
- "examples": {"Case A": {"value": "a"}},
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/route1": {
+ "get": {
+ "summary": "Route1",
+ "operationId": "route1_route1_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "anyOf": [
+ {"$ref": "#/components/schemas/ModelA"},
+ {"$ref": "#/components/schemas/ModelB"},
+ ],
+ "title": "Response 500 Route1 Route1 Get",
+ },
+ "examples": {"Case A": {"value": "a"}},
+ }
+ },
},
},
- },
- }
- },
- "/route2": {
- "get": {
- "summary": "Route2",
- "operationId": "route2_route2_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {
- "anyOf": [
- {"$ref": "#/components/schemas/ModelA"},
- {"$ref": "#/components/schemas/ModelB"},
- ],
- "title": "Response 500 Route2 Route2 Get",
- },
- "examples": {"Case A": {"value": "a"}},
- }
+ }
+ },
+ "/route2": {
+ "get": {
+ "summary": "Route2",
+ "operationId": "route2_route2_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "anyOf": [
+ {"$ref": "#/components/schemas/ModelA"},
+ {"$ref": "#/components/schemas/ModelB"},
+ ],
+ "title": "Response 500 Route2 Route2 Get",
+ },
+ "examples": {"Case A": {"value": "a"}},
+ }
+ },
},
},
+ }
+ },
+ },
+ "components": {
+ "schemas": {
+ "ModelA": {
+ "properties": {"a": {"type": "string", "title": "A"}},
+ "type": "object",
+ "required": ["a"],
+ "title": "ModelA",
+ },
+ "ModelB": {
+ "properties": {"b": {"type": "string", "title": "B"}},
+ "type": "object",
+ "required": ["b"],
+ "title": "ModelB",
},
}
},
- },
- "components": {
- "schemas": {
- "ModelA": {
- "properties": {"a": {"type": "string", "title": "A"}},
- "type": "object",
- "required": ["a"],
- "title": "ModelA",
- },
- "ModelB": {
- "properties": {"b": {"type": "string", "title": "B"}},
- "type": "object",
- "required": ["b"],
- "title": "ModelB",
- },
- }
- },
- }
+ }
+ )
import pytest
from fastapi import APIRouter, FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/default": {
- "get": {
- "summary": "Default",
- "operationId": "default_default_get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Foo",
- "type": "string",
- "default": "foo",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/default": {
+ "get": {
+ "summary": "Default",
+ "operationId": "default_default_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Foo",
+ "type": "string",
+ "default": "foo",
+ },
+ "name": "foo",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "foo",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/required": {
- "get": {
- "summary": "Required",
- "operationId": "required_required_get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Foo",
- "minLength": 1,
- "type": "string",
+ }
+ },
+ "/required": {
+ "get": {
+ "summary": "Required",
+ "operationId": "required_required_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Foo",
+ "minLength": 1,
+ "type": "string",
+ },
+ "name": "foo",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "foo",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/multiple": {
- "get": {
- "summary": "Multiple",
- "operationId": "multiple_multiple_get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Foo",
- "minLength": 1,
- "type": "string",
+ }
+ },
+ "/multiple": {
+ "get": {
+ "summary": "Multiple",
+ "operationId": "multiple_multiple_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Foo",
+ "minLength": 1,
+ "type": "string",
+ },
+ "name": "foo",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "foo",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/unrelated": {
- "get": {
- "summary": "Unrelated",
- "operationId": "unrelated_unrelated_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Foo", "type": "string"},
- "name": "foo",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/unrelated": {
+ "get": {
+ "summary": "Unrelated",
+ "operationId": "unrelated_unrelated_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Foo", "type": "string"},
+ "name": "foo",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from .main import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "externalDocs": {
- "description": "External API documentation.",
- "url": "https://docs.example.com/api-general",
- },
- "paths": {
- "/api_route": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Non Operation",
- "operationId": "non_operation_api_route_get",
- }
- },
- "/non_decorated_route": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Non Decorated Route",
- "operationId": "non_decorated_route_non_decorated_route_get",
- }
- },
- "/text": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Get Text",
- "operationId": "get_text_text_get",
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "externalDocs": {
+ "description": "External API documentation.",
+ "url": "https://docs.example.com/api-general",
},
- "/path/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "paths": {
+ "/api_route": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Non Operation",
+ "operationId": "non_operation_api_route_get",
+ }
+ },
+ "/non_decorated_route": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Non Decorated Route",
+ "operationId": "non_decorated_route_non_decorated_route_get",
+ }
+ },
+ "/text": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Get Text",
+ "operationId": "get_text_text_get",
+ }
+ },
+ "/path/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Id",
- "operationId": "get_id_path__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/str/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Id",
+ "operationId": "get_id_path__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/str/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Str Id",
- "operationId": "get_str_id_path_str__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Str Id",
+ "operationId": "get_str_id_path_str__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Int Id",
- "operationId": "get_int_id_path_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/float/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Int Id",
+ "operationId": "get_int_id_path_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/float/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Float Id",
- "operationId": "get_float_id_path_float__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "number"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/bool/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Float Id",
+ "operationId": "get_float_id_path_float__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "number"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/bool/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Bool Id",
- "operationId": "get_bool_id_path_bool__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "boolean"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Bool Id",
+ "operationId": "get_bool_id_path_bool__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "boolean"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Id",
- "operationId": "get_path_param_id_path_param__item_id__get",
- "parameters": [
- {
- "name": "item_id",
- "in": "path",
- "required": True,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Item Id",
- },
- }
- ],
- }
- },
- "/path/param-minlength/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Id",
+ "operationId": "get_path_param_id_path_param__item_id__get",
+ "parameters": [
+ {
+ "name": "item_id",
+ "in": "path",
+ "required": True,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Item Id",
+ },
+ }
+ ],
+ }
+ },
+ "/path/param-minlength/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Min Length",
- "operationId": "get_path_param_min_length_path_param_minlength__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "minLength": 3,
- "type": "string",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-maxlength/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Min Length",
+ "operationId": "get_path_param_min_length_path_param_minlength__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "minLength": 3,
+ "type": "string",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-maxlength/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Max Length",
- "operationId": "get_path_param_max_length_path_param_maxlength__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maxLength": 3,
- "type": "string",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-min_maxlength/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Max Length",
+ "operationId": "get_path_param_max_length_path_param_maxlength__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maxLength": 3,
+ "type": "string",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-min_maxlength/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Min Max Length",
- "operationId": "get_path_param_min_max_length_path_param_min_maxlength__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maxLength": 3,
- "minLength": 2,
- "type": "string",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-gt/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Min Max Length",
+ "operationId": "get_path_param_min_max_length_path_param_min_maxlength__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maxLength": 3,
+ "minLength": 2,
+ "type": "string",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-gt/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Gt",
- "operationId": "get_path_param_gt_path_param_gt__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMinimum": 3.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-gt0/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Gt",
+ "operationId": "get_path_param_gt_path_param_gt__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMinimum": 3.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-gt0/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Gt0",
- "operationId": "get_path_param_gt0_path_param_gt0__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMinimum": 0.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-ge/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Gt0",
+ "operationId": "get_path_param_gt0_path_param_gt0__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMinimum": 0.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-ge/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Ge",
- "operationId": "get_path_param_ge_path_param_ge__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "minimum": 3.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-lt/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Ge",
+ "operationId": "get_path_param_ge_path_param_ge__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "minimum": 3.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-lt/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Lt",
- "operationId": "get_path_param_lt_path_param_lt__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMaximum": 3.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-lt0/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Lt",
+ "operationId": "get_path_param_lt_path_param_lt__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMaximum": 3.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-lt0/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Lt0",
- "operationId": "get_path_param_lt0_path_param_lt0__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMaximum": 0.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-le/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Lt0",
+ "operationId": "get_path_param_lt0_path_param_lt0__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMaximum": 0.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-le/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Le",
- "operationId": "get_path_param_le_path_param_le__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maximum": 3.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-lt-gt/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Le",
+ "operationId": "get_path_param_le_path_param_le__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maximum": 3.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-lt-gt/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Lt Gt",
- "operationId": "get_path_param_lt_gt_path_param_lt_gt__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMaximum": 3.0,
- "exclusiveMinimum": 1.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-le-ge/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Lt Gt",
+ "operationId": "get_path_param_lt_gt_path_param_lt_gt__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMaximum": 3.0,
+ "exclusiveMinimum": 1.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-le-ge/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Le Ge",
- "operationId": "get_path_param_le_ge_path_param_le_ge__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maximum": 3.0,
- "minimum": 1.0,
- "type": "number",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-lt-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Le Ge",
+ "operationId": "get_path_param_le_ge_path_param_le_ge__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maximum": 3.0,
+ "minimum": 1.0,
+ "type": "number",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-lt-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Lt Int",
- "operationId": "get_path_param_lt_int_path_param_lt_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMaximum": 3.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-gt-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Lt Int",
+ "operationId": "get_path_param_lt_int_path_param_lt_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMaximum": 3.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-gt-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Gt Int",
- "operationId": "get_path_param_gt_int_path_param_gt_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMinimum": 3.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-le-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Gt Int",
+ "operationId": "get_path_param_gt_int_path_param_gt_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMinimum": 3.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-le-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Le Int",
- "operationId": "get_path_param_le_int_path_param_le_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maximum": 3.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-ge-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Le Int",
+ "operationId": "get_path_param_le_int_path_param_le_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maximum": 3.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-ge-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Ge Int",
- "operationId": "get_path_param_ge_int_path_param_ge_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "minimum": 3.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-lt-gt-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Ge Int",
+ "operationId": "get_path_param_ge_int_path_param_ge_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "minimum": 3.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-lt-gt-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Lt Gt Int",
- "operationId": "get_path_param_lt_gt_int_path_param_lt_gt_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "exclusiveMaximum": 3.0,
- "exclusiveMinimum": 1.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/path/param-le-ge-int/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Lt Gt Int",
+ "operationId": "get_path_param_lt_gt_int_path_param_lt_gt_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "exclusiveMaximum": 3.0,
+ "exclusiveMinimum": 1.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/path/param-le-ge-int/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Path Param Le Ge Int",
- "operationId": "get_path_param_le_ge_int_path_param_le_ge_int__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "maximum": 3.0,
- "minimum": 1.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/query": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Path Param Le Ge Int",
+ "operationId": "get_path_param_le_ge_int_path_param_le_ge_int__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "maximum": 3.0,
+ "minimum": 1.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/query": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query",
- "operationId": "get_query_query_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Query"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/optional": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query",
+ "operationId": "get_query_query_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Query"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/optional": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Optional",
- "operationId": "get_query_optional_query_optional_get",
- "parameters": [
- {
- "required": False,
- "schema": {"title": "Query"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/int": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Optional",
+ "operationId": "get_query_optional_query_optional_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {"title": "Query"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/int": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Type",
- "operationId": "get_query_type_query_int_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Query", "type": "integer"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/int/optional": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Type",
+ "operationId": "get_query_type_query_int_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Query", "type": "integer"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/int/optional": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Type Optional",
- "operationId": "get_query_type_optional_query_int_optional_get",
- "parameters": [
- {
- "name": "query",
- "in": "query",
- "required": False,
- "schema": {
- "anyOf": [{"type": "integer"}, {"type": "null"}],
- "title": "Query",
- },
- }
- ],
- }
- },
- "/query/int/default": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Type Optional",
+ "operationId": "get_query_type_optional_query_int_optional_get",
+ "parameters": [
+ {
+ "name": "query",
+ "in": "query",
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "integer"}, {"type": "null"}],
+ "title": "Query",
+ },
+ }
+ ],
+ }
+ },
+ "/query/int/default": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Type Int Default",
- "operationId": "get_query_type_int_default_query_int_default_get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Query",
- "type": "integer",
- "default": 10,
- },
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/param": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Type Int Default",
+ "operationId": "get_query_type_int_default_query_int_default_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Query",
+ "type": "integer",
+ "default": 10,
+ },
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/param": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Param",
- "operationId": "get_query_param_query_param_get",
- "parameters": [
- {
- "required": False,
- "schema": {"title": "Query"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/param-required": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Param",
+ "operationId": "get_query_param_query_param_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {"title": "Query"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/param-required": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Param Required",
- "operationId": "get_query_param_required_query_param_required_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Query"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/query/param-required/int": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Query Param Required",
+ "operationId": "get_query_param_required_query_param_required_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Query"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/query/param-required/int": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Query Param Required Type",
- "operationId": "get_query_param_required_type_query_param_required_int_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Query", "type": "integer"},
- "name": "query",
- "in": "query",
- }
- ],
- }
- },
- "/enum-status-code": {
- "get": {
- "responses": {
- "201": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- },
- "summary": "Get Enum Status Code",
- "operationId": "get_enum_status_code_enum_status_code_get",
- }
- },
- "/query/frozenset": {
- "get": {
- "summary": "Get Query Type Frozenset",
- "operationId": "get_query_type_frozenset_query_frozenset_get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Query",
- "uniqueItems": True,
- "type": "array",
- "items": {"type": "integer"},
- },
- "name": "query",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "summary": "Get Query Param Required Type",
+ "operationId": "get_query_param_required_type_query_param_required_int_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Query", "type": "integer"},
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ }
+ },
+ "/enum-status-code": {
+ "get": {
+ "responses": {
+ "201": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Get Enum Status Code",
+ "operationId": "get_enum_status_code_enum_status_code_get",
+ }
+ },
+ "/query/frozenset": {
+ "get": {
+ "summary": "Get Query Type Frozenset",
+ "operationId": "get_query_type_frozenset_query_frozenset_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Query",
+ "uniqueItems": True,
+ "type": "array",
+ "items": {"type": "integer"},
+ },
+ "name": "query",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query/list": {
- "get": {
- "summary": "Get Query List",
- "operationId": "get_query_list_query_list_get",
- "parameters": [
- {
- "name": "device_ids",
- "in": "query",
- "required": True,
- "schema": {
- "type": "array",
- "items": {"type": "integer"},
- "title": "Device Ids",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {"type": "integer"},
- "title": "Response Get Query List Query List Get",
+ }
+ },
+ "/query/list": {
+ "get": {
+ "summary": "Get Query List",
+ "operationId": "get_query_list_query_list_get",
+ "parameters": [
+ {
+ "name": "device_ids",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "type": "array",
+ "items": {"type": "integer"},
+ "title": "Device Ids",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {"type": "integer"},
+ "title": "Response Get Query List Query List Get",
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query/list-default": {
- "get": {
- "summary": "Get Query List Default",
- "operationId": "get_query_list_default_query_list_default_get",
- "parameters": [
- {
- "name": "device_ids",
- "in": "query",
- "required": False,
- "schema": {
- "type": "array",
- "items": {"type": "integer"},
- "default": [],
- "title": "Device Ids",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {"type": "integer"},
- "title": "Response Get Query List Default Query List Default Get",
+ }
+ },
+ "/query/list-default": {
+ "get": {
+ "summary": "Get Query List Default",
+ "operationId": "get_query_list_default_query_list_default_get",
+ "parameters": [
+ {
+ "name": "device_ids",
+ "in": "query",
+ "required": False,
+ "schema": {
+ "type": "array",
+ "items": {"type": "integer"},
+ "default": [],
+ "title": "Device Ids",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {"type": "integer"},
+ "title": "Response Get Query List Default Query List Default Get",
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(name="client")
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "Read Root",
- "operationId": "read_root__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Rectangle"}
- }
- },
- }
- },
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "Read Root",
+ "operationId": "read_root__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Rectangle"
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/responses": {
+ "get": {
+ "summary": "Read Responses",
+ "operationId": "read_responses_responses_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Rectangle"
+ }
+ }
+ },
+ }
+ },
+ }
+ },
},
- "/responses": {
- "get": {
- "summary": "Read Responses",
- "operationId": "read_responses_responses_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Rectangle"}
- }
+ "components": {
+ "schemas": {
+ "Rectangle": {
+ "properties": {
+ "width": {"type": "integer", "title": "Width"},
+ "length": {"type": "integer", "title": "Length"},
+ "area": {
+ "type": "integer",
+ "title": "Area",
+ "readOnly": True,
},
- }
- },
+ },
+ "type": "object",
+ "required": ["width", "length", "area"],
+ "title": "Rectangle",
+ }
}
},
- },
- "components": {
- "schemas": {
- "Rectangle": {
- "properties": {
- "width": {"type": "integer", "title": "Width"},
- "length": {"type": "integer", "title": "Length"},
- "area": {"type": "integer", "title": "Area", "readOnly": True},
- },
- "type": "object",
- "required": ["width", "length", "area"],
- "title": "Rectangle",
- }
- }
- },
- }
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.routing import APIRoute
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from starlette.routing import Route
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Get A",
- "operationId": "get_a_a__get",
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Get A",
+ "operationId": "get_a_a__get",
+ }
+ },
+ "/a/b/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Get B",
+ "operationId": "get_b_a_b__get",
+ }
+ },
+ "/a/b/c/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Get C",
+ "operationId": "get_c_a_b_c__get",
+ }
+ },
},
- "/a/b/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Get B",
- "operationId": "get_b_a_b__get",
- }
- },
- "/a/b/c/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Get C",
- "operationId": "get_c_a_b_c__get",
- }
- },
- },
- }
+ }
+ )
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/with-duplicates": {
- "post": {
- "summary": "With Duplicates",
- "operationId": "with_duplicates_with_duplicates_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/with-duplicates": {
+ "post": {
+ "summary": "With Duplicates",
+ "operationId": "with_duplicates_with_duplicates_post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- }
- },
- "/no-duplicates": {
- "post": {
- "summary": "No Duplicates",
- "operationId": "no_duplicates_no_duplicates_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_no_duplicates_no_duplicates_post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/no-duplicates": {
+ "post": {
+ "summary": "No Duplicates",
+ "operationId": "no_duplicates_no_duplicates_post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_no_duplicates_no_duplicates_post"
}
}
},
+ "required": True,
},
- },
- }
- },
- "/with-duplicates-sub": {
- "post": {
- "summary": "No Duplicates Sub",
- "operationId": "no_duplicates_sub_with_duplicates_sub_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/with-duplicates-sub": {
+ "post": {
+ "summary": "No Duplicates Sub",
+ "operationId": "no_duplicates_sub_with_duplicates_sub_post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_no_duplicates_no_duplicates_post": {
- "title": "Body_no_duplicates_no_duplicates_post",
- "required": ["item", "item2"],
- "type": "object",
- "properties": {
- "item": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
+ "components": {
+ "schemas": {
+ "Body_no_duplicates_no_duplicates_post": {
+ "title": "Body_no_duplicates_no_duplicates_post",
+ "required": ["item", "item2"],
+ "type": "object",
+ "properties": {
+ "item": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["data"],
- "type": "object",
- "properties": {"data": {"title": "Data", "type": "string"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "Item": {
+ "title": "Item",
+ "required": ["data"],
+ "type": "object",
+ "properties": {"data": {"title": "Data", "type": "string"}},
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Request
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI(openapi_prefix="/api/v1")
def test_openapi():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/app": {
- "get": {
- "summary": "Read Main",
- "operationId": "read_main_app_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/app": {
+ "get": {
+ "summary": "Read Main",
+ "operationId": "read_main_app_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- "servers": [{"url": "/api/v1"}],
- }
+ },
+ "servers": [{"url": "/api/v1"}],
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "F",
- "operationId": "f__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model3"}
- }
- },
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "F",
+ "operationId": "f__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Model3"
+ }
+ }
+ },
+ }
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Model": {"title": "Model", "type": "object", "properties": {}},
- "Model2": {
- "title": "Model2",
- "required": ["a"],
- "type": "object",
- "properties": {"a": {"$ref": "#/components/schemas/Model"}},
- },
- "Model3": {
- "title": "Model3",
- "required": ["c", "d"],
- "type": "object",
- "properties": {
- "c": {"$ref": "#/components/schemas/Model"},
- "d": {"$ref": "#/components/schemas/Model2"},
+ },
+ "components": {
+ "schemas": {
+ "Model": {"title": "Model", "type": "object", "properties": {}},
+ "Model2": {
+ "title": "Model2",
+ "required": ["a"],
+ "type": "object",
+ "properties": {"a": {"$ref": "#/components/schemas/Model"}},
+ },
+ "Model3": {
+ "title": "Model3",
+ "required": ["c", "d"],
+ "type": "object",
+ "properties": {
+ "c": {"$ref": "#/components/schemas/Model"},
+ "d": {"$ref": "#/components/schemas/Model2"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from typing import Optional
-from fastapi import Depends, FastAPI, Query, status
+from fastapi import Depends, FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
client = TestClient(app)
-expected_schema = {
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "title": "Detail",
- "type": "array",
- }
- },
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
- "title": "Location",
- "type": "array",
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
- },
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- "type": "object",
- },
- }
- },
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "openapi": "3.1.0",
- "paths": {
- "/foo": {
- "get": {
- "operationId": "foo_handler_foo_get",
- "parameters": [
- {
- "in": "query",
- "name": "client_id",
- "required": True,
- "schema": {"title": "Client Id", "type": "string"},
- },
- ],
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- "description": "Validation Error",
- },
- },
- "summary": "Foo Handler",
- }
- }
- },
-}
-
-
-def test_schema():
- response = client.get("/openapi.json")
- assert response.status_code == status.HTTP_200_OK
- actual_schema = response.json()
- assert actual_schema == expected_schema
-
def test_get_invalid():
response = client.get("/foo")
response = client.get("/foo", params={"client_id": "bar"})
assert response.status_code == 200
assert response.json() == {"client_id": "bar_key", "client_tag": "bar_tag"}
+
+
+def test_openapi_schema():
+ response = client.get("/openapi.json")
+ assert response.status_code == 200, response.text
+ assert response.json() == snapshot(
+ {
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "title": "Detail",
+ "type": "array",
+ }
+ },
+ "title": "HTTPValidationError",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
+ "type": "object",
+ },
+ }
+ },
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "openapi": "3.1.0",
+ "paths": {
+ "/foo": {
+ "get": {
+ "operationId": "foo_handler_foo_get",
+ "parameters": [
+ {
+ "in": "query",
+ "name": "client_id",
+ "required": True,
+ "schema": {"title": "Client Id", "type": "string"},
+ },
+ ],
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ "description": "Validation Error",
+ },
+ },
+ "summary": "Foo Handler",
+ }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Get Items",
+ "operationId": "get_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Get Items",
- "operationId": "get_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- },
- "delete": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "delete": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Delete Item",
+ "operationId": "delete_item_items__item_id__delete",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
- },
- },
- "summary": "Delete Item",
- "operationId": "delete_item_items__item_id__delete",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
},
- "required": True,
},
- },
- "options": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "options": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Options Item",
+ "operationId": "options_item_items__item_id__options",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Options Item",
- "operationId": "options_item_items__item_id__options",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- },
- "head": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "head": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Head Item",
+ "operationId": "head_item_items__item_id__head",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Head Item",
- "operationId": "head_item_items__item_id__head",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- },
- "patch": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "patch": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Patch Item",
+ "operationId": "patch_item_items__item_id__patch",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
- },
- },
- "summary": "Patch Item",
- "operationId": "patch_item_items__item_id__patch",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
},
- "required": True,
},
- },
- "trace": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "trace": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Trace Item",
+ "operationId": "trace_item_items__item_id__trace",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Trace Item",
- "operationId": "trace_item_items__item_id__trace",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
},
- },
- "/items-not-decorated/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "/items-not-decorated/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Get Not Decorated",
- "operationId": "get_not_decorated_items_not_decorated__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
+ "summary": "Get Not Decorated",
+ "operationId": "get_not_decorated_items_not_decorated__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {
- "title": "Price",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {
+ "title": "Price",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/form/": {
- "post": {
- "summary": "Post Form",
- "operationId": "post_form_form__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_post_form_form__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/form/": {
+ "post": {
+ "summary": "Post Form",
+ "operationId": "post_form_form__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_post_form_form__post"
}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Body_post_form_form__post": {
- "properties": {"username": {"type": "string", "title": "Username"}},
- "type": "object",
- "required": ["username"],
- "title": "Body_post_form_form__post",
- },
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ },
+ "components": {
+ "schemas": {
+ "Body_post_form_form__post": {
+ "properties": {
+ "username": {"type": "string", "title": "Username"}
+ },
+ "type": "object",
+ "required": ["username"],
+ "title": "Body_post_form_form__post",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.routing import APIRoute
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app.include_router(router)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "foo_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "foo_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "foo_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Foo Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "foo_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Foo Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_foo_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_foo_post_root": {
- "title": "Body_foo_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_router": {
- "title": "Body_foo_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
+ }
},
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_foo_post_root": {
+ "title": "Body_foo_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_router": {
+ "title": "Body_foo_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_router_overrides_generate_unique_id():
app.include_router(router)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "foo_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "foo_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "bar_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_bar_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Bar Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "bar_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Bar Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_bar_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_bar_post_router": {
- "title": "Body_bar_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_root": {
- "title": "Body_foo_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
+ }
},
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_bar_post_router": {
+ "title": "Body_bar_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_root": {
+ "title": "Body_foo_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_router_include_overrides_generate_unique_id():
app.include_router(router, generate_unique_id_function=custom_generate_unique_id3)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "foo_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "foo_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "bar_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_bar_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Bar Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "bar_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Bar Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_bar_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_bar_post_router": {
- "title": "Body_bar_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_root": {
- "title": "Body_foo_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
+ }
},
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_bar_post_router": {
+ "title": "Body_bar_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_root": {
+ "title": "Body_foo_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_subrouter_top_level_include_overrides_generate_unique_id():
app.include_router(router, generate_unique_id_function=custom_generate_unique_id3)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "foo_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "foo_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "baz_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_baz_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Baz Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "baz_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Baz Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_baz_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Baz Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/subrouter": {
- "post": {
- "summary": "Post Subrouter",
- "operationId": "bar_post_subrouter",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_bar_post_subrouter"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Bar Post Subrouter",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Baz Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Bar Post Subrouter",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/subrouter": {
+ "post": {
+ "summary": "Post Subrouter",
+ "operationId": "bar_post_subrouter",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_bar_post_subrouter"
}
}
},
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Bar Post Subrouter",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
+ }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Bar Post Subrouter",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_bar_post_subrouter": {
- "title": "Body_bar_post_subrouter",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_baz_post_router": {
- "title": "Body_baz_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_root": {
- "title": "Body_foo_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
+ }
},
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_bar_post_subrouter": {
+ "title": "Body_bar_post_subrouter",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_baz_post_router": {
+ "title": "Body_baz_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_root": {
+ "title": "Body_foo_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_router_path_operation_overrides_generate_unique_id():
app.include_router(router)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "foo_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "foo_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "baz_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_baz_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Baz Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "baz_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Baz Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_baz_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Baz Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Baz Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_baz_post_router": {
- "title": "Body_baz_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_root": {
- "title": "Body_foo_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
+ }
},
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_baz_post_router": {
+ "title": "Body_baz_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_root": {
+ "title": "Body_foo_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_app_path_operation_overrides_generate_unique_id():
app.include_router(router)
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "baz_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_baz_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "baz_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Baz Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_baz_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Baz Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Baz Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Baz Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
},
- },
- },
- }
- },
- "/router": {
- "post": {
- "summary": "Post Router",
- "operationId": "bar_post_router",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_bar_post_router"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Bar Post Router",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- "404": {
- "description": "Not Found",
+ }
+ },
+ "/router": {
+ "post": {
+ "summary": "Post Router",
+ "operationId": "bar_post_router",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response 404 Bar Post Router",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "$ref": "#/components/schemas/Body_bar_post_router"
}
}
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
+ },
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Bar Post Router",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_bar_post_router": {
- "title": "Body_bar_post_router",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_baz_post_root": {
- "title": "Body_baz_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
+ }
},
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_bar_post_router": {
+ "title": "Body_bar_post_router",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_baz_post_root": {
+ "title": "Body_baz_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_callback_override_generate_unique_id():
client = TestClient(app)
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "post": {
- "summary": "Post Root",
- "operationId": "baz_post_root",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_baz_post_root"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "post": {
+ "summary": "Post Root",
+ "operationId": "baz_post_root",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Baz Post Root",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_baz_post_root"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Baz Post Root",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Baz Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Baz Post Root",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- "callbacks": {
- "post_callback": {
- "/post-callback": {
- "post": {
- "summary": "Post Callback",
- "operationId": "baz_post_callback",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_baz_post_callback"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ "callbacks": {
+ "post_callback": {
+ "/post-callback": {
+ "post": {
+ "summary": "Post Callback",
+ "operationId": "baz_post_callback",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Baz Post Callback",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Item"
- },
+ "$ref": "#/components/schemas/Body_baz_post_callback"
}
}
},
+ "required": True,
},
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Baz Post Callback",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Baz Post Callback",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Baz Post Callback",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- }
- },
- }
- },
- "/tocallback": {
- "post": {
- "summary": "Post With Callback",
- "operationId": "foo_post_with_callback",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_foo_post_with_callback"
+ }
}
}
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ }
+ },
+ "/tocallback": {
+ "post": {
+ "summary": "Post With Callback",
+ "operationId": "foo_post_with_callback",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "title": "Response Foo Post With Callback",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "$ref": "#/components/schemas/Body_foo_post_with_callback"
}
}
},
- },
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 404 Foo Post With Callback",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Message"
- },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Foo Post With Callback",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 404 Foo Post With Callback",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Message"
+ },
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_baz_post_callback": {
- "title": "Body_baz_post_callback",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_baz_post_root": {
- "title": "Body_baz_post_root",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
- },
- "Body_foo_post_with_callback": {
- "title": "Body_foo_post_with_callback",
- "required": ["item1", "item2"],
- "type": "object",
- "properties": {
- "item1": {"$ref": "#/components/schemas/Item"},
- "item2": {"$ref": "#/components/schemas/Item"},
- },
+ }
},
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "Message": {
- "title": "Message",
- "required": ["title", "description"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "description": {"title": "Description", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_baz_post_callback": {
+ "title": "Body_baz_post_callback",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_baz_post_root": {
+ "title": "Body_baz_post_root",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "Body_foo_post_with_callback": {
+ "title": "Body_foo_post_with_callback",
+ "required": ["item1", "item2"],
+ "type": "object",
+ "properties": {
+ "item1": {"$ref": "#/components/schemas/Item"},
+ "item2": {"$ref": "#/components/schemas/Item"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["title", "description"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_warn_duplicate_operation_id():
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "openapi": "3.1.0",
- "paths": {
- "/a": {
- "get": {
- "operationId": "a_a_get",
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- }
- },
- "summary": "A",
- }
+ assert response.json() == snapshot(
+ {
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "openapi": "3.1.0",
+ "paths": {
+ "/a": {
+ "get": {
+ "operationId": "a_a_get",
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ }
+ },
+ "summary": "A",
+ }
+ },
+ "/b": {
+ "get": {
+ "operationId": "b_b_get",
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ }
+ },
+ "summary": "B",
+ }
+ },
},
- "/b": {
- "get": {
- "operationId": "b_b_get",
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- }
- },
- "summary": "B",
- }
- },
- },
- }
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/product": {
- "get": {
- "summary": "Create Item",
- "operationId": "create_item_product_get",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Product"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/product": {
+ "get": {
+ "summary": "Create Item",
+ "operationId": "create_item_product_get",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Product"}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Product": {
- "title": "Product",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {"title": "Description", "type": "string"},
- "price": {"title": "Price", "type": "number"},
+ "Product": {
+ "title": "Product",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import APIRouter, Depends, FastAPI, Response
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
class ResponseLevel0(JSONResponse):
response = client.get("/openapi.json")
assert issubclass(w[-1].category, UserWarning)
assert "Duplicate Operation ID" in str(w[-1].message)
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/override1": {
- "get": {
- "tags": ["path1a", "path1b"],
- "summary": "Path1 Override",
- "operationId": "path1_override_override1_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level1", "type": "string"},
- "name": "level1",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-1": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/override1": {
+ "get": {
+ "tags": ["path1a", "path1b"],
+ "summary": "Path1 Override",
+ "operationId": "path1_override_override1_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level1", "type": "string"},
+ "name": "level1",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-1": {"schema": {}}},
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/default1": {
+ "get": {
+ "summary": "Path1 Default",
+ "operationId": "path1_default_default1_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level1", "type": "string"},
+ "name": "level1",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-0": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
}
},
- },
- "deprecated": True,
- }
- },
- "/default1": {
- "get": {
- "summary": "Path1 Default",
- "operationId": "path1_default_default1_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level1", "type": "string"},
- "name": "level1",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-0": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ "/level1/level2/override3": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "path3a",
+ "path3b",
+ ],
+ "summary": "Path3 Override Router2 Override",
+ "operationId": "path3_override_router2_override_level1_level2_override3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
},
- },
- "500": {"description": "Server error level 0"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- }
- },
- }
- },
- "/level1/level2/override3": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "path3a",
- "path3b",
- ],
- "summary": "Path3 Override Router2 Override",
- "operationId": "path3_override_router2_override_level1_level2_override3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/default3": {
+ "get": {
+ "tags": ["level1a", "level1b", "level2a", "level2b"],
+ "summary": "Path3 Default Router2 Override",
+ "operationId": "path3_default_router2_override_level1_level2_default3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-2": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level3/level4/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level1_level2_level3_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/default3": {
- "get": {
- "tags": ["level1a", "level1b", "level2a", "level2b"],
- "summary": "Path3 Default Router2 Override",
- "operationId": "path3_default_router2_override_level1_level2_default3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-2": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level3/level4/default5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ ],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level1_level2_level3_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level3/level4/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level1_level2_level3_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level3/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level1_level2_level3_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level3/default5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ ],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level1_level2_level3_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level4/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level1_level2_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level3/level4/default5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- ],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level1_level2_level3_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/level4/default5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "level4a",
+ "level4b",
+ ],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level1_level2_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level2a",
+ "level2b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level1_level2_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level3/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level1_level2_level3_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level3/default5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- ],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level1_level2_level3_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level4/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level1_level2_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/level4/default5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "level4a",
- "level4b",
- ],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level1_level2_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level2a",
- "level2b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level1_level2_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level2/default5": {
- "get": {
- "tags": ["level1a", "level1b", "level2a", "level2b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level1_level2_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-2": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "402": {"description": "Client error level 2"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "502": {"description": "Server error level 2"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/override3": {
- "get": {
- "tags": ["level1a", "level1b", "path3a", "path3b"],
- "summary": "Path3 Override Router2 Default",
- "operationId": "path3_override_router2_default_level1_override3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/default3": {
- "get": {
- "tags": ["level1a", "level1b"],
- "summary": "Path3 Default Router2 Default",
- "operationId": "path3_default_router2_default_level1_default3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-1": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- }
- },
- "/level1/level3/level4/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level1_level3_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level3/level4/default5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- ],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level1_level3_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level3/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level3a",
- "level3b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level1_level3_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "403": {"description": "Client error level 3"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "503": {"description": "Server error level 3"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level3/default5": {
- "get": {
- "tags": ["level1a", "level1b", "level3a", "level3b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level1_level3_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- }
- },
- "/level1/level4/override5": {
- "get": {
- "tags": [
- "level1a",
- "level1b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level1_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/level4/default5": {
- "get": {
- "tags": ["level1a", "level1b", "level4a", "level4b"],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level1_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/override5": {
- "get": {
- "tags": ["level1a", "level1b", "path5a", "path5b"],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level1_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level1/default5": {
- "get": {
- "tags": ["level1a", "level1b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level1_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-1": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "401": {"description": "Client error level 1"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "501": {"description": "Server error level 1"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- "callback1": {
- "/": {
- "get": {
- "summary": "Callback1",
- "operationId": "callback1__get",
- "parameters": [
- {
- "name": "level1",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level1",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- }
- },
- },
- }
- },
- "/level2/override3": {
- "get": {
- "tags": ["level2a", "level2b", "path3a", "path3b"],
- "summary": "Path3 Override Router2 Override",
- "operationId": "path3_override_router2_override_level2_override3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level2/default5": {
+ "get": {
+ "tags": ["level1a", "level1b", "level2a", "level2b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level1_level2_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-2": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "402": {"description": "Client error level 2"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "502": {"description": "Server error level 2"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/default3": {
- "get": {
- "tags": ["level2a", "level2b"],
- "summary": "Path3 Default Router2 Override",
- "operationId": "path3_default_router2_override_level2_default3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-2": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/override3": {
+ "get": {
+ "tags": ["level1a", "level1b", "path3a", "path3b"],
+ "summary": "Path3 Override Router2 Default",
+ "operationId": "path3_override_router2_default_level1_override3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level3/level4/override5": {
- "get": {
- "tags": [
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level2_level3_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/default3": {
+ "get": {
+ "tags": ["level1a", "level1b"],
+ "summary": "Path3 Default Router2 Default",
+ "operationId": "path3_default_router2_default_level1_default3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-1": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ }
+ },
+ "/level1/level3/level4/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level1_level3_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level3/level4/default5": {
- "get": {
- "tags": [
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- ],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level2_level3_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level3/level4/default5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ ],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level1_level3_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level3/override5": {
- "get": {
- "tags": [
- "level2a",
- "level2b",
- "level3a",
- "level3b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level2_level3_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level3/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level3a",
+ "level3b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level1_level3_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "403": {"description": "Client error level 3"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "503": {"description": "Server error level 3"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level3/default5": {
- "get": {
- "tags": ["level2a", "level2b", "level3a", "level3b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level2_level3_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level3/default5": {
+ "get": {
+ "tags": ["level1a", "level1b", "level3a", "level3b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level1_level3_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level4/override5": {
- "get": {
- "tags": [
- "level2a",
- "level2b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level2_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
+ }
+ },
+ "/level1/level4/override5": {
+ "get": {
+ "tags": [
+ "level1a",
+ "level1b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level1_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/level4/default5": {
+ "get": {
+ "tags": ["level1a", "level1b", "level4a", "level4b"],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level1_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/level4/default5": {
- "get": {
- "tags": ["level2a", "level2b", "level4a", "level4b"],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level2_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
}
}
},
},
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level1/override5": {
+ "get": {
+ "tags": ["level1a", "level1b", "path5a", "path5b"],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level1_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
+ },
+ }
+ }
+ },
+ },
+ "deprecated": True,
+ }
+ },
+ "/level1/default5": {
+ "get": {
+ "tags": ["level1a", "level1b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level1_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-1": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "401": {"description": "Client error level 1"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "501": {"description": "Server error level 1"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback1": {
+ "/": {
+ "get": {
+ "summary": "Callback1",
+ "operationId": "callback1__get",
+ "parameters": [
+ {
+ "name": "level1",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level1",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ }
+ },
+ "/level2/override3": {
+ "get": {
+ "tags": ["level2a", "level2b", "path3a", "path3b"],
+ "summary": "Path3 Override Router2 Override",
+ "operationId": "path3_override_router2_override_level2_override3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/override5": {
- "get": {
- "tags": ["level2a", "level2b", "path5a", "path5b"],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level2_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
}
}
},
},
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/default3": {
+ "get": {
+ "tags": ["level2a", "level2b"],
+ "summary": "Path3 Default Router2 Override",
+ "operationId": "path3_default_router2_override_level2_default3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-2": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level3/level4/override5": {
+ "get": {
+ "tags": [
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level2_level3_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level2/default5": {
- "get": {
- "tags": ["level2a", "level2b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level2_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-2": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "402": {"description": "Client error level 2"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
}
}
},
},
- "500": {"description": "Server error level 0"},
- "502": {"description": "Server error level 2"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level3/level4/default5": {
+ "get": {
+ "tags": [
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ ],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level2_level3_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback2": {
- "/": {
- "get": {
- "summary": "Callback2",
- "operationId": "callback2__get",
- "parameters": [
- {
- "name": "level2",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level2",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/override3": {
- "get": {
- "tags": ["path3a", "path3b"],
- "summary": "Path3 Override Router2 Default",
- "operationId": "path3_override_router2_default_override3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level3/override5": {
+ "get": {
+ "tags": [
+ "level2a",
+ "level2b",
+ "level3a",
+ "level3b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level2_level3_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/default3": {
- "get": {
- "summary": "Path3 Default Router2 Default",
- "operationId": "path3_default_router2_default_default3_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level3", "type": "string"},
- "name": "level3",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-0": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level3/default5": {
+ "get": {
+ "tags": ["level2a", "level2b", "level3a", "level3b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level2_level3_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- }
- },
- }
- },
- "/level3/level4/override5": {
- "get": {
- "tags": [
- "level3a",
- "level3b",
- "level4a",
- "level4b",
- "path5a",
- "path5b",
- ],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level3_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level4/override5": {
+ "get": {
+ "tags": [
+ "level2a",
+ "level2b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level2_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/level4/default5": {
+ "get": {
+ "tags": ["level2a", "level2b", "level4a", "level4b"],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level2_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level3/level4/default5": {
- "get": {
- "tags": ["level3a", "level3b", "level4a", "level4b"],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level3_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "403": {"description": "Client error level 3"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
}
}
},
},
- "500": {"description": "Server error level 0"},
- "503": {"description": "Server error level 3"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/override5": {
+ "get": {
+ "tags": ["level2a", "level2b", "path5a", "path5b"],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level2_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level2/default5": {
+ "get": {
+ "tags": ["level2a", "level2b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level2_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-2": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "402": {"description": "Client error level 2"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "502": {"description": "Server error level 2"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback2": {
+ "/": {
+ "get": {
+ "summary": "Callback2",
+ "operationId": "callback2__get",
+ "parameters": [
+ {
+ "name": "level2",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level2",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level3/override5": {
- "get": {
- "tags": ["level3a", "level3b", "path5a", "path5b"],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_level3_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "403": {"description": "Client error level 3"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- "503": {"description": "Server error level 3"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/override3": {
+ "get": {
+ "tags": ["path3a", "path3b"],
+ "summary": "Path3 Override Router2 Default",
+ "operationId": "path3_override_router2_default_override3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/default3": {
+ "get": {
+ "summary": "Path3 Default Router2 Default",
+ "operationId": "path3_default_router2_default_default3_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level3", "type": "string"},
+ "name": "level3",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-0": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
}
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ }
+ },
+ "/level3/level4/override5": {
+ "get": {
+ "tags": [
+ "level3a",
+ "level3b",
+ "level4a",
+ "level4b",
+ "path5a",
+ "path5b",
+ ],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level3_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level3/default5": {
- "get": {
- "tags": ["level3a", "level3b"],
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_level3_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-3": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "403": {"description": "Client error level 3"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "503": {"description": "Server error level 3"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback3": {
- "/": {
- "get": {
- "summary": "Callback3",
- "operationId": "callback3__get",
- "parameters": [
- {
- "name": "level3",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level3",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level3/level4/default5": {
+ "get": {
+ "tags": ["level3a", "level3b", "level4a", "level4b"],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level3_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "403": {"description": "Client error level 3"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "503": {"description": "Server error level 3"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- }
- },
- "/level4/override5": {
- "get": {
- "tags": ["level4a", "level4b", "path5a", "path5b"],
- "summary": "Path5 Override Router4 Override",
- "operationId": "path5_override_router4_override_level4_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "404": {"description": "Client error level 4"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
- },
- "500": {"description": "Server error level 0"},
- "504": {"description": "Server error level 4"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level3/override5": {
+ "get": {
+ "tags": ["level3a", "level3b", "path5a", "path5b"],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_level3_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "403": {"description": "Client error level 3"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "503": {"description": "Server error level 3"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/level4/default5": {
- "get": {
- "tags": ["level4a", "level4b"],
- "summary": "Path5 Default Router4 Override",
- "operationId": "path5_default_router4_override_level4_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-4": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "404": {"description": "Client error level 4"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- "504": {"description": "Server error level 4"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level3/default5": {
+ "get": {
+ "tags": ["level3a", "level3b"],
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_level3_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-3": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "403": {"description": "Client error level 3"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "503": {"description": "Server error level 3"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback3": {
+ "/": {
+ "get": {
+ "summary": "Callback3",
+ "operationId": "callback3__get",
+ "parameters": [
+ {
+ "name": "level3",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level3",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback4": {
- "/": {
- "get": {
- "summary": "Callback4",
- "operationId": "callback4__get",
- "parameters": [
- {
- "name": "level4",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level4",
- "type": "string",
- },
+ }
+ },
+ "/level4/override5": {
+ "get": {
+ "tags": ["level4a", "level4b", "path5a", "path5b"],
+ "summary": "Path5 Override Router4 Override",
+ "operationId": "path5_override_router4_override_level4_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "404": {"description": "Client error level 4"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "504": {"description": "Server error level 4"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
- },
- },
- "deprecated": True,
- }
- },
- "/override5": {
- "get": {
- "tags": ["path5a", "path5b"],
- "summary": "Path5 Override Router4 Default",
- "operationId": "path5_override_router4_default_override5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-5": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "405": {"description": "Client error level 5"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
}
}
},
},
- "500": {"description": "Server error level 0"},
- "505": {"description": "Server error level 5"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/level4/default5": {
+ "get": {
+ "tags": ["level4a", "level4b"],
+ "summary": "Path5 Default Router4 Override",
+ "operationId": "path5_default_router4_override_level4_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-4": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "404": {"description": "Client error level 4"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "504": {"description": "Server error level 4"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback4": {
+ "/": {
+ "get": {
+ "summary": "Callback4",
+ "operationId": "callback4__get",
+ "parameters": [
+ {
+ "name": "level4",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level4",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- "callback5": {
- "/": {
- "get": {
- "summary": "Callback5",
- "operationId": "callback5__get",
- "parameters": [
- {
- "name": "level5",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level5",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/override5": {
+ "get": {
+ "tags": ["path5a", "path5b"],
+ "summary": "Path5 Override Router4 Default",
+ "operationId": "path5_override_router4_default_override5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-5": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "405": {"description": "Client error level 5"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ "505": {"description": "Server error level 5"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ }
+ },
+ "callback5": {
+ "/": {
+ "get": {
+ "summary": "Callback5",
+ "operationId": "callback5__get",
+ "parameters": [
+ {
+ "name": "level5",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level5",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
- }
- },
- },
- "deprecated": True,
- }
- },
- "/default5": {
- "get": {
- "summary": "Path5 Default Router4 Default",
- "operationId": "path5_default_router4_default_default5_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Level5", "type": "string"},
- "name": "level5",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/x-level-0": {"schema": {}}},
- },
- "400": {"description": "Client error level 0"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
}
}
},
},
- "500": {"description": "Server error level 0"},
- },
- "callbacks": {
- "callback0": {
- "/": {
- "get": {
- "summary": "Callback0",
- "operationId": "callback0__get",
- "parameters": [
- {
- "name": "level0",
- "in": "query",
- "required": True,
- "schema": {
- "title": "Level0",
- "type": "string",
- },
+ "deprecated": True,
+ }
+ },
+ "/default5": {
+ "get": {
+ "summary": "Path5 Default Router4 Default",
+ "operationId": "path5_default_router4_default_default5_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Level5", "type": "string"},
+ "name": "level5",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/x-level-0": {"schema": {}}},
+ },
+ "400": {"description": "Client error level 0"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
}
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ }
+ },
+ },
+ "500": {"description": "Server error level 0"},
+ },
+ "callbacks": {
+ "callback0": {
+ "/": {
+ "get": {
+ "summary": "Callback0",
+ "operationId": "callback0__get",
+ "parameters": [
+ {
+ "name": "level0",
+ "in": "query",
+ "required": True,
+ "schema": {
+ "title": "Level0",
+ "type": "string",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {"schema": {}}
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
}
- }
- },
- }
+ },
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/": {
- "get": {
- "summary": "Get Users",
- "operationId": "get_users_users__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/users/{user_id}": {
- "get": {
- "summary": "Get User",
- "operationId": "get_user_users__user_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "User Id", "type": "string"},
- "name": "user_id",
- "in": "path",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/": {
+ "get": {
+ "summary": "Get Users",
+ "operationId": "get_users_users__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/users/{user_id}": {
+ "get": {
+ "summary": "Get User",
+ "operationId": "get_user_users__user_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "User Id", "type": "string"},
+ "name": "user_id",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/items/": {
- "get": {
- "summary": "Get Items",
- "operationId": "get_items_items__get",
- "parameters": [
- {
- "required": False,
- "name": "user_id",
- "in": "query",
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "User Id",
+ }
+ },
+ "/items/": {
+ "get": {
+ "summary": "Get Items",
+ "operationId": "get_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "name": "user_id",
+ "in": "query",
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "User Id",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/items/{item_id}": {
- "get": {
- "summary": "Get Item",
- "operationId": "get_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "name": "user_id",
- "in": "query",
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "User Id",
+ }
+ },
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Get Item",
+ "operationId": "get_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ {
+ "required": False,
+ "name": "user_id",
+ "in": "query",
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "User Id",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/users/{user_id}/items/": {
- "get": {
- "summary": "Get Items",
- "operationId": "get_items_users__user_id__items__get",
- "parameters": [
- {
- "required": True,
- "name": "user_id",
- "in": "path",
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "User Id",
+ }
+ },
+ "/users/{user_id}/items/": {
+ "get": {
+ "summary": "Get Items",
+ "operationId": "get_items_users__user_id__items__get",
+ "parameters": [
+ {
+ "required": True,
+ "name": "user_id",
+ "in": "path",
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "User Id",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/users/{user_id}/items/{item_id}": {
- "get": {
- "summary": "Get Item",
- "operationId": "get_item_users__user_id__items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "name": "user_id",
- "in": "path",
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "User Id",
+ }
+ },
+ "/users/{user_id}/items/{item_id}": {
+ "get": {
+ "summary": "Get Item",
+ "operationId": "get_item_users__user_id__items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ {
+ "required": True,
+ "name": "user_id",
+ "in": "path",
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "User Id",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from .app.main import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a/compute": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a/compute": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Compute",
+ "operationId": "compute_a_compute_post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_compute_a_compute_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Compute",
- "operationId": "compute_a_compute_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_compute_a_compute_post"
- }
- }
- },
- "required": True,
- },
- }
- },
- "/b/compute/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/b/compute/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Compute",
+ "operationId": "compute_b_compute__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_compute_b_compute__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Compute",
- "operationId": "compute_b_compute__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_compute_b_compute__post"
- }
- }
- },
- "required": True,
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_compute_b_compute__post": {
- "title": "Body_compute_b_compute__post",
- "required": ["a", "b"],
- "type": "object",
- "properties": {
- "a": {"title": "A", "type": "integer"},
- "b": {"title": "B", "type": "string"},
+ "components": {
+ "schemas": {
+ "Body_compute_b_compute__post": {
+ "title": "Body_compute_b_compute__post",
+ "required": ["a", "b"],
+ "type": "object",
+ "properties": {
+ "a": {"title": "A", "type": "integer"},
+ "b": {"title": "B", "type": "string"},
+ },
},
- },
- "Body_compute_a_compute_post": {
- "title": "Body_compute_a_compute_post",
- "required": ["a", "b"],
- "type": "object",
- "properties": {
- "a": {"title": "A", "type": "integer"},
- "b": {"title": "B", "type": "string"},
+ "Body_compute_a_compute_post": {
+ "title": "Body_compute_a_compute_post",
+ "required": ["a", "b"],
+ "type": "object",
+ "properties": {
+ "a": {"title": "A", "type": "integer"},
+ "b": {"title": "B", "type": "string"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Save Item No Body",
+ "operationId": "save_item_no_body_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Item",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Item"},
}
}
},
+ "required": True,
},
- },
- "summary": "Save Item No Body",
- "operationId": "save_item_no_body_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Item",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "age"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "age": {
- "title": "Age",
- "anyOf": [
- {"exclusiveMinimum": 0.0, "type": "number"},
- IsOneOf(
- # pydantic < 2.12.0
- {"type": "string"},
- # pydantic >= 2.12.0
- {
- "type": "string",
- "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$",
- },
- ),
- ],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "age"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "age": {
+ "title": "Age",
+ "anyOf": [
+ {"exclusiveMinimum": 0.0, "type": "number"},
+ IsOneOf(
+ # pydantic < 2.12.0
+ {"type": "string"},
+ # pydantic >= 2.12.0
+ {
+ "type": "string",
+ "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$",
+ },
+ ),
+ ],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Q",
- "type": "array",
- "items": {"type": "integer"},
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "type": "array",
+ "items": {"type": "integer"},
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import Body, Cookie, FastAPI, Header, Path, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/examples/": {
- "post": {
- "summary": "Examples",
- "operationId": "examples_examples__post",
- "requestBody": {
- "content": {
- "application/json": {
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/examples/": {
+ "post": {
+ "summary": "Examples",
+ "operationId": "examples_examples__post",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Item",
+ "examples": [
+ {"data": "Data in Body examples, example1"}
+ ],
+ },
+ "examples": {
+ "Example One": {
+ "summary": "Example One Summary",
+ "description": "Example One Description",
+ "value": {
+ "data": "Data in Body examples, example1"
+ },
+ },
+ "Example Two": {
+ "value": {
+ "data": "Data in Body examples, example2"
+ }
+ },
+ },
+ }
+ },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/path_examples/{item_id}": {
+ "get": {
+ "summary": "Path Examples",
+ "operationId": "path_examples_path_examples__item_id__get",
+ "parameters": [
+ {
+ "name": "item_id",
+ "in": "path",
+ "required": True,
"schema": {
- "$ref": "#/components/schemas/Item",
+ "type": "string",
"examples": [
- {"data": "Data in Body examples, example1"}
+ "json_schema_item_1",
+ "json_schema_item_2",
],
+ "title": "Item Id",
},
"examples": {
- "Example One": {
- "summary": "Example One Summary",
- "description": "Example One Description",
- "value": {
- "data": "Data in Body examples, example1"
- },
- },
- "Example Two": {
- "value": {
- "data": "Data in Body examples, example2"
- }
+ "Path One": {
+ "summary": "Path One Summary",
+ "description": "Path One Description",
+ "value": "item_1",
},
+ "Path Two": {"value": "item_2"},
},
}
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/path_examples/{item_id}": {
- "get": {
- "summary": "Path Examples",
- "operationId": "path_examples_path_examples__item_id__get",
- "parameters": [
- {
- "name": "item_id",
- "in": "path",
- "required": True,
- "schema": {
- "type": "string",
- "examples": [
- "json_schema_item_1",
- "json_schema_item_2",
- ],
- "title": "Item Id",
- },
- "examples": {
- "Path One": {
- "summary": "Path One Summary",
- "description": "Path One Description",
- "value": "item_1",
+ }
+ },
+ "/query_examples/": {
+ "get": {
+ "summary": "Query Examples",
+ "operationId": "query_examples_query_examples__get",
+ "parameters": [
+ {
+ "name": "data",
+ "in": "query",
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "examples": [
+ "json_schema_query1",
+ "json_schema_query2",
+ ],
+ "title": "Data",
+ },
+ "examples": {
+ "Query One": {
+ "summary": "Query One Summary",
+ "description": "Query One Description",
+ "value": "query1",
+ },
+ "Query Two": {"value": "query2"},
},
- "Path Two": {"value": "item_2"},
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query_examples/": {
- "get": {
- "summary": "Query Examples",
- "operationId": "query_examples_query_examples__get",
- "parameters": [
- {
- "name": "data",
- "in": "query",
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "examples": [
- "json_schema_query1",
- "json_schema_query2",
- ],
- "title": "Data",
- },
- "examples": {
- "Query One": {
- "summary": "Query One Summary",
- "description": "Query One Description",
- "value": "query1",
+ }
+ },
+ "/header_examples/": {
+ "get": {
+ "summary": "Header Examples",
+ "operationId": "header_examples_header_examples__get",
+ "parameters": [
+ {
+ "name": "data",
+ "in": "header",
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "examples": [
+ "json_schema_header1",
+ "json_schema_header2",
+ ],
+ "title": "Data",
},
- "Query Two": {"value": "query2"},
+ "examples": {
+ "Header One": {
+ "summary": "Header One Summary",
+ "description": "Header One Description",
+ "value": "header1",
+ },
+ "Header Two": {"value": "header2"},
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/header_examples/": {
- "get": {
- "summary": "Header Examples",
- "operationId": "header_examples_header_examples__get",
- "parameters": [
- {
- "name": "data",
- "in": "header",
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "examples": [
- "json_schema_header1",
- "json_schema_header2",
- ],
- "title": "Data",
- },
- "examples": {
- "Header One": {
- "summary": "Header One Summary",
- "description": "Header One Description",
- "value": "header1",
+ }
+ },
+ "/cookie_examples/": {
+ "get": {
+ "summary": "Cookie Examples",
+ "operationId": "cookie_examples_cookie_examples__get",
+ "parameters": [
+ {
+ "name": "data",
+ "in": "cookie",
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "examples": [
+ "json_schema_cookie1",
+ "json_schema_cookie2",
+ ],
+ "title": "Data",
+ },
+ "examples": {
+ "Cookie One": {
+ "summary": "Cookie One Summary",
+ "description": "Cookie One Description",
+ "value": "cookie1",
+ },
+ "Cookie Two": {"value": "cookie2"},
},
- "Header Two": {"value": "header2"},
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- "/cookie_examples/": {
- "get": {
- "summary": "Cookie Examples",
- "operationId": "cookie_examples_cookie_examples__get",
- "parameters": [
- {
- "name": "data",
- "in": "cookie",
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "examples": [
- "json_schema_cookie1",
- "json_schema_cookie2",
- ],
- "title": "Data",
- },
- "examples": {
- "Cookie One": {
- "summary": "Cookie One Summary",
- "description": "Cookie One Description",
- "value": "cookie1",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
},
- "Cookie Two": {"value": "cookie2"},
- },
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
+ "type": "array",
+ "title": "Detail",
+ }
},
+ "type": "object",
+ "title": "HTTPValidationError",
},
- }
- },
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ "Item": {
+ "properties": {"data": {"type": "string", "title": "Data"}},
+ "type": "object",
+ "required": ["data"],
+ "title": "Item",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {"data": {"type": "string", "title": "Data"}},
- "type": "object",
- "required": ["data"],
- "title": "Item",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "Route With Extra Query Parameters",
- "operationId": "route_with_extra_query_parameters__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "integer"}, {"type": "null"}],
- "default": 50,
- "title": "Standard Query Param",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "Route With Extra Query Parameters",
+ "operationId": "route_with_extra_query_parameters__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "integer"}, {"type": "null"}],
+ "default": 50,
+ "title": "Standard Query Param",
+ },
+ "name": "standard_query_param",
+ "in": "query",
},
- "name": "standard_query_param",
- "in": "query",
- },
- {
- "required": False,
- "schema": {"title": "Extra Param 1"},
- "name": "extra_param_1",
- "in": "query",
- },
- {
- "required": True,
- "schema": {"title": "Extra Param 2"},
- "name": "extra_param_2",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ {
+ "required": False,
+ "schema": {"title": "Extra Param 1"},
+ "name": "extra_param_1",
+ "in": "query",
+ },
+ {
+ "required": True,
+ "schema": {"title": "Extra Param 2"},
+ "name": "extra_param_2",
+ "in": "query",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
assert response.json() == {}
-def test_openapi():
+def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- },
- "summary": "Route With Extras",
- "operationId": "route_with_extras__get",
- "x-custom-extension": "value",
- }
+ "summary": "Route With Extras",
+ "operationId": "route_with_extras__get",
+ "x-custom-extension": "value",
+ }
+ },
},
- },
- }
+ }
+ )
client = get_app_client(separate_input_output_schemas=False)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "items": {"$ref": "#/components/schemas/Item"},
- "type": "array",
- "title": "Response Read Items Items Get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ "type": "array",
+ "title": "Response Read Items Items Get",
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "402": {
- "description": "Payment Required",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "402": {
+ "description": "Payment Required",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
- },
- "/items-list/": {
- "post": {
- "summary": "Create Item List",
- "operationId": "create_item_list_items_list__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "items": {"$ref": "#/components/schemas/Item"},
- "type": "array",
- "title": "Item",
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "/items-list/": {
+ "post": {
+ "summary": "Create Item List",
+ "operationId": "create_item_list_items_list__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "items": {"$ref": "#/components/schemas/Item"},
+ "type": "array",
+ "title": "Item",
}
}
},
+ "required": True,
},
- },
- }
- },
- "/with-computed-field/": {
- "post": {
- "summary": "Create With Computed Field",
- "operationId": "create_with_computed_field_with_computed_field__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/WithComputedField-Input"
- }
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ }
+ },
+ "/with-computed-field/": {
+ "post": {
+ "summary": "Create With Computed Field",
+ "operationId": "create_with_computed_field_with_computed_field__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/WithComputedField-Output"
+ "$ref": "#/components/schemas/WithComputedField-Input"
}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/WithComputedField-Output"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
- },
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
- },
- "sub": {
- "anyOf": [
- {"$ref": "#/components/schemas/SubItem"},
- {"type": "null"},
- ]
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
},
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "required": ["name"],
- "title": "Item",
- },
- "SubItem": {
- "properties": {
- "subname": {"type": "string", "title": "Subname"},
- "sub_description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Sub Description",
+ "Item": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
+ "sub": {
+ "anyOf": [
+ {"$ref": "#/components/schemas/SubItem"},
+ {"type": "null"},
+ ]
+ },
},
- "tags": {
- "items": {"type": "string"},
- "type": "array",
- "title": "Tags",
- "default": [],
+ "type": "object",
+ "required": ["name"],
+ "title": "Item",
+ },
+ "SubItem": {
+ "properties": {
+ "subname": {"type": "string", "title": "Subname"},
+ "sub_description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Sub Description",
+ },
+ "tags": {
+ "items": {"type": "string"},
+ "type": "array",
+ "title": "Tags",
+ "default": [],
+ },
},
+ "type": "object",
+ "required": ["subname"],
+ "title": "SubItem",
},
- "type": "object",
- "required": ["subname"],
- "title": "SubItem",
- },
- "WithComputedField-Input": {
- "properties": {"name": {"type": "string", "title": "Name"}},
- "type": "object",
- "required": ["name"],
- "title": "WithComputedField",
- },
- "WithComputedField-Output": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "computed_field": {
- "type": "string",
- "title": "Computed Field",
- "readOnly": True,
+ "WithComputedField-Input": {
+ "properties": {"name": {"type": "string", "title": "Name"}},
+ "type": "object",
+ "required": ["name"],
+ "title": "WithComputedField",
+ },
+ "WithComputedField-Output": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "computed_field": {
+ "type": "string",
+ "title": "Computed Field",
+ "readOnly": True,
+ },
},
+ "type": "object",
+ "required": ["name", "computed_field"],
+ "title": "WithComputedField",
},
- "type": "object",
- "required": ["name", "computed_field"],
- "title": "WithComputedField",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- "type": "array",
- "title": "Location",
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
+ },
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/{user_id}": {
- "get": {
- "summary": "Read Users",
- "operationId": "read_users_users__user_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "User Id", "type": "integer"},
- "name": "user_id",
- "in": "path",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/{user_id}": {
+ "get": {
+ "summary": "Read Users",
+ "operationId": "read_users_users__user_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "User Id", "type": "integer"},
+ "name": "user_id",
+ "in": "path",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import Cookie, FastAPI, Header, Path, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
return {"hidden_query": hidden_query}
-openapi_schema = {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/hidden_cookie": {
- "get": {
- "summary": "Hidden Cookie",
- "operationId": "hidden_cookie_hidden_cookie_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- },
- "/hidden_header": {
- "get": {
- "summary": "Hidden Header",
- "operationId": "hidden_header_hidden_header_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- },
- "/hidden_path/{hidden_path}": {
- "get": {
- "summary": "Hidden Path",
- "operationId": "hidden_path_hidden_path__hidden_path__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- },
- "/hidden_query": {
- "get": {
- "summary": "Hidden Query",
- "operationId": "hidden_query_hidden_query_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- },
- },
- }
- },
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
- "input": {"title": "Input"},
- "ctx": {"title": "Context", "type": "object"},
- },
- },
- }
- },
-}
-
-
-def test_openapi_schema():
- client = TestClient(app)
- response = client.get("/openapi.json")
- assert response.status_code == 200
- assert response.json() == openapi_schema
-
-
@pytest.mark.parametrize(
"path,cookies,expected_status,expected_response",
[
response = client.get(path)
assert response.status_code == expected_status
assert response.json() == expected_response
+
+
+def test_openapi_schema():
+ client = TestClient(app)
+ response = client.get("/openapi.json")
+ assert response.status_code == 200
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/hidden_cookie": {
+ "get": {
+ "summary": "Hidden Cookie",
+ "operationId": "hidden_cookie_hidden_cookie_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/hidden_header": {
+ "get": {
+ "summary": "Hidden Header",
+ "operationId": "hidden_header_hidden_header_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/hidden_path/{hidden_path}": {
+ "get": {
+ "summary": "Hidden Path",
+ "operationId": "hidden_path_hidden_path__hidden_path__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/hidden_query": {
+ "get": {
+ "summary": "Hidden Query",
+ "operationId": "hidden_query_hidden_query_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ "input": {"title": "Input"},
+ "ctx": {"title": "Context", "type": "object"},
+ },
+ },
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Save Item No Body",
- "operationId": "save_item_no_body_items__item_id__put",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Save Item No Body",
+ "operationId": "save_item_no_body_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Query
from fastapi.exceptions import FastAPIDeprecationWarning
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from .utils import needs_py310
client = get_client()
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- # insert_assert(response.json())
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "name": "q",
- "in": "query",
- "required": False,
- "schema": {
- "anyOf": [
- {"type": "string", "pattern": "^fixedquery$"},
- {"type": "null"},
- ],
- "title": "Q",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "name": "q",
+ "in": "query",
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"type": "string", "pattern": "^fixedquery$"},
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Header, status
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
client = TestClient(app)
-schema = {
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "title": "Detail",
- "type": "array",
- }
- },
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]},
- "title": "Location",
- "type": "array",
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
- },
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- "type": "object",
- },
- }
- },
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "openapi": "3.1.0",
- "paths": {
- "/": {
- "get": {
- "operationId": "get_deps__get",
- "parameters": [
- {
- "in": "header",
- "name": "someheader",
- "required": True,
- "schema": {"title": "Someheader", "type": "string"},
- }
- ],
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
- },
- "description": "Validation Error",
- },
- },
- "summary": "Get Deps",
- }
- }
- },
-}
+
+def test_response():
+ response = client.get("/", headers={"someheader": "hello"})
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"dep1": "hello", "dep2": "hello123"}
-def test_schema():
+def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == status.HTTP_200_OK
actual_schema = response.json()
- assert actual_schema == schema
assert (
len(actual_schema["paths"]["/"]["get"]["parameters"]) == 1
) # primary goal of this test
-
-
-def test_response():
- response = client.get("/", headers={"someheader": "hello"})
- assert response.status_code == status.HTTP_200_OK
- assert response.json() == {"dep1": "hello", "dep2": "hello123"}
+ assert actual_schema == snapshot(
+ {
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "title": "Detail",
+ "type": "array",
+ }
+ },
+ "title": "HTTPValidationError",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ },
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
+ "type": "object",
+ },
+ }
+ },
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "openapi": "3.1.0",
+ "paths": {
+ "/": {
+ "get": {
+ "operationId": "get_deps__get",
+ "parameters": [
+ {
+ "in": "header",
+ "name": "someheader",
+ "required": True,
+ "schema": {"title": "Someheader", "type": "string"},
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ "description": "Validation Error",
+ },
+ },
+ "summary": "Get Deps",
+ }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Path, Query, status
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == status.HTTP_200_OK
- actual_schema = response.json()
- assert actual_schema == {
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "title": "Detail",
- "type": "array",
- }
+ assert response.json() == snapshot(
+ {
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "title": "Detail",
+ "type": "array",
+ }
+ },
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "title": "Location",
+ "type": "array",
},
- "title": "Location",
- "type": "array",
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
},
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- "type": "object",
- },
- }
- },
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "openapi": "3.1.0",
- "paths": {
- "/{repeated_alias}": {
- "get": {
- "operationId": "get_parameters_with_repeated_aliases__repeated_alias__get",
- "parameters": [
- {
- "in": "path",
- "name": "repeated_alias",
- "required": True,
- "schema": {"title": "Repeated Alias", "type": "string"},
- },
- {
- "in": "query",
- "name": "repeated_alias",
- "required": True,
- "schema": {"title": "Repeated Alias", "type": "string"},
- },
- ],
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "openapi": "3.1.0",
+ "paths": {
+ "/{repeated_alias}": {
+ "get": {
+ "operationId": "get_parameters_with_repeated_aliases__repeated_alias__get",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "repeated_alias",
+ "required": True,
+ "schema": {"title": "Repeated Alias", "type": "string"},
+ },
+ {
+ "in": "query",
+ "name": "repeated_alias",
+ "required": True,
+ "schema": {"title": "Repeated Alias", "type": "string"},
+ },
+ ],
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
- "summary": "Get Parameters With Repeated Aliases",
+ "summary": "Get Parameters With Repeated Aliases",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Response
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/{id}": {
- "delete": {
- "summary": "Delete Deployment",
- "operationId": "delete_deployment__id__delete",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Id", "type": "integer"},
- "name": "id",
- "in": "path",
- }
- ],
- "responses": {
- "204": {"description": "Successful Response"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/{id}": {
+ "delete": {
+ "summary": "Delete Deployment",
+ "operationId": "delete_deployment__id__delete",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Id", "type": "integer"},
+ "name": "id",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "204": {"description": "Successful Response"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/products": {
- "post": {
- "summary": "Create Product",
- "operationId": "create_product_products_post",
- "requestBody": {
- "content": {
- "application/vnd.api+json": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_product_products_post"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/products": {
+ "post": {
+ "summary": "Create Product",
+ "operationId": "create_product_products_post",
+ "requestBody": {
+ "content": {
+ "application/vnd.api+json": {
+ "schema": {
+ "$ref": "#/components/schemas/Body_create_product_products_post"
+ }
}
- }
+ },
+ "required": True,
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/shops": {
+ "post": {
+ "summary": "Create Shop",
+ "operationId": "create_shop_shops_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/vnd.api+json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_shop_shops_post"
}
}
},
+ "required": True,
},
- },
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
},
- "/shops": {
- "post": {
- "summary": "Create Shop",
- "operationId": "create_shop_shops_post",
- "requestBody": {
- "content": {
- "application/vnd.api+json": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_shop_shops_post"
- }
- }
+ "components": {
+ "schemas": {
+ "Body_create_product_products_post": {
+ "title": "Body_create_product_products_post",
+ "required": ["data"],
+ "type": "object",
+ "properties": {
+ "data": {"$ref": "#/components/schemas/Product"}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ "Body_create_shop_shops_post": {
+ "title": "Body_create_shop_shops_post",
+ "required": ["data"],
+ "type": "object",
+ "properties": {
+ "data": {"$ref": "#/components/schemas/Shop"},
+ "included": {
+ "title": "Included",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Product"},
+ "default": [],
},
},
},
- }
- },
- },
- "components": {
- "schemas": {
- "Body_create_product_products_post": {
- "title": "Body_create_product_products_post",
- "required": ["data"],
- "type": "object",
- "properties": {"data": {"$ref": "#/components/schemas/Product"}},
- },
- "Body_create_shop_shops_post": {
- "title": "Body_create_shop_shops_post",
- "required": ["data"],
- "type": "object",
- "properties": {
- "data": {"$ref": "#/components/schemas/Shop"},
- "included": {
- "title": "Included",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Product"},
- "default": [],
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
},
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "Product": {
+ "title": "Product",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- },
- "Product": {
- "title": "Product",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
+ "Shop": {
+ "title": "Shop",
+ "required": ["name"],
+ "type": "object",
+ "properties": {"name": {"title": "Name", "type": "string"}},
},
- },
- "Shop": {
- "title": "Shop",
- "required": ["name"],
- "type": "object",
- "properties": {"name": {"title": "Name", "type": "string"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import Cookie, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/optional-str", "/model-optional-str"],
)
def test_optional_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P",
- },
- "name": "p",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P",
+ },
+ "name": "p",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-alias", "/model-optional-alias"],
)
def test_optional_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Alias",
- },
- "name": "p_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Alias",
+ },
+ "name": "p_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-validation-alias", "/model-optional-validation-alias"],
)
def test_optional_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_optional_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from dirty_equals import IsOneOf
from fastapi import Cookie, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/required-str", "/model-required-str"],
)
def test_required_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P", "type": "string"},
- "name": "p",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P", "type": "string"},
+ "name": "p",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-alias", "/model-required-alias"],
)
def test_required_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Alias", "type": "string"},
- "name": "p_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Alias", "type": "string"},
+ "name": "p_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-validation-alias", "/model-required-validation-alias"],
)
def test_required_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_required_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "cookie",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "cookie",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from dirty_equals import AnyThing, IsOneOf, IsPartialDict
from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/required-list-str", "/model-required-list-str"],
)
def test_required_list_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-list-alias", "/model-required-list-alias"],
)
def test_required_list_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-list-validation-alias", "/model-required-list-validation-alias"],
)
def test_required_list_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Val Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Val Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_required_list_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Val Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Val Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
import pytest
from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/optional-list-str", "/model-optional-list-str"],
)
def test_optional_list_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P",
- },
- "name": "p",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P",
+ },
+ "name": "p",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-list-alias", "/model-optional-list-alias"],
)
def test_optional_list_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Alias",
- },
- "name": "p_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Alias",
+ },
+ "name": "p_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
)
def test_optional_list_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_optional_list_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
import pytest
from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/optional-str", "/model-optional-str"],
)
def test_optional_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P",
- },
- "name": "p",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P",
+ },
+ "name": "p",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-alias", "/model-optional-alias"],
)
def test_optional_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Alias",
- },
- "name": "p_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Alias",
+ },
+ "name": "p_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-validation-alias", "/model-optional-validation-alias"],
)
def test_optional_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_optional_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from dirty_equals import AnyThing, IsOneOf, IsPartialDict
from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/required-str", "/model-required-str"],
)
def test_required_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P", "type": "string"},
- "name": "p",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P", "type": "string"},
+ "name": "p",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-alias", "/model-required-alias"],
)
def test_required_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Alias", "type": "string"},
- "name": "p_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Alias", "type": "string"},
+ "name": "p_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-validation-alias", "/model-required-validation-alias"],
)
def test_required_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_required_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "header",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "header",
+ }
+ ]
+ )
@pytest.mark.parametrize(
import pytest
from fastapi import FastAPI, Path
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
],
)
def test_schema(path: str, expected_name: str, expected_title: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": expected_title, "type": "string"},
- "name": expected_name,
- "in": "path",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": expected_title, "type": "string"},
+ "name": expected_name,
+ "in": "path",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from dirty_equals import IsOneOf
from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/required-list-str", "/model-required-list-str"],
)
def test_required_list_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-list-alias", "/model-required-list-alias"],
)
def test_required_list_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-list-validation-alias", "/model-required-list-validation-alias"],
)
def test_required_list_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Val Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Val Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_required_list_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {
- "title": "P Val Alias",
- "type": "array",
- "items": {"type": "string"},
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {
+ "title": "P Val Alias",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
import pytest
from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/optional-list-str", "/model-optional-list-str"],
)
def test_optional_list_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P",
- },
- "name": "p",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P",
+ },
+ "name": "p",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-list-alias", "/model-optional-list-alias"],
)
def test_optional_list_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Alias",
- },
- "name": "p_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Alias",
+ },
+ "name": "p_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
)
def test_optional_list_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_optional_list_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"items": {"type": "string"}, "type": "array"},
- {"type": "null"},
- ],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"items": {"type": "string"}, "type": "array"},
+ {"type": "null"},
+ ],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
import pytest
from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/optional-str", "/model-optional-str"],
)
def test_optional_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P",
- },
- "name": "p",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P",
+ },
+ "name": "p",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-alias", "/model-optional-alias"],
)
def test_optional_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Alias",
- },
- "name": "p_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Alias",
+ },
+ "name": "p_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/optional-validation-alias", "/model-optional-validation-alias"],
)
def test_optional_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_optional_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "P Val Alias",
- },
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "P Val Alias",
+ },
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from dirty_equals import IsOneOf
from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, Field
app = FastAPI()
["/required-str", "/model-required-str"],
)
def test_required_str_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P", "type": "string"},
- "name": "p",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P", "type": "string"},
+ "name": "p",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-alias", "/model-required-alias"],
)
def test_required_str_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Alias", "type": "string"},
- "name": "p_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Alias", "type": "string"},
+ "name": "p_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
["/required-validation-alias", "/model-required-validation-alias"],
)
def test_required_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
],
)
def test_required_alias_and_validation_alias_schema(path: str):
- assert app.openapi()["paths"][path]["get"]["parameters"] == [
- {
- "required": True,
- "schema": {"title": "P Val Alias", "type": "string"},
- "name": "p_val_alias",
- "in": "query",
- }
- ]
+ assert app.openapi()["paths"][path]["get"]["parameters"] == snapshot(
+ [
+ {
+ "required": True,
+ "schema": {"title": "P Val Alias", "type": "string"},
+ "name": "p_val_alias",
+ "in": "query",
+ }
+ ]
+ )
@pytest.mark.parametrize(
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict, Field
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/dict": {
- "get": {
- "summary": "Read Dict",
- "operationId": "read_dict_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model"}
- }
- },
- }
- },
- }
- },
- "/model": {
- "get": {
- "summary": "Read Model",
- "operationId": "read_model_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model"}
- }
- },
- }
- },
- }
- },
- "/list": {
- "get": {
- "summary": "Read List",
- "operationId": "read_list_list_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Read List List Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Model"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/dict": {
+ "get": {
+ "summary": "Read Dict",
+ "operationId": "read_dict_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Model"}
}
- }
- },
- }
- },
- }
- },
- "/by-alias/dict": {
- "get": {
- "summary": "By Alias Dict",
- "operationId": "by_alias_dict_by_alias_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model"}
- }
- },
- }
- },
- }
- },
- "/by-alias/model": {
- "get": {
- "summary": "By Alias Model",
- "operationId": "by_alias_model_by_alias_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model"}
- }
- },
- }
- },
- }
- },
- "/by-alias/list": {
- "get": {
- "summary": "By Alias List",
- "operationId": "by_alias_list_by_alias_list_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response By Alias List By Alias List Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Model"},
+ },
+ }
+ },
+ }
+ },
+ "/model": {
+ "get": {
+ "summary": "Read Model",
+ "operationId": "read_model_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Model"}
}
- }
- },
- }
- },
- }
- },
- "/no-alias/dict": {
- "get": {
- "summary": "No Alias Dict",
- "operationId": "no_alias_dict_no_alias_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ModelNoAlias"
+ },
+ }
+ },
+ }
+ },
+ "/list": {
+ "get": {
+ "summary": "Read List",
+ "operationId": "read_list_list_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Read List List Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Model"
+ },
+ }
}
- }
- },
- }
- },
- }
- },
- "/no-alias/model": {
- "get": {
- "summary": "No Alias Model",
- "operationId": "no_alias_model_no_alias_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/ModelNoAlias"
+ },
+ }
+ },
+ }
+ },
+ "/by-alias/dict": {
+ "get": {
+ "summary": "By Alias Dict",
+ "operationId": "by_alias_dict_by_alias_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Model"}
}
- }
- },
- }
- },
- }
- },
- "/no-alias/list": {
- "get": {
- "summary": "No Alias List",
- "operationId": "no_alias_list_no_alias_list_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response No Alias List No Alias List Get",
- "type": "array",
- "items": {
+ },
+ }
+ },
+ }
+ },
+ "/by-alias/model": {
+ "get": {
+ "summary": "By Alias Model",
+ "operationId": "by_alias_model_by_alias_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Model"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/by-alias/list": {
+ "get": {
+ "summary": "By Alias List",
+ "operationId": "by_alias_list_by_alias_list_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response By Alias List By Alias List Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Model"
+ },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no-alias/dict": {
+ "get": {
+ "summary": "No Alias Dict",
+ "operationId": "no_alias_dict_no_alias_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ModelNoAlias"
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no-alias/model": {
+ "get": {
+ "summary": "No Alias Model",
+ "operationId": "no_alias_model_no_alias_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
"$ref": "#/components/schemas/ModelNoAlias"
- },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no-alias/list": {
+ "get": {
+ "summary": "No Alias List",
+ "operationId": "no_alias_list_no_alias_list_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response No Alias List No Alias List Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ModelNoAlias"
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ },
+ }
+ },
+ },
+ "components": {
+ "schemas": {
+ "Model": {
+ "title": "Model",
+ "required": ["alias"],
+ "type": "object",
+ "properties": {"alias": {"title": "Alias", "type": "string"}},
+ },
+ "ModelNoAlias": {
+ "title": "ModelNoAlias",
+ "required": ["name"],
+ "type": "object",
+ "properties": {"name": {"title": "Name", "type": "string"}},
+ "description": "response_model_by_alias=False is basically a quick hack, to support proper OpenAPI use another model with the correct field names",
},
}
},
- },
- "components": {
- "schemas": {
- "Model": {
- "title": "Model",
- "required": ["alias"],
- "type": "object",
- "properties": {"alias": {"title": "Alias", "type": "string"}},
- },
- "ModelNoAlias": {
- "title": "ModelNoAlias",
- "required": ["name"],
- "type": "object",
- "properties": {"name": {"title": "Name", "type": "string"}},
- "description": "response_model_by_alias=False is basically a quick hack, to support proper OpenAPI use another model with the correct field names",
- },
- }
- },
- }
+ }
+ )
from fastapi import FastAPI, Response
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a": {
- "get": {
- "responses": {
- "500": {
- "description": "Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/JsonApiError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a": {
+ "get": {
+ "responses": {
+ "500": {
+ "description": "Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/JsonApiError"
+ }
}
- }
+ },
},
+ "200": {"description": "Successful Response"},
},
- "200": {"description": "Successful Response"},
- },
- "summary": "A",
- "operationId": "a_a_get",
- }
- },
- "/b": {
- "get": {
- "responses": {
- "500": {
- "description": "Error",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Error"}
- }
+ "summary": "A",
+ "operationId": "a_a_get",
+ }
+ },
+ "/b": {
+ "get": {
+ "responses": {
+ "500": {
+ "description": "Error",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Error"}
+ }
+ },
+ },
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "summary": "B",
+ "operationId": "b_b_get",
+ }
+ },
+ },
+ "components": {
+ "schemas": {
+ "Error": {
+ "title": "Error",
+ "required": ["status", "title"],
+ "type": "object",
+ "properties": {
+ "status": {"title": "Status", "type": "string"},
+ "title": {"title": "Title", "type": "string"},
+ },
+ },
+ "JsonApiError": {
+ "title": "JsonApiError",
+ "required": ["errors"],
+ "type": "object",
+ "properties": {
+ "errors": {
+ "title": "Errors",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Error"},
+ }
},
},
- "summary": "B",
- "operationId": "b_b_get",
}
},
- },
- "components": {
- "schemas": {
- "Error": {
- "title": "Error",
- "required": ["status", "title"],
- "type": "object",
- "properties": {
- "status": {"title": "Status", "type": "string"},
- "title": {"title": "Title", "type": "string"},
- },
- },
- "JsonApiError": {
- "title": "JsonApiError",
- "required": ["errors"],
- "type": "object",
- "properties": {
- "errors": {
- "title": "Errors",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Error"},
- }
- },
- },
- }
- },
- }
+ }
+ )
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/a": {
- "get": {
- "responses": {
- "500": {
- "description": "Error",
- "content": {
- "application/vnd.api+json": {
- "schema": {
- "$ref": "#/components/schemas/JsonApiError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/a": {
+ "get": {
+ "responses": {
+ "500": {
+ "description": "Error",
+ "content": {
+ "application/vnd.api+json": {
+ "schema": {
+ "$ref": "#/components/schemas/JsonApiError"
+ }
}
- }
+ },
},
+ "204": {"description": "Successful Response"},
},
- "204": {"description": "Successful Response"},
- },
- "summary": "A",
- "operationId": "a_a_get",
- }
+ "summary": "A",
+ "operationId": "a_a_get",
+ }
+ },
+ "/b": {
+ "get": {
+ "responses": {
+ "204": {"description": "No Content"},
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ },
+ "summary": "B",
+ "operationId": "b_b_get",
+ }
+ },
},
- "/b": {
- "get": {
- "responses": {
- "204": {"description": "No Content"},
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "components": {
+ "schemas": {
+ "Error": {
+ "title": "Error",
+ "required": ["status", "title"],
+ "type": "object",
+ "properties": {
+ "status": {"title": "Status", "type": "string"},
+ "title": {"title": "Title", "type": "string"},
+ },
+ },
+ "JsonApiError": {
+ "title": "JsonApiError",
+ "required": ["errors"],
+ "type": "object",
+ "properties": {
+ "errors": {
+ "title": "Errors",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Error"},
+ }
},
},
- "summary": "B",
- "operationId": "b_b_get",
}
},
- },
- "components": {
- "schemas": {
- "Error": {
- "title": "Error",
- "required": ["status", "title"],
- "type": "object",
- "properties": {
- "status": {"title": "Status", "type": "string"},
- "title": {"title": "Title", "type": "string"},
- },
- },
- "JsonApiError": {
- "title": "JsonApiError",
- "required": ["errors"],
- "type": "object",
- "properties": {
- "errors": {
- "title": "Errors",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Error"},
- }
- },
- },
- }
- },
- }
+ }
+ )
from fastapi.exceptions import FastAPIError, ResponseValidationError
from fastapi.responses import JSONResponse, Response
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/no_response_model-no_annotation-return_model": {
- "get": {
- "summary": "No Response Model No Annotation Return Model",
- "operationId": "no_response_model_no_annotation_return_model_no_response_model_no_annotation_return_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/no_response_model-no_annotation-return_dict": {
- "get": {
- "summary": "No Response Model No Annotation Return Dict",
- "operationId": "no_response_model_no_annotation_return_dict_no_response_model_no_annotation_return_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model-no_annotation-return_same_model": {
- "get": {
- "summary": "Response Model No Annotation Return Same Model",
- "operationId": "response_model_no_annotation_return_same_model_response_model_no_annotation_return_same_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model-no_annotation-return_exact_dict": {
- "get": {
- "summary": "Response Model No Annotation Return Exact Dict",
- "operationId": "response_model_no_annotation_return_exact_dict_response_model_no_annotation_return_exact_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model-no_annotation-return_invalid_dict": {
- "get": {
- "summary": "Response Model No Annotation Return Invalid Dict",
- "operationId": "response_model_no_annotation_return_invalid_dict_response_model_no_annotation_return_invalid_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model-no_annotation-return_invalid_model": {
- "get": {
- "summary": "Response Model No Annotation Return Invalid Model",
- "operationId": "response_model_no_annotation_return_invalid_model_response_model_no_annotation_return_invalid_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model-no_annotation-return_dict_with_extra_data": {
- "get": {
- "summary": "Response Model No Annotation Return Dict With Extra Data",
- "operationId": "response_model_no_annotation_return_dict_with_extra_data_response_model_no_annotation_return_dict_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model-no_annotation-return_submodel_with_extra_data": {
- "get": {
- "summary": "Response Model No Annotation Return Submodel With Extra Data",
- "operationId": "response_model_no_annotation_return_submodel_with_extra_data_response_model_no_annotation_return_submodel_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_same_model": {
- "get": {
- "summary": "No Response Model Annotation Return Same Model",
- "operationId": "no_response_model_annotation_return_same_model_no_response_model_annotation_return_same_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_exact_dict": {
- "get": {
- "summary": "No Response Model Annotation Return Exact Dict",
- "operationId": "no_response_model_annotation_return_exact_dict_no_response_model_annotation_return_exact_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_invalid_dict": {
- "get": {
- "summary": "No Response Model Annotation Return Invalid Dict",
- "operationId": "no_response_model_annotation_return_invalid_dict_no_response_model_annotation_return_invalid_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_invalid_model": {
- "get": {
- "summary": "No Response Model Annotation Return Invalid Model",
- "operationId": "no_response_model_annotation_return_invalid_model_no_response_model_annotation_return_invalid_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_dict_with_extra_data": {
- "get": {
- "summary": "No Response Model Annotation Return Dict With Extra Data",
- "operationId": "no_response_model_annotation_return_dict_with_extra_data_no_response_model_annotation_return_dict_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation-return_submodel_with_extra_data": {
- "get": {
- "summary": "No Response Model Annotation Return Submodel With Extra Data",
- "operationId": "no_response_model_annotation_return_submodel_with_extra_data_no_response_model_annotation_return_submodel_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_none-annotation-return_same_model": {
- "get": {
- "summary": "Response Model None Annotation Return Same Model",
- "operationId": "response_model_none_annotation_return_same_model_response_model_none_annotation_return_same_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_none-annotation-return_exact_dict": {
- "get": {
- "summary": "Response Model None Annotation Return Exact Dict",
- "operationId": "response_model_none_annotation_return_exact_dict_response_model_none_annotation_return_exact_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_none-annotation-return_invalid_dict": {
- "get": {
- "summary": "Response Model None Annotation Return Invalid Dict",
- "operationId": "response_model_none_annotation_return_invalid_dict_response_model_none_annotation_return_invalid_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_none-annotation-return_invalid_model": {
- "get": {
- "summary": "Response Model None Annotation Return Invalid Model",
- "operationId": "response_model_none_annotation_return_invalid_model_response_model_none_annotation_return_invalid_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_none-annotation-return_dict_with_extra_data": {
- "get": {
- "summary": "Response Model None Annotation Return Dict With Extra Data",
- "operationId": "response_model_none_annotation_return_dict_with_extra_data_response_model_none_annotation_return_dict_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_none-annotation-return_submodel_with_extra_data": {
- "get": {
- "summary": "Response Model None Annotation Return Submodel With Extra Data",
- "operationId": "response_model_none_annotation_return_submodel_with_extra_data_response_model_none_annotation_return_submodel_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_same_model": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Same Model",
- "operationId": "response_model_model1_annotation_model2_return_same_model_response_model_model1_annotation_model2_return_same_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_exact_dict": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Exact Dict",
- "operationId": "response_model_model1_annotation_model2_return_exact_dict_response_model_model1_annotation_model2_return_exact_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_invalid_dict": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Invalid Dict",
- "operationId": "response_model_model1_annotation_model2_return_invalid_dict_response_model_model1_annotation_model2_return_invalid_dict_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_invalid_model": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Invalid Model",
- "operationId": "response_model_model1_annotation_model2_return_invalid_model_response_model_model1_annotation_model2_return_invalid_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_dict_with_extra_data": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Dict With Extra Data",
- "operationId": "response_model_model1_annotation_model2_return_dict_with_extra_data_response_model_model1_annotation_model2_return_dict_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_model1-annotation_model2-return_submodel_with_extra_data": {
- "get": {
- "summary": "Response Model Model1 Annotation Model2 Return Submodel With Extra Data",
- "operationId": "response_model_model1_annotation_model2_return_submodel_with_extra_data_response_model_model1_annotation_model2_return_submodel_with_extra_data_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_filtering_model-annotation_submodel-return_submodel": {
- "get": {
- "summary": "Response Model Filtering Model Annotation Submodel Return Submodel",
- "operationId": "response_model_filtering_model_annotation_submodel_return_submodel_response_model_filtering_model_annotation_submodel_return_submodel_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- }
- },
- }
- },
- "/response_model_list_of_model-no_annotation": {
- "get": {
- "summary": "Response Model List Of Model No Annotation",
- "operationId": "response_model_list_of_model_no_annotation_response_model_list_of_model_no_annotation_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Response Model List Of Model No Annotation Response Model List Of Model No Annotation Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/User"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/no_response_model-no_annotation-return_model": {
+ "get": {
+ "summary": "No Response Model No Annotation Return Model",
+ "operationId": "no_response_model_no_annotation_return_model_no_response_model_no_annotation_return_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/no_response_model-no_annotation-return_dict": {
+ "get": {
+ "summary": "No Response Model No Annotation Return Dict",
+ "operationId": "no_response_model_no_annotation_return_dict_no_response_model_no_annotation_return_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_same_model": {
+ "get": {
+ "summary": "Response Model No Annotation Return Same Model",
+ "operationId": "response_model_no_annotation_return_same_model_response_model_no_annotation_return_same_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation_list_of_model": {
- "get": {
- "summary": "No Response Model Annotation List Of Model",
- "operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/User"},
+ },
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_exact_dict": {
+ "get": {
+ "summary": "Response Model No Annotation Return Exact Dict",
+ "operationId": "response_model_no_annotation_return_exact_dict_response_model_no_annotation_return_exact_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation_forward_ref_list_of_model": {
- "get": {
- "summary": "No Response Model Annotation Forward Ref List Of Model",
- "operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/User"},
+ },
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_invalid_dict": {
+ "get": {
+ "summary": "Response Model No Annotation Return Invalid Dict",
+ "operationId": "response_model_no_annotation_return_invalid_dict_response_model_no_annotation_return_invalid_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/response_model_union-no_annotation-return_model1": {
- "get": {
- "summary": "Response Model Union No Annotation Return Model1",
- "operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get",
- "anyOf": [
- {"$ref": "#/components/schemas/User"},
- {"$ref": "#/components/schemas/Item"},
- ],
+ },
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_invalid_model": {
+ "get": {
+ "summary": "Response Model No Annotation Return Invalid Model",
+ "operationId": "response_model_no_annotation_return_invalid_model_response_model_no_annotation_return_invalid_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/response_model_union-no_annotation-return_model2": {
- "get": {
- "summary": "Response Model Union No Annotation Return Model2",
- "operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get",
- "anyOf": [
- {"$ref": "#/components/schemas/User"},
- {"$ref": "#/components/schemas/Item"},
- ],
+ },
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_dict_with_extra_data": {
+ "get": {
+ "summary": "Response Model No Annotation Return Dict With Extra Data",
+ "operationId": "response_model_no_annotation_return_dict_with_extra_data_response_model_no_annotation_return_dict_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation_union-return_model1": {
- "get": {
- "summary": "No Response Model Annotation Union Return Model1",
- "operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get",
- "anyOf": [
- {"$ref": "#/components/schemas/User"},
- {"$ref": "#/components/schemas/Item"},
- ],
+ },
+ }
+ },
+ }
+ },
+ "/response_model-no_annotation-return_submodel_with_extra_data": {
+ "get": {
+ "summary": "Response Model No Annotation Return Submodel With Extra Data",
+ "operationId": "response_model_no_annotation_return_submodel_with_extra_data_response_model_no_annotation_return_submodel_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
- },
- "/no_response_model-annotation_union-return_model2": {
- "get": {
- "summary": "No Response Model Annotation Union Return Model2",
- "operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get",
- "anyOf": [
- {"$ref": "#/components/schemas/User"},
- {"$ref": "#/components/schemas/Item"},
- ],
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_same_model": {
+ "get": {
+ "summary": "No Response Model Annotation Return Same Model",
+ "operationId": "no_response_model_annotation_return_same_model_no_response_model_annotation_return_same_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
}
- }
- },
- }
- },
- }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_exact_dict": {
+ "get": {
+ "summary": "No Response Model Annotation Return Exact Dict",
+ "operationId": "no_response_model_annotation_return_exact_dict_no_response_model_annotation_return_exact_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_invalid_dict": {
+ "get": {
+ "summary": "No Response Model Annotation Return Invalid Dict",
+ "operationId": "no_response_model_annotation_return_invalid_dict_no_response_model_annotation_return_invalid_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_invalid_model": {
+ "get": {
+ "summary": "No Response Model Annotation Return Invalid Model",
+ "operationId": "no_response_model_annotation_return_invalid_model_no_response_model_annotation_return_invalid_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_dict_with_extra_data": {
+ "get": {
+ "summary": "No Response Model Annotation Return Dict With Extra Data",
+ "operationId": "no_response_model_annotation_return_dict_with_extra_data_no_response_model_annotation_return_dict_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation-return_submodel_with_extra_data": {
+ "get": {
+ "summary": "No Response Model Annotation Return Submodel With Extra Data",
+ "operationId": "no_response_model_annotation_return_submodel_with_extra_data_no_response_model_annotation_return_submodel_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_same_model": {
+ "get": {
+ "summary": "Response Model None Annotation Return Same Model",
+ "operationId": "response_model_none_annotation_return_same_model_response_model_none_annotation_return_same_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_exact_dict": {
+ "get": {
+ "summary": "Response Model None Annotation Return Exact Dict",
+ "operationId": "response_model_none_annotation_return_exact_dict_response_model_none_annotation_return_exact_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_invalid_dict": {
+ "get": {
+ "summary": "Response Model None Annotation Return Invalid Dict",
+ "operationId": "response_model_none_annotation_return_invalid_dict_response_model_none_annotation_return_invalid_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_invalid_model": {
+ "get": {
+ "summary": "Response Model None Annotation Return Invalid Model",
+ "operationId": "response_model_none_annotation_return_invalid_model_response_model_none_annotation_return_invalid_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_dict_with_extra_data": {
+ "get": {
+ "summary": "Response Model None Annotation Return Dict With Extra Data",
+ "operationId": "response_model_none_annotation_return_dict_with_extra_data_response_model_none_annotation_return_dict_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_none-annotation-return_submodel_with_extra_data": {
+ "get": {
+ "summary": "Response Model None Annotation Return Submodel With Extra Data",
+ "operationId": "response_model_none_annotation_return_submodel_with_extra_data_response_model_none_annotation_return_submodel_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_same_model": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Same Model",
+ "operationId": "response_model_model1_annotation_model2_return_same_model_response_model_model1_annotation_model2_return_same_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_exact_dict": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Exact Dict",
+ "operationId": "response_model_model1_annotation_model2_return_exact_dict_response_model_model1_annotation_model2_return_exact_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_invalid_dict": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Invalid Dict",
+ "operationId": "response_model_model1_annotation_model2_return_invalid_dict_response_model_model1_annotation_model2_return_invalid_dict_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_invalid_model": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Invalid Model",
+ "operationId": "response_model_model1_annotation_model2_return_invalid_model_response_model_model1_annotation_model2_return_invalid_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_dict_with_extra_data": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Dict With Extra Data",
+ "operationId": "response_model_model1_annotation_model2_return_dict_with_extra_data_response_model_model1_annotation_model2_return_dict_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_model1-annotation_model2-return_submodel_with_extra_data": {
+ "get": {
+ "summary": "Response Model Model1 Annotation Model2 Return Submodel With Extra Data",
+ "operationId": "response_model_model1_annotation_model2_return_submodel_with_extra_data_response_model_model1_annotation_model2_return_submodel_with_extra_data_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_filtering_model-annotation_submodel-return_submodel": {
+ "get": {
+ "summary": "Response Model Filtering Model Annotation Submodel Return Submodel",
+ "operationId": "response_model_filtering_model_annotation_submodel_return_submodel_response_model_filtering_model_annotation_submodel_return_submodel_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_list_of_model-no_annotation": {
+ "get": {
+ "summary": "Response Model List Of Model No Annotation",
+ "operationId": "response_model_list_of_model_no_annotation_response_model_list_of_model_no_annotation_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Response Model List Of Model No Annotation Response Model List Of Model No Annotation Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/User"
+ },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_list_of_model": {
+ "get": {
+ "summary": "No Response Model Annotation List Of Model",
+ "operationId": "no_response_model_annotation_list_of_model_no_response_model_annotation_list_of_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response No Response Model Annotation List Of Model No Response Model Annotation List Of Model Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/User"
+ },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_forward_ref_list_of_model": {
+ "get": {
+ "summary": "No Response Model Annotation Forward Ref List Of Model",
+ "operationId": "no_response_model_annotation_forward_ref_list_of_model_no_response_model_annotation_forward_ref_list_of_model_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response No Response Model Annotation Forward Ref List Of Model No Response Model Annotation Forward Ref List Of Model Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/User"
+ },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_union-no_annotation-return_model1": {
+ "get": {
+ "summary": "Response Model Union No Annotation Return Model1",
+ "operationId": "response_model_union_no_annotation_return_model1_response_model_union_no_annotation_return_model1_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Response Model Union No Annotation Return Model1 Response Model Union No Annotation Return Model1 Get",
+ "anyOf": [
+ {"$ref": "#/components/schemas/User"},
+ {"$ref": "#/components/schemas/Item"},
+ ],
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/response_model_union-no_annotation-return_model2": {
+ "get": {
+ "summary": "Response Model Union No Annotation Return Model2",
+ "operationId": "response_model_union_no_annotation_return_model2_response_model_union_no_annotation_return_model2_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Response Model Union No Annotation Return Model2 Response Model Union No Annotation Return Model2 Get",
+ "anyOf": [
+ {"$ref": "#/components/schemas/User"},
+ {"$ref": "#/components/schemas/Item"},
+ ],
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_union-return_model1": {
+ "get": {
+ "summary": "No Response Model Annotation Union Return Model1",
+ "operationId": "no_response_model_annotation_union_return_model1_no_response_model_annotation_union_return_model1_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response No Response Model Annotation Union Return Model1 No Response Model Annotation Union Return Model1 Get",
+ "anyOf": [
+ {"$ref": "#/components/schemas/User"},
+ {"$ref": "#/components/schemas/Item"},
+ ],
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_union-return_model2": {
+ "get": {
+ "summary": "No Response Model Annotation Union Return Model2",
+ "operationId": "no_response_model_annotation_union_return_model2_no_response_model_annotation_union_return_model2_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response No Response Model Annotation Union Return Model2 No Response Model Annotation Union Return Model2 Get",
+ "anyOf": [
+ {"$ref": "#/components/schemas/User"},
+ {"$ref": "#/components/schemas/Item"},
+ ],
+ }
+ }
+ },
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_response_class": {
+ "get": {
+ "summary": "No Response Model Annotation Response Class",
+ "operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/no_response_model-annotation_json_response_class": {
+ "get": {
+ "summary": "No Response Model Annotation Json Response Class",
+ "operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
},
- "/no_response_model-annotation_response_class": {
- "get": {
- "summary": "No Response Model Annotation Response Class",
- "operationId": "no_response_model_annotation_response_class_no_response_model_annotation_response_class_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- }
- },
- "/no_response_model-annotation_json_response_class": {
- "get": {
- "summary": "No Response Model Annotation Json Response Class",
- "operationId": "no_response_model_annotation_json_response_class_no_response_model_annotation_json_response_class_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
+ "User": {
+ "title": "User",
+ "required": ["name", "surname"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "surname": {"title": "Surname", "type": "string"},
+ },
},
}
},
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- },
- },
- "User": {
- "title": "User",
- "required": ["name", "surname"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "surname": {"title": "Surname", "type": "string"},
- },
- },
- }
- },
- }
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/valid1": {
- "get": {
- "summary": "Valid1",
- "operationId": "valid1_valid1_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 500 Valid1 Valid1 Get",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/valid1": {
+ "get": {
+ "summary": "Valid1",
+ "operationId": "valid1_valid1_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 500 Valid1 Valid1 Get",
+ "type": "integer",
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/valid2": {
- "get": {
- "summary": "Valid2",
- "operationId": "valid2_valid2_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 500 Valid2 Valid2 Get",
- "type": "array",
- "items": {"type": "integer"},
+ }
+ },
+ "/valid2": {
+ "get": {
+ "summary": "Valid2",
+ "operationId": "valid2_valid2_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 500 Valid2 Valid2 Get",
+ "type": "array",
+ "items": {"type": "integer"},
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/valid3": {
- "get": {
- "summary": "Valid3",
- "operationId": "valid3_valid3_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Model"}
- }
+ }
+ },
+ "/valid3": {
+ "get": {
+ "summary": "Valid3",
+ "operationId": "valid3_valid3_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Model"}
+ }
+ },
},
},
- },
- }
- },
- "/valid4": {
- "get": {
- "summary": "Valid4",
- "operationId": "valid4_valid4_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "500": {
- "description": "Internal Server Error",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response 500 Valid4 Valid4 Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Model"},
+ }
+ },
+ "/valid4": {
+ "get": {
+ "summary": "Valid4",
+ "operationId": "valid4_valid4_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response 500 Valid4 Valid4 Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Model"
+ },
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Model": {
- "title": "Model",
- "required": ["name"],
- "type": "object",
- "properties": {"name": {"title": "Name", "type": "string"}},
+ "components": {
+ "schemas": {
+ "Model": {
+ "title": "Model",
+ "required": ["name"],
+ "type": "object",
+ "properties": {"name": {"title": "Name", "type": "string"}},
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Body, Cookie, FastAPI, Header, Path, Query
from fastapi.exceptions import FastAPIDeprecationWarning
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict
client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/schema_extra/": {
- "post": {
- "summary": "Schema Extra",
- "operationId": "schema_extra_schema_extra__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/schema_extra/": {
+ "post": {
+ "summary": "Schema Extra",
+ "operationId": "schema_extra_schema_extra__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- }
- },
- "/example/": {
- "post": {
- "summary": "Example",
- "operationId": "example_example__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"},
- "example": {"data": "Data in Body example"},
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/examples/": {
- "post": {
- "summary": "Examples",
- "operationId": "examples_examples__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- "examples": [
- {"data": "Data in Body examples, example1"},
- {"data": "Data in Body examples, example2"},
- ],
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/example/": {
+ "post": {
+ "summary": "Example",
+ "operationId": "example_example__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"},
+ "example": {"data": "Data in Body example"},
}
},
+ "required": True,
},
- },
- }
- },
- "/example_examples/": {
- "post": {
- "summary": "Example Examples",
- "operationId": "example_examples_example_examples__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- "examples": [
- {"data": "examples example_examples 1"},
- {"data": "examples example_examples 2"},
- ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
},
- "example": {"data": "Overridden example"},
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/examples/": {
+ "post": {
+ "summary": "Examples",
+ "operationId": "examples_examples__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
+ "examples": [
+ {"data": "Data in Body examples, example1"},
+ {"data": "Data in Body examples, example2"},
+ ],
}
}
},
- },
- },
- }
- },
- "/path_example/{item_id}": {
- "get": {
- "summary": "Path Example",
- "operationId": "path_example_path_example__item_id__get",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "example": "item_1",
- "name": "item_id",
- "in": "path",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/path_examples/{item_id}": {
- "get": {
- "summary": "Path Examples",
- "operationId": "path_examples_path_examples__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "string",
- "examples": ["item_1", "item_2"],
- },
- "name": "item_id",
- "in": "path",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/example_examples/": {
+ "post": {
+ "summary": "Example Examples",
+ "operationId": "example_examples_example_examples__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "$ref": "#/components/schemas/Item",
+ "examples": [
+ {"data": "examples example_examples 1"},
+ {"data": "examples example_examples 2"},
+ ],
+ },
+ "example": {"data": "Overridden example"},
}
},
- },
- },
- }
- },
- "/path_example_examples/{item_id}": {
- "get": {
- "summary": "Path Example Examples",
- "operationId": "path_example_examples_path_example_examples__item_id__get",
- "parameters": [
- {
"required": True,
- "schema": {
- "title": "Item Id",
- "type": "string",
- "examples": ["item_1", "item_2"],
- },
- "example": "item_overridden",
- "name": "item_id",
- "in": "path",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query_example/": {
- "get": {
- "summary": "Query Example",
- "operationId": "query_example_query_example__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- },
- "example": "query1",
- "name": "data",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/path_example/{item_id}": {
+ "get": {
+ "summary": "Path Example",
+ "operationId": "path_example_path_example__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "example": "item_1",
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query_examples/": {
- "get": {
- "summary": "Query Examples",
- "operationId": "query_examples_query_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["query1", "query2"],
- },
- "name": "data",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/path_examples/{item_id}": {
+ "get": {
+ "summary": "Path Examples",
+ "operationId": "path_examples_path_examples__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "string",
+ "examples": ["item_1", "item_2"],
+ },
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/query_example_examples/": {
- "get": {
- "summary": "Query Example Examples",
- "operationId": "query_example_examples_query_example_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["query1", "query2"],
- },
- "example": "query_overridden",
- "name": "data",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/path_example_examples/{item_id}": {
+ "get": {
+ "summary": "Path Example Examples",
+ "operationId": "path_example_examples_path_example_examples__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "string",
+ "examples": ["item_1", "item_2"],
+ },
+ "example": "item_overridden",
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/header_example/": {
- "get": {
- "summary": "Header Example",
- "operationId": "header_example_header_example__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- },
- "example": "header1",
- "name": "data",
- "in": "header",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/query_example/": {
+ "get": {
+ "summary": "Query Example",
+ "operationId": "query_example_query_example__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ },
+ "example": "query1",
+ "name": "data",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/header_examples/": {
- "get": {
- "summary": "Header Examples",
- "operationId": "header_examples_header_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["header1", "header2"],
- },
- "name": "data",
- "in": "header",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/query_examples/": {
+ "get": {
+ "summary": "Query Examples",
+ "operationId": "query_examples_query_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["query1", "query2"],
+ },
+ "name": "data",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/header_example_examples/": {
- "get": {
- "summary": "Header Example Examples",
- "operationId": "header_example_examples_header_example_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["header1", "header2"],
- },
- "example": "header_overridden",
- "name": "data",
- "in": "header",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/query_example_examples/": {
+ "get": {
+ "summary": "Query Example Examples",
+ "operationId": "query_example_examples_query_example_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["query1", "query2"],
+ },
+ "example": "query_overridden",
+ "name": "data",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/cookie_example/": {
- "get": {
- "summary": "Cookie Example",
- "operationId": "cookie_example_cookie_example__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- },
- "example": "cookie1",
- "name": "data",
- "in": "cookie",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/header_example/": {
+ "get": {
+ "summary": "Header Example",
+ "operationId": "header_example_header_example__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ },
+ "example": "header1",
+ "name": "data",
+ "in": "header",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/header_examples/": {
+ "get": {
+ "summary": "Header Examples",
+ "operationId": "header_examples_header_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["header1", "header2"],
+ },
+ "name": "data",
+ "in": "header",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/cookie_examples/": {
- "get": {
- "summary": "Cookie Examples",
- "operationId": "cookie_examples_cookie_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["cookie1", "cookie2"],
- },
- "name": "data",
- "in": "cookie",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/header_example_examples/": {
+ "get": {
+ "summary": "Header Example Examples",
+ "operationId": "header_example_examples_header_example_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["header1", "header2"],
+ },
+ "example": "header_overridden",
+ "name": "data",
+ "in": "header",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/cookie_example/": {
+ "get": {
+ "summary": "Cookie Example",
+ "operationId": "cookie_example_cookie_example__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ },
+ "example": "cookie1",
+ "name": "data",
+ "in": "cookie",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/cookie_example_examples/": {
- "get": {
- "summary": "Cookie Example Examples",
- "operationId": "cookie_example_examples_cookie_example_examples__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Data",
- "examples": ["cookie1", "cookie2"],
- },
- "example": "cookie_overridden",
- "name": "data",
- "in": "cookie",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/cookie_examples/": {
+ "get": {
+ "summary": "Cookie Examples",
+ "operationId": "cookie_examples_cookie_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["cookie1", "cookie2"],
+ },
+ "name": "data",
+ "in": "cookie",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/cookie_example_examples/": {
+ "get": {
+ "summary": "Cookie Example Examples",
+ "operationId": "cookie_example_examples_cookie_example_examples__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Data",
+ "examples": ["cookie1", "cookie2"],
+ },
+ "example": "cookie_overridden",
+ "name": "data",
+ "in": "cookie",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["data"],
- "type": "object",
- "properties": {"data": {"title": "Data", "type": "string"}},
- "example": {"data": "Data in schema_extra"},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "Item": {
+ "title": "Item",
+ "required": ["data"],
+ "type": "object",
+ "properties": {"data": {"title": "Data", "type": "string"}},
+ "example": {"data": "Data in schema_extra"},
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyCookie
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyCookie": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyCookie": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyCookie
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyCookie": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyCookie": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyCookie": {
- "type": "apiKey",
- "name": "key",
- "in": "cookie",
- "description": "An API Cookie Key",
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyCookie": {
+ "type": "apiKey",
+ "name": "key",
+ "in": "cookie",
+ "description": "An API Cookie Key",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyCookie
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
client = TestClient(app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyCookie": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyCookie": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyCookie": {"type": "apiKey", "name": "key", "in": "cookie"}
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyHeader
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyHeader": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyHeader": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyHeader
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyHeader": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyHeader": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyHeader": {
- "type": "apiKey",
- "name": "key",
- "in": "header",
- "description": "An API Key Header",
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyHeader": {
+ "type": "apiKey",
+ "name": "key",
+ "in": "header",
+ "description": "An API Key Header",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyHeader
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyHeader": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyHeader": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyHeader": {"type": "apiKey", "name": "key", "in": "header"}
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyQuery
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyQuery": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyQuery": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
+ }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyQuery
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyQuery": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyQuery": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyQuery": {
- "type": "apiKey",
- "name": "key",
- "in": "query",
- "description": "API Key Query",
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyQuery": {
+ "type": "apiKey",
+ "name": "key",
+ "in": "query",
+ "description": "API Key Query",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import APIKeyQuery
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"APIKeyQuery": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"APIKeyQuery": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
- }
- },
- }
+ },
+ "components": {
+ "securitySchemes": {
+ "APIKeyQuery": {"type": "apiKey", "name": "key", "in": "query"}
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBase
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBase": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBase": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBase
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBase": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBase": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "HTTPBase": {
- "type": "http",
- "scheme": "Other",
- "description": "Other Security Scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "HTTPBase": {
+ "type": "http",
+ "scheme": "Other",
+ "description": "Other Security Scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBase
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBase": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBase": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBase": {"type": "http", "scheme": "Other"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBasic": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBasic": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBasic": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBasic": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBasic": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBasic": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "HTTPBasic": {
- "type": "http",
- "scheme": "basic",
- "description": "HTTPBasic scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "HTTPBasic": {
+ "type": "http",
+ "scheme": "basic",
+ "description": "HTTPBasic scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "HTTPBearer": {
- "type": "http",
- "scheme": "bearer",
- "description": "HTTP Bearer token scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "HTTPBearer": {
+ "type": "http",
+ "scheme": "bearer",
+ "description": "HTTP Bearer token scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPDigest": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPDigest": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPDigest": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPDigest": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "HTTPDigest": {
- "type": "http",
- "scheme": "digest",
- "description": "HTTPDigest scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "HTTPDigest": {
+ "type": "http",
+ "scheme": "digest",
+ "description": "HTTPDigest scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPDigest": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPDigest": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPDigest": {"type": "http", "scheme": "digest"}}
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_login_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login_post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_login_post"
- }
+ }
+ },
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- }
- },
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"OAuth2": []}],
- }
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"OAuth2": []}],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_login_login_post": {
- "title": "Body_login_login_post",
- "required": ["grant_type", "username", "password"],
- "type": "object",
- "properties": {
- "grant_type": {
- "title": "Grant Type",
- "pattern": "^password$",
- "type": "string",
- },
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
- "scope": {"title": "Scope", "type": "string", "default": ""},
- "client_id": {
- "title": "Client Id",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "client_secret": {
- "title": "Client Secret",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "components": {
+ "schemas": {
+ "Body_login_login_post": {
+ "title": "Body_login_login_post",
+ "required": ["grant_type", "username", "password"],
+ "type": "object",
+ "properties": {
+ "grant_type": {
+ "title": "Grant Type",
+ "pattern": "^password$",
+ "type": "string",
+ },
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ "scope": {
+ "title": "Scope",
+ "type": "string",
+ "default": "",
+ },
+ "client_id": {
+ "title": "Client Id",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "client_secret": {
+ "title": "Client Secret",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
},
+ "securitySchemes": {
+ "OAuth2": {
+ "type": "oauth2",
+ "flows": {
+ "password": {
+ "scopes": {
+ "read:users": "Read the users",
+ "write:users": "Create users",
+ },
+ "tokenUrl": "token",
+ }
+ },
+ }
+ },
},
- "securitySchemes": {
- "OAuth2": {
- "type": "oauth2",
- "flows": {
- "password": {
- "scopes": {
- "read:users": "Read the users",
- "write:users": "Create users",
- },
- "tokenUrl": "token",
- }
- },
- }
- },
- },
- }
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import OAuth2AuthorizationCodeBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "security": [{"OAuth2AuthorizationCodeBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "security": [{"OAuth2AuthorizationCodeBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2AuthorizationCodeBearer": {
- "type": "oauth2",
- "flows": {
- "authorizationCode": {
- "authorizationUrl": "authorize",
- "tokenUrl": "token",
- "scopes": {},
- }
- },
+ },
+ "components": {
+ "securitySchemes": {
+ "OAuth2AuthorizationCodeBearer": {
+ "type": "oauth2",
+ "flows": {
+ "authorizationCode": {
+ "authorizationUrl": "authorize",
+ "tokenUrl": "token",
+ "scopes": {},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import OAuth2AuthorizationCodeBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "security": [{"OAuth2AuthorizationCodeBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "security": [{"OAuth2AuthorizationCodeBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2AuthorizationCodeBearer": {
- "type": "oauth2",
- "flows": {
- "authorizationCode": {
- "authorizationUrl": "authorize",
- "tokenUrl": "token",
- "scopes": {},
- }
- },
- "description": "OAuth2 Code Bearer",
+ },
+ "components": {
+ "securitySchemes": {
+ "OAuth2AuthorizationCodeBearer": {
+ "type": "oauth2",
+ "flows": {
+ "authorizationCode": {
+ "authorizationUrl": "authorize",
+ "tokenUrl": "token",
+ "scopes": {},
+ }
+ },
+ "description": "OAuth2 Code Bearer",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_login_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login_post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_login_post"
- }
+ }
+ },
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- }
- },
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Users Me",
- "operationId": "read_users_me_users_me_get",
- "security": [{"OAuth2": []}],
- }
+ "summary": "Read Users Me",
+ "operationId": "read_users_me_users_me_get",
+ "security": [{"OAuth2": []}],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_login_login_post": {
- "title": "Body_login_login_post",
- "required": ["grant_type", "username", "password"],
- "type": "object",
- "properties": {
- "grant_type": {
- "title": "Grant Type",
- "pattern": "^password$",
- "type": "string",
- },
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
- "scope": {"title": "Scope", "type": "string", "default": ""},
- "client_id": {
- "title": "Client Id",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "client_secret": {
- "title": "Client Secret",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "components": {
+ "schemas": {
+ "Body_login_login_post": {
+ "title": "Body_login_login_post",
+ "required": ["grant_type", "username", "password"],
+ "type": "object",
+ "properties": {
+ "grant_type": {
+ "title": "Grant Type",
+ "pattern": "^password$",
+ "type": "string",
+ },
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ "scope": {
+ "title": "Scope",
+ "type": "string",
+ "default": "",
+ },
+ "client_id": {
+ "title": "Client Id",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "client_secret": {
+ "title": "Client Secret",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
},
+ "securitySchemes": {
+ "OAuth2": {
+ "type": "oauth2",
+ "flows": {
+ "password": {
+ "scopes": {
+ "read:users": "Read the users",
+ "write:users": "Create users",
+ },
+ "tokenUrl": "token",
+ }
+ },
+ }
+ },
},
- "securitySchemes": {
- "OAuth2": {
- "type": "oauth2",
- "flows": {
- "password": {
- "scopes": {
- "read:users": "Read the users",
- "write:users": "Create users",
- },
- "tokenUrl": "token",
- }
- },
- }
- },
- },
- }
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_login_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login_post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_login_post"
- }
+ }
+ },
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- }
- },
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Users Me",
- "operationId": "read_users_me_users_me_get",
- "security": [{"OAuth2": []}],
- }
+ "summary": "Read Users Me",
+ "operationId": "read_users_me_users_me_get",
+ "security": [{"OAuth2": []}],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_login_login_post": {
- "title": "Body_login_login_post",
- "required": ["grant_type", "username", "password"],
- "type": "object",
- "properties": {
- "grant_type": {
- "title": "Grant Type",
- "pattern": "^password$",
- "type": "string",
- },
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
- "scope": {"title": "Scope", "type": "string", "default": ""},
- "client_id": {
- "title": "Client Id",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "client_secret": {
- "title": "Client Secret",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "components": {
+ "schemas": {
+ "Body_login_login_post": {
+ "title": "Body_login_login_post",
+ "required": ["grant_type", "username", "password"],
+ "type": "object",
+ "properties": {
+ "grant_type": {
+ "title": "Grant Type",
+ "pattern": "^password$",
+ "type": "string",
+ },
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ "scope": {
+ "title": "Scope",
+ "type": "string",
+ "default": "",
+ },
+ "client_id": {
+ "title": "Client Id",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "client_secret": {
+ "title": "Client Secret",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
},
+ "securitySchemes": {
+ "OAuth2": {
+ "type": "oauth2",
+ "flows": {
+ "password": {
+ "scopes": {
+ "read:users": "Read the users",
+ "write:users": "Create users",
+ },
+ "tokenUrl": "token",
+ }
+ },
+ "description": "OAuth2 security scheme",
+ }
+ },
},
- "securitySchemes": {
- "OAuth2": {
- "type": "oauth2",
- "flows": {
- "password": {
- "scopes": {
- "read:users": "Read the users",
- "write:users": "Create users",
- },
- "tokenUrl": "token",
- }
- },
- "description": "OAuth2 security scheme",
- }
- },
- },
- }
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import OAuth2PasswordBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "security": [{"OAuth2PasswordBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
+ },
+ "components": {
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import OAuth2PasswordBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "security": [{"OAuth2PasswordBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
- "description": "OAuth2PasswordBearer security scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {"password": {"scopes": {}, "tokenUrl": "/token"}},
+ "description": "OAuth2PasswordBearer security scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security.open_id_connect_url import OpenIdConnect
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"OpenIdConnect": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"OpenIdConnect": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OpenIdConnect": {
- "type": "openIdConnect",
- "openIdConnectUrl": "/openid",
+ },
+ "components": {
+ "securitySchemes": {
+ "OpenIdConnect": {
+ "type": "openIdConnect",
+ "openIdConnectUrl": "/openid",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security.open_id_connect_url import OpenIdConnect
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"OpenIdConnect": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"OpenIdConnect": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OpenIdConnect": {
- "type": "openIdConnect",
- "openIdConnectUrl": "/openid",
- "description": "OpenIdConnect security scheme",
+ },
+ "components": {
+ "securitySchemes": {
+ "OpenIdConnect": {
+ "type": "openIdConnect",
+ "openIdConnectUrl": "/openid",
+ "description": "OpenIdConnect security scheme",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import Depends, FastAPI, Security
from fastapi.security.open_id_connect_url import OpenIdConnect
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"OpenIdConnect": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"OpenIdConnect": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OpenIdConnect": {
- "type": "openIdConnect",
- "openIdConnectUrl": "/openid",
+ },
+ "components": {
+ "securitySchemes": {
+ "OpenIdConnect": {
+ "type": "openIdConnect",
+ "openIdConnectUrl": "/openid",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi import FastAPI, HTTPException
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from starlette.exceptions import HTTPException as StarletteHTTPException
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/http-no-body-statuscode-exception": {
- "get": {
- "operationId": "no_body_status_code_exception_http_no_body_statuscode_exception_get",
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- }
- },
- "summary": "No Body Status Code Exception",
- }
- },
- "/http-no-body-statuscode-with-detail-exception": {
- "get": {
- "operationId": "no_body_status_code_with_detail_exception_http_no_body_statuscode_with_detail_exception_get",
- "responses": {
- "200": {
- "content": {"application/json": {"schema": {}}},
- "description": "Successful Response",
- }
- },
- "summary": "No Body Status Code With Detail Exception",
- }
- },
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/http-no-body-statuscode-exception": {
+ "get": {
+ "operationId": "no_body_status_code_exception_http_no_body_statuscode_exception_get",
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ }
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "No Body Status Code Exception",
+ }
+ },
+ "/http-no-body-statuscode-with-detail-exception": {
+ "get": {
+ "operationId": "no_body_status_code_with_detail_exception_http_no_body_statuscode_with_detail_exception_get",
+ "responses": {
+ "200": {
+ "content": {"application/json": {"schema": {}}},
+ "description": "Successful Response",
+ }
+ },
+ "summary": "No Body Status Code With Detail Exception",
+ }
+ },
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
- },
- "/starlette-items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
+ "/starlette-items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Starlette Item",
- "operationId": "read_starlette_item_starlette_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- }
+ "summary": "Read Starlette Item",
+ "operationId": "read_starlette_item_starlette_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel, HttpUrl
app = FastAPI()
def test_openapi_schema():
with client:
response = client.get("/openapi.json")
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/invoices/": {
- "post": {
- "summary": "Create Invoice",
- "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n * At this point is that the API will somehow send a POST request to the\n external API with the notification of the invoice event\n (e.g. "payment successful").',
- "operationId": "create_invoice_invoices__post",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Callback Url",
- "anyOf": [
- {
- "type": "string",
- "format": "uri",
- "minLength": 1,
- "maxLength": 2083,
- },
- {"type": "null"},
- ],
- },
- "name": "callback_url",
- "in": "query",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Invoice"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/invoices/": {
+ "post": {
+ "summary": "Create Invoice",
+ "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n * At this point is that the API will somehow send a POST request to the\n external API with the notification of the invoice event\n (e.g. "payment successful").',
+ "operationId": "create_invoice_invoices__post",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Callback Url",
+ "anyOf": [
+ {
+ "type": "string",
+ "format": "uri",
+ "minLength": 1,
+ "maxLength": 2083,
+ },
+ {"type": "null"},
+ ],
+ },
+ "name": "callback_url",
+ "in": "query",
}
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Invoice"
}
}
},
+ "required": True,
},
- },
- "callbacks": {
- "event_callback": {
- "{$callback_url}/events/{$request.body.title}": {
- "get": {
- "summary": "Event Callback",
- "operationId": "event_callback__callback_url__events___request_body_title__get",
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Event"
- }
- }
- },
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {"schema": {}}
- },
- },
- "422": {
- "description": "Validation Error",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ "callbacks": {
+ "event_callback": {
+ "{$callback_url}/events/{$request.body.title}": {
+ "get": {
+ "summary": "Event Callback",
+ "operationId": "event_callback__callback_url__events___request_body_title__get",
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Event"
}
}
},
},
- },
- }
- }
- },
- "invoice_notification": {
- "{$callback_url}/invoices/{$request.body.id}": {
- "post": {
- "summary": "Invoice Notification",
- "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/InvoiceEvent"
- }
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ }
+ }
+ },
+ "invoice_notification": {
+ "{$callback_url}/invoices/{$request.body.id}": {
+ "post": {
+ "summary": "Invoice Notification",
+ "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/InvoiceEventReceived"
+ "$ref": "#/components/schemas/InvoiceEvent"
}
}
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InvoiceEventReceived"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
- }
+ },
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Event": {
- "title": "Event",
- "required": ["name", "total"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "total": {"title": "Total", "type": "number"},
+ },
+ "components": {
+ "schemas": {
+ "Event": {
+ "title": "Event",
+ "required": ["name", "total"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "total": {"title": "Total", "type": "number"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ValidationError"
+ "Invoice": {
+ "title": "Invoice",
+ "required": ["id", "customer", "total"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "title": {
+ "title": "Title",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
},
- }
+ "customer": {"title": "Customer", "type": "string"},
+ "total": {"title": "Total", "type": "number"},
+ },
},
- },
- "Invoice": {
- "title": "Invoice",
- "required": ["id", "customer", "total"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "title": {
- "title": "Title",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "InvoiceEvent": {
+ "title": "InvoiceEvent",
+ "required": ["description", "paid"],
+ "type": "object",
+ "properties": {
+ "description": {
+ "title": "Description",
+ "type": "string",
+ },
+ "paid": {"title": "Paid", "type": "boolean"},
},
- "customer": {"title": "Customer", "type": "string"},
- "total": {"title": "Total", "type": "number"},
},
- },
- "InvoiceEvent": {
- "title": "InvoiceEvent",
- "required": ["description", "paid"],
- "type": "object",
- "properties": {
- "description": {"title": "Description", "type": "string"},
- "paid": {"title": "Paid", "type": "boolean"},
+ "InvoiceEventReceived": {
+ "title": "InvoiceEventReceived",
+ "required": ["ok"],
+ "type": "object",
+ "properties": {"ok": {"title": "Ok", "type": "boolean"}},
},
- },
- "InvoiceEventReceived": {
- "title": "InvoiceEventReceived",
- "required": ["ok"],
- "type": "object",
- "properties": {"ok": {"title": "Ok", "type": "boolean"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "integer"},
+ ]
+ },
},
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
},
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/model-with-tuple/": {
- "post": {
- "summary": "Post Model With Tuple",
- "operationId": "post_model_with_tuple_model_with_tuple__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/ItemGroup"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/model-with-tuple/": {
+ "post": {
+ "summary": "Post Model With Tuple",
+ "operationId": "post_model_with_tuple_model_with_tuple__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/ItemGroup"}
}
},
+ "required": True,
},
- },
- }
- },
- "/tuple-of-models/": {
- "post": {
- "summary": "Post Tuple Of Models",
- "operationId": "post_tuple_of_models_tuple_of_models__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Square",
- "maxItems": 2,
- "minItems": 2,
- "type": "array",
- "prefixItems": [
- {"$ref": "#/components/schemas/Coordinate"},
- {"$ref": "#/components/schemas/Coordinate"},
- ],
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/tuple-of-models/": {
+ "post": {
+ "summary": "Post Tuple Of Models",
+ "operationId": "post_tuple_of_models_tuple_of_models__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Square",
+ "maxItems": 2,
+ "minItems": 2,
+ "type": "array",
+ "prefixItems": [
+ {"$ref": "#/components/schemas/Coordinate"},
+ {"$ref": "#/components/schemas/Coordinate"},
+ ],
}
}
},
+ "required": True,
},
- },
- }
- },
- "/tuple-form/": {
- "post": {
- "summary": "Hello",
- "operationId": "hello_tuple_form__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_hello_tuple_form__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/tuple-form/": {
+ "post": {
+ "summary": "Hello",
+ "operationId": "hello_tuple_form__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_hello_tuple_form__post"
}
}
},
+ "required": True,
},
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_hello_tuple_form__post": {
- "title": "Body_hello_tuple_form__post",
- "required": ["values"],
- "type": "object",
- "properties": {
- "values": {
- "title": "Values",
- "maxItems": 2,
- "minItems": 2,
- "type": "array",
- "prefixItems": [
- {"type": "integer"},
- {"type": "integer"},
- ],
- }
- },
- },
- "Coordinate": {
- "title": "Coordinate",
- "required": ["x", "y"],
- "type": "object",
- "properties": {
- "x": {"title": "X", "type": "number"},
- "y": {"title": "Y", "type": "number"},
- },
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
},
- "ItemGroup": {
- "title": "ItemGroup",
- "required": ["items"],
- "type": "object",
- "properties": {
- "items": {
- "title": "Items",
- "type": "array",
- "items": {
+ },
+ "components": {
+ "schemas": {
+ "Body_hello_tuple_form__post": {
+ "title": "Body_hello_tuple_form__post",
+ "required": ["values"],
+ "type": "object",
+ "properties": {
+ "values": {
+ "title": "Values",
"maxItems": 2,
"minItems": 2,
"type": "array",
"prefixItems": [
- {"type": "string"},
- {"type": "string"},
+ {"type": "integer"},
+ {"type": "integer"},
],
- },
- }
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
+ "Coordinate": {
+ "title": "Coordinate",
+ "required": ["x", "y"],
+ "type": "object",
+ "properties": {
+ "x": {"title": "X", "type": "number"},
+ "y": {"title": "Y", "type": "number"},
+ },
+ },
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
+ },
+ "ItemGroup": {
+ "title": "ItemGroup",
+ "required": ["items"],
+ "type": "object",
+ "properties": {
"items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "title": "Items",
+ "type": "array",
+ "items": {
+ "maxItems": 2,
+ "minItems": 2,
+ "type": "array",
+ "prefixItems": [
+ {"type": "string"},
+ {"type": "string"},
+ ],
+ },
+ }
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.additional_responses.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "404": {
- "description": "Not Found",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Message"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "404": {
+ "description": "Not Found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Message"
+ }
+ }
+ },
},
- },
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["id", "value"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "value": {"title": "Value", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["id", "value"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "value": {"title": "Value", "type": "string"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
},
- },
- "Message": {
- "title": "Message",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from tests.utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Return the JSON item or an image.",
- "content": {
- "image/png": {},
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Return the JSON item or an image.",
+ "content": {
+ "image/png": {},
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ },
},
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "boolean"}, {"type": "null"}],
- "title": "Img",
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "img",
- "in": "query",
- },
- ],
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "boolean"}, {"type": "null"}],
+ "title": "Img",
+ },
+ "name": "img",
+ "in": "query",
+ },
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["id", "value"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "value": {"title": "Value", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["id", "value"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "value": {"title": "Value", "type": "string"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.additional_responses.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "404": {
- "description": "The item was not found",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Message"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "404": {
+ "description": "The item was not found",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Message"
+ }
+ }
+ },
},
- },
- "200": {
- "description": "Item requested by ID",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"},
- "example": {
- "id": "bar",
- "value": "The bar tenders",
- },
- }
+ "200": {
+ "description": "Item requested by ID",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"},
+ "example": {
+ "id": "bar",
+ "value": "The bar tenders",
+ },
+ }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["id", "value"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "value": {"title": "Value", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["id", "value"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "value": {"title": "Value", "type": "string"},
+ },
+ },
+ "Message": {
+ "title": "Message",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
},
- },
- "Message": {
- "title": "Message",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from tests.utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "404": {"description": "Item not found"},
- "302": {"description": "The item was moved"},
- "403": {"description": "Not enough privileges"},
- "200": {
- "description": "Successful Response",
- "content": {
- "image/png": {},
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "404": {"description": "Item not found"},
+ "302": {"description": "The item was moved"},
+ "403": {"description": "Not enough privileges"},
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "image/png": {},
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ },
},
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "boolean"}, {"type": "null"}],
- "title": "Img",
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "img",
- "in": "query",
- },
- ],
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "boolean"}, {"type": "null"}],
+ "title": "Img",
+ },
+ "name": "img",
+ "in": "query",
+ },
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["id", "value"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "value": {"title": "Value", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["id", "value"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "value": {"title": "Value", "type": "string"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.behind_a_proxy.tutorial001_py39 import app
def test_openapi():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/app": {
- "get": {
- "summary": "Read Main",
- "operationId": "read_main_app_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/app": {
+ "get": {
+ "summary": "Read Main",
+ "operationId": "read_main_app_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- "servers": [{"url": "/api/v1"}],
- }
+ },
+ "servers": [{"url": "/api/v1"}],
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.behind_a_proxy.tutorial002_py39 import app
def test_openapi():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/app": {
- "get": {
- "summary": "Read Main",
- "operationId": "read_main_app_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/app": {
+ "get": {
+ "summary": "Read Main",
+ "operationId": "read_main_app_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- "servers": [{"url": "/api/v1"}],
- }
+ },
+ "servers": [{"url": "/api/v1"}],
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/": {
- "get": {
- "tags": ["users"],
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/users/me": {
- "get": {
- "tags": ["users"],
- "summary": "Read User Me",
- "operationId": "read_user_me_users_me_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/users/me": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Read User Me",
+ "operationId": "read_user_me_users_me_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/users/{username}": {
- "get": {
- "tags": ["users"],
- "summary": "Read User",
- "operationId": "read_user_users__username__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Username", "type": "string"},
- "name": "username",
- "in": "path",
- },
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/users/{username}": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Read User",
+ "operationId": "read_user_users__username__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Username", "type": "string"},
+ "name": "username",
+ "in": "path",
+ },
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- },
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "404": {"description": "Not found"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "404": {"description": "Not found"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/items/{item_id}": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ },
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "404": {"description": "Not found"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
},
- }
- },
- "/items/{item_id}": {
- "get": {
- "tags": ["items"],
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- },
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "404": {"description": "Not found"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "put": {
+ "tags": ["items", "custom"],
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ },
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "404": {"description": "Not found"},
+ "403": {"description": "Operation forbidden"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
},
},
- "put": {
- "tags": ["items", "custom"],
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- },
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "404": {"description": "Not found"},
- "403": {"description": "Operation forbidden"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "/admin/": {
+ "post": {
+ "tags": ["admin"],
+ "summary": "Update Admin",
+ "operationId": "update_admin_admin__post",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "418": {"description": "I'm a teapot"},
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
},
- },
- "/admin/": {
- "post": {
- "tags": ["admin"],
- "summary": "Update Admin",
- "operationId": "update_admin_admin__post",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- },
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "418": {"description": "I'm a teapot"},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "/": {
+ "get": {
+ "summary": "Root",
+ "operationId": "root__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Token", "type": "string"},
+ "name": "token",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- "/": {
- "get": {
- "summary": "Root",
- "operationId": "root__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Token", "type": "string"},
- "name": "token",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
- }
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
},
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
+ "input": {"title": "Input"},
+ "ctx": {"title": "Context", "type": "object"},
},
},
}
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
- },
- },
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
- "input": {"title": "Input"},
- "ctx": {"title": "Context", "type": "object"},
- },
- },
- }
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
},
- },
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
- "name": "q",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
}
}
},
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
- }
- }
},
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "The description of the item",
- "anyOf": [
- {"maxLength": 300, "type": "string"},
- {"type": "null"},
- ],
- },
- "price": {
- "title": "Price",
- "exclusiveMinimum": 0.0,
- "type": "number",
- "description": "The price must be greater than zero",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "The description of the item",
+ "anyOf": [
+ {"maxLength": 300, "type": "string"},
+ {"type": "null"},
+ ],
+ },
+ "price": {
+ "title": "Price",
+ "exclusiveMinimum": 0.0,
+ "type": "number",
+ "description": "The price must be greater than zero",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "Body_update_item_items__item_id__put": {
- "title": "Body_update_item_items__item_id__put",
- "required": ["item"],
- "type": "object",
- "properties": {"item": {"$ref": "#/components/schemas/Item"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "Body_update_item_items__item_id__put": {
+ "title": "Body_update_item_items__item_id__put",
+ "required": ["item"],
+ "type": "object",
+ "properties": {"item": {"$ref": "#/components/schemas/Item"}},
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "maximum": 1000.0,
+ "minimum": 0.0,
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
+ },
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ },
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "anyOf": [
+ {"$ref": "#/components/schemas/Item"},
+ {"type": "null"},
+ ],
+ "title": "Item",
}
}
- },
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "maximum": 1000.0,
- "minimum": 0.0,
- "type": "integer",
- },
- "name": "item_id",
- "in": "path",
+ }
},
- {
- "required": False,
- "schema": {
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
"anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
},
- "name": "q",
- "in": "query",
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "anyOf": [
- {"$ref": "#/components/schemas/Item"},
- {"type": "null"},
- ],
- "title": "Item",
- }
- }
- }
- },
- }
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/items/{item_id}": {
- "put": {
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
- },
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
"schema": {
- "$ref": "#/components/schemas/Body_update_item_items__item_id__put",
+ "title": "Item Id",
+ "type": "integer",
},
},
- },
- "required": True,
- },
- "responses": {
- "200": {
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {},
+ "schema": {
+ "$ref": "#/components/schemas/Body_update_item_items__item_id__put",
+ },
},
},
- "description": "Successful Response",
+ "required": True,
},
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
+ },
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Update Item",
},
- "summary": "Update Item",
},
},
- },
- "components": {
- "schemas": {
- "Body_update_item_items__item_id__put": {
- "properties": {
- "item": {
- "$ref": "#/components/schemas/Item",
- },
- "user": {
- "$ref": "#/components/schemas/User",
+ "components": {
+ "schemas": {
+ "Body_update_item_items__item_id__put": {
+ "properties": {
+ "item": {
+ "$ref": "#/components/schemas/Item",
+ },
+ "user": {
+ "$ref": "#/components/schemas/User",
+ },
},
+ "required": [
+ "item",
+ "user",
+ ],
+ "title": "Body_update_item_items__item_id__put",
+ "type": "object",
},
- "required": [
- "item",
- "user",
- ],
- "title": "Body_update_item_items__item_id__put",
- "type": "object",
- },
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "User": {
- "properties": {
- "username": {
- "title": "Username",
- "type": "string",
- },
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "User": {
+ "properties": {
+ "username": {
+ "title": "Username",
+ "type": "string",
+ },
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
+ "required": [
+ "username",
+ ],
+ "title": "User",
+ "type": "object",
},
- "required": [
- "username",
- ],
- "title": "User",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
}
}
},
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
- }
- }
},
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "User": {
- "title": "User",
- "required": ["username"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "User": {
+ "title": "User",
+ "required": ["username"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "Body_update_item_items__item_id__put": {
- "title": "Body_update_item_items__item_id__put",
- "required": ["item", "user", "importance"],
- "type": "object",
- "properties": {
- "item": {"$ref": "#/components/schemas/Item"},
- "user": {"$ref": "#/components/schemas/User"},
- "importance": {"title": "Importance", "type": "integer"},
+ "Body_update_item_items__item_id__put": {
+ "title": "Body_update_item_items__item_id__put",
+ "required": ["item", "user", "importance"],
+ "type": "object",
+ "properties": {
+ "item": {"$ref": "#/components/schemas/Item"},
+ "user": {"$ref": "#/components/schemas/User"},
+ "importance": {"title": "Importance", "type": "integer"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ },
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ },
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
}
}
},
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
},
- {
- "required": False,
- "schema": {
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
"anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
},
- "name": "q",
- "in": "query",
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Body_update_item_items__item_id__put"
- }
- }
- },
- "required": True,
- },
- }
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "User": {
- "title": "User",
- "required": ["username"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "User": {
+ "title": "User",
+ "required": ["username"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "Body_update_item_items__item_id__put": {
- "title": "Body_update_item_items__item_id__put",
- "required": ["item", "user", "importance"],
- "type": "object",
- "properties": {
- "item": {"$ref": "#/components/schemas/Item"},
- "user": {"$ref": "#/components/schemas/User"},
- "importance": {
- "title": "Importance",
- "type": "integer",
- "exclusiveMinimum": 0.0,
+ "Body_update_item_items__item_id__put": {
+ "title": "Body_update_item_items__item_id__put",
+ "required": ["item", "user", "importance"],
+ "type": "object",
+ "properties": {
+ "item": {"$ref": "#/components/schemas/Item"},
+ "user": {"$ref": "#/components/schemas/User"},
+ "importance": {
+ "title": "Importance",
+ "type": "integer",
+ "exclusiveMinimum": 0.0,
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/items/{item_id}": {
- "put": {
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
- },
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
"schema": {
- "$ref": "#/components/schemas/Body_update_item_items__item_id__put",
+ "title": "Item Id",
+ "type": "integer",
},
},
- },
- "required": True,
- },
- "responses": {
- "200": {
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {},
+ "schema": {
+ "$ref": "#/components/schemas/Body_update_item_items__item_id__put",
+ },
},
},
- "description": "Successful Response",
+ "required": True,
},
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
},
},
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
+ },
+ },
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Update Item",
},
- "summary": "Update Item",
},
},
- },
- "components": {
- "schemas": {
- "Body_update_item_items__item_id__put": {
- "properties": {
- "item": {
- "$ref": "#/components/schemas/Item",
+ "components": {
+ "schemas": {
+ "Body_update_item_items__item_id__put": {
+ "properties": {
+ "item": {
+ "$ref": "#/components/schemas/Item",
+ },
},
+ "required": ["item"],
+ "title": "Body_update_item_items__item_id__put",
+ "type": "object",
},
- "required": ["item"],
- "title": "Body_update_item_items__item_id__put",
- "type": "object",
- },
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": tags_schema,
},
- "tags": tags_schema,
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Image": {
- "properties": {
- "url": {
- "title": "Url",
- "type": "string",
- },
- "name": {
- "title": "Name",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "Image": {
+ "properties": {
+ "url": {
+ "title": "Url",
+ "type": "string",
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
},
+ "required": ["url", "name"],
+ "title": "Image",
+ "type": "object",
},
- "required": ["url", "name"],
- "title": "Image",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "default": [],
- "type": "array",
- "items": {"type": "string"},
- "uniqueItems": True,
- },
- "image": {
- "anyOf": [
- {"$ref": "#/components/schemas/Image"},
- {"type": "null"},
- ],
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "default": [],
+ "type": "array",
+ "items": {"type": "string"},
+ "uniqueItems": True,
+ },
+ "image": {
+ "anyOf": [
+ {"$ref": "#/components/schemas/Image"},
+ {"type": "null"},
+ ],
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Image": {
- "properties": {
- "url": {
- "title": "Url",
- "type": "string",
- "format": "uri",
- "maxLength": 2083,
- "minLength": 1,
- },
- "name": {
- "title": "Name",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "Image": {
+ "properties": {
+ "url": {
+ "title": "Url",
+ "type": "string",
+ "format": "uri",
+ "maxLength": 2083,
+ "minLength": 1,
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
},
+ "required": ["url", "name"],
+ "title": "Image",
+ "type": "object",
},
- "required": ["url", "name"],
- "title": "Image",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "default": [],
- "type": "array",
- "items": {"type": "string"},
- "uniqueItems": True,
- },
- "image": {
- "anyOf": [
- {"$ref": "#/components/schemas/Image"},
- {"type": "null"},
- ],
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "default": [],
+ "type": "array",
+ "items": {"type": "string"},
+ "uniqueItems": True,
+ },
+ "image": {
+ "anyOf": [
+ {"$ref": "#/components/schemas/Image"},
+ {"type": "null"},
+ ],
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
}
}
},
+ "required": True,
},
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Image": {
- "properties": {
- "url": {
- "title": "Url",
- "type": "string",
- "format": "uri",
- "maxLength": 2083,
- "minLength": 1,
- },
- "name": {
- "title": "Name",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "Image": {
+ "properties": {
+ "url": {
+ "title": "Url",
+ "type": "string",
+ "format": "uri",
+ "maxLength": 2083,
+ "minLength": 1,
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
},
+ "required": ["url", "name"],
+ "title": "Image",
+ "type": "object",
},
- "required": ["url", "name"],
- "title": "Image",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "default": [],
- "type": "array",
- "items": {"type": "string"},
- "uniqueItems": True,
- },
- "images": {
- "anyOf": [
- {
- "items": {
- "$ref": "#/components/schemas/Image",
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "default": [],
+ "type": "array",
+ "items": {"type": "string"},
+ "uniqueItems": True,
+ },
+ "images": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/Image",
+ },
+ "type": "array",
},
- "type": "array",
- },
- {
- "type": "null",
- },
- ],
- "title": "Images",
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Images",
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/offers/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/offers/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Offer",
+ "operationId": "create_offer_offers__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Offer",
}
}
},
+ "required": True,
},
- },
- "summary": "Create Offer",
- "operationId": "create_offer_offers__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Offer",
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Image": {
- "properties": {
- "url": {
- "title": "Url",
- "type": "string",
- "format": "uri",
- "maxLength": 2083,
- "minLength": 1,
- },
- "name": {
- "title": "Name",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "Image": {
+ "properties": {
+ "url": {
+ "title": "Url",
+ "type": "string",
+ "format": "uri",
+ "maxLength": 2083,
+ "minLength": 1,
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
},
+ "required": ["url", "name"],
+ "title": "Image",
+ "type": "object",
},
- "required": ["url", "name"],
- "title": "Image",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "default": [],
- "type": "array",
- "items": {"type": "string"},
- "uniqueItems": True,
- },
- "images": {
- "anyOf": [
- {
- "items": {
- "$ref": "#/components/schemas/Image",
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "default": [],
+ "type": "array",
+ "items": {"type": "string"},
+ "uniqueItems": True,
+ },
+ "images": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/Image",
+ },
+ "type": "array",
},
- "type": "array",
- },
- {
- "type": "null",
- },
- ],
- "title": "Images",
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Images",
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "Offer": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "items": {
- "title": "Items",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "Offer": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "items": {
+ "title": "Items",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Item"},
+ },
},
+ "required": ["name", "price", "items"],
+ "title": "Offer",
+ "type": "object",
},
- "required": ["name", "price", "items"],
- "title": "Offer",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/images/multiple/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/images/multiple/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Multiple Images",
+ "operationId": "create_multiple_images_images_multiple__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Images",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Image"},
}
}
},
+ "required": True,
},
- },
- "summary": "Create Multiple Images",
- "operationId": "create_multiple_images_images_multiple__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Images",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Image"},
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Image": {
- "properties": {
- "url": {
- "title": "Url",
- "type": "string",
- "format": "uri",
- "maxLength": 2083,
- "minLength": 1,
- },
- "name": {
- "title": "Name",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "Image": {
+ "properties": {
+ "url": {
+ "title": "Url",
+ "type": "string",
+ "format": "uri",
+ "maxLength": 2083,
+ "minLength": 1,
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
},
+ "required": ["url", "name"],
+ "title": "Image",
+ "type": "object",
},
- "required": ["url", "name"],
- "title": "Image",
- "type": "object",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/index-weights/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/index-weights/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Index Weights",
+ "operationId": "create_index_weights_index_weights__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Weights",
+ "type": "object",
+ "additionalProperties": {"type": "number"},
}
}
},
+ "required": True,
},
- },
- "summary": "Create Index Weights",
- "operationId": "create_index_weights_index_weights__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Weights",
- "type": "object",
- "additionalProperties": {"type": "number"},
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- },
- "put": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ "put": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
},
- "required": True,
},
- },
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "type": "object",
- "title": "Item",
- "properties": {
- "name": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Name",
- },
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
- },
- "price": {
- "anyOf": [{"type": "number"}, {"type": "null"}],
- "title": "Price",
- },
- "tax": {"title": "Tax", "type": "number", "default": 10.5},
- "tags": {
- "title": "Tags",
- "type": "array",
- "items": {"type": "string"},
- "default": [],
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "type": "object",
+ "title": "Item",
+ "properties": {
+ "name": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Name",
+ },
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
+ "price": {
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ "title": "Price",
+ },
+ "tax": {"title": "Tax", "type": "number", "default": 10.5},
+ "tags": {
+ "title": "Tags",
+ "type": "array",
+ "items": {"type": "string"},
+ "default": [],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
},
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- },
- "patch": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ "patch": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__patch",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
- },
- },
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__patch",
- "parameters": [
- {
"required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
},
- "required": True,
},
- },
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "type": "object",
- "title": "Item",
- "properties": {
- "name": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Name",
- },
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
- },
- "price": {
- "anyOf": [{"type": "number"}, {"type": "null"}],
- "title": "Price",
- },
- "tax": {"title": "Tax", "type": "number", "default": 10.5},
- "tags": {
- "title": "Tags",
- "type": "array",
- "items": {"type": "string"},
- "default": [],
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "type": "object",
+ "title": "Item",
+ "properties": {
+ "name": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Name",
+ },
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
+ "price": {
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ "title": "Price",
+ },
+ "tax": {"title": "Tax", "type": "number", "default": 10.5},
+ "tags": {
+ "title": "Tags",
+ "type": "array",
+ "items": {"type": "string"},
+ "default": [],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import importlib
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
def get_client() -> TestClient:
response = client.get("/redoc")
assert response.status_code == 200, response.text
response = client.get("/openapi.json")
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "Root",
- "operationId": "root__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "Root",
+ "operationId": "root__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
client = TestClient(mod.app)
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Ads Id",
- },
- "name": "ads_id",
- "in": "cookie",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Ads Id",
+ },
+ "name": "ads_id",
+ "in": "cookie",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.custom_response.tutorial001b_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": response_content,
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": response_content,
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.custom_response.tutorial005_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "Main",
- "operationId": "main__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"text/plain": {"schema": {"type": "string"}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "Main",
+ "operationId": "main__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "text/plain": {"schema": {"type": "string"}}
+ },
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.custom_response.tutorial006_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/typer": {
- "get": {
- "summary": "Redirect Typer",
- "operationId": "redirect_typer_typer_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/typer": {
+ "get": {
+ "summary": "Redirect Typer",
+ "operationId": "redirect_typer_typer_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.custom_response.tutorial006b_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/fastapi": {
- "get": {
- "summary": "Redirect Fastapi",
- "operationId": "redirect_fastapi_fastapi_get",
- "responses": {"307": {"description": "Successful Response"}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/fastapi": {
+ "get": {
+ "summary": "Redirect Fastapi",
+ "operationId": "redirect_fastapi_fastapi_get",
+ "responses": {"307": {"description": "Successful Response"}},
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.custom_response.tutorial006c_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/pydantic": {
- "get": {
- "summary": "Redirect Pydantic",
- "operationId": "redirect_pydantic_pydantic_get",
- "responses": {"302": {"description": "Successful Response"}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/pydantic": {
+ "get": {
+ "summary": "Redirect Pydantic",
+ "operationId": "redirect_pydantic_pydantic_get",
+ "responses": {"302": {"description": "Successful Response"}},
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from tests.utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/authors/{author_id}/items/": {
- "post": {
- "summary": "Create Author Items",
- "operationId": "create_author_items_authors__author_id__items__post",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Author Id", "type": "string"},
- "name": "author_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Items",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/authors/{author_id}/items/": {
+ "post": {
+ "summary": "Create Author Items",
+ "operationId": "create_author_items_authors__author_id__items__post",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Author Id", "type": "string"},
+ "name": "author_id",
+ "in": "path",
}
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Author"}
- }
- },
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Items",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Item"},
}
}
},
+ "required": True,
},
- },
- }
- },
- "/authors/": {
- "get": {
- "summary": "Get Authors",
- "operationId": "get_authors_authors__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Get Authors Authors Get",
- "type": "array",
- "items": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
"$ref": "#/components/schemas/Author"
- },
+ }
}
- }
+ },
},
- }
- },
- }
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/authors/": {
+ "get": {
+ "summary": "Get Authors",
+ "operationId": "get_authors_authors__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Get Authors Authors Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Author"
+ },
+ }
+ }
+ },
+ }
+ },
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Author": {
- "title": "Author",
- "required": ["name"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "items": {
- "title": "Items",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ "components": {
+ "schemas": {
+ "Author": {
+ "title": "Author",
+ "required": ["name"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "items": {
+ "title": "Items",
+ "type": "array",
+ "items": {"$ref": "#/components/schemas/Item"},
+ },
},
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["name"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
+ "Item": {
+ "title": "Item",
+ "required": ["name"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
MOD_NAME = "docs_src.debugging.tutorial001_py39"
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "summary": "Root",
- "operationId": "root__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "summary": "Root",
+ "operationId": "root__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
},
- },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Skip",
- "type": "integer",
- "default": 0,
+ {
+ "required": False,
+ "schema": {
+ "title": "Skip",
+ "type": "integer",
+ "default": 0,
+ },
+ "name": "skip",
+ "in": "query",
},
- "name": "skip",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Limit",
- "type": "integer",
- "default": 100,
+ {
+ "required": False,
+ "schema": {
+ "title": "Limit",
+ "type": "integer",
+ "default": 100,
+ },
+ "name": "limit",
+ "in": "query",
},
- "name": "limit",
- "in": "query",
- },
- ],
- }
- },
- "/users/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ ],
+ }
+ },
+ "/users/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Skip",
- "type": "integer",
- "default": 0,
+ {
+ "required": False,
+ "schema": {
+ "title": "Skip",
+ "type": "integer",
+ "default": 0,
+ },
+ "name": "skip",
+ "in": "query",
},
- "name": "skip",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Limit",
- "type": "integer",
- "default": 100,
+ {
+ "required": False,
+ "schema": {
+ "title": "Limit",
+ "type": "integer",
+ "default": 100,
+ },
+ "name": "limit",
+ "in": "query",
},
- "name": "limit",
- "in": "query",
- },
- ],
- }
+ ],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Skip",
- "type": "integer",
- "default": 0,
+ {
+ "required": False,
+ "schema": {
+ "title": "Skip",
+ "type": "integer",
+ "default": 0,
+ },
+ "name": "skip",
+ "in": "query",
},
- "name": "skip",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Limit",
- "type": "integer",
- "default": 100,
+ {
+ "required": False,
+ "schema": {
+ "title": "Limit",
+ "type": "integer",
+ "default": 100,
+ },
+ "name": "limit",
+ "in": "query",
},
- "name": "limit",
- "in": "query",
- },
- ],
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Query",
- "operationId": "read_query_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Q",
+ "summary": "Read Query",
+ "operationId": "read_query_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Last Query",
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Last Query",
+ },
+ "name": "last_query",
+ "in": "cookie",
},
- "name": "last_query",
- "in": "cookie",
- },
- ],
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- {
- "required": True,
- "schema": {"title": "X-Key", "type": "string"},
- "name": "x-key",
- "in": "header",
- },
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Key", "type": "string"},
+ "name": "x-key",
+ "in": "header",
+ },
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/query-checker/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/query-checker/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Query Check",
- "operationId": "read_query_check_query_checker__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "type": "string",
- "default": "",
- "title": "Q",
+ "summary": "Read Query Check",
+ "operationId": "read_query_check_query_checker__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "type": "string",
+ "default": "",
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- ],
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- {
- "required": True,
- "schema": {"title": "X-Key", "type": "string"},
- "name": "x-key",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Key", "type": "string"},
+ "name": "x-key",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
- },
- "/users/": {
- "get": {
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "X-Token", "type": "string"},
- "name": "x-token",
- "in": "header",
- },
- {
- "required": True,
- "schema": {"title": "X-Key", "type": "string"},
- "name": "x-key",
- "in": "header",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ },
+ "/users/": {
+ "get": {
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "X-Token", "type": "string"},
+ "name": "x-token",
+ "in": "header",
+ },
+ {
+ "required": True,
+ "schema": {"title": "X-Key", "type": "string"},
+ "name": "x-key",
+ "in": "header",
+ },
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{id}": {
- "put": {
- "operationId": "update_item_items__id__put",
- "parameters": [
- {
- "in": "path",
- "name": "id",
- "required": True,
- "schema": {
- "title": "Id",
- "type": "string",
- },
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{id}": {
+ "put": {
+ "operationId": "update_item_items__id__put",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "id",
+ "required": True,
"schema": {
- "$ref": "#/components/schemas/Item",
+ "title": "Id",
+ "type": "string",
},
},
- },
- "required": True,
- },
- "responses": {
- "200": {
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {},
+ "schema": {
+ "$ref": "#/components/schemas/Item",
+ },
},
},
- "description": "Successful Response",
+ "required": True,
},
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
},
},
+ "description": "Successful Response",
},
- "description": "Validation Error",
- },
- },
- "summary": "Update Item",
- },
- },
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
+ },
+ },
+ "description": "Validation Error",
},
- "title": "Detail",
- "type": "array",
},
+ "summary": "Update Item",
},
- "title": "HTTPValidationError",
- "type": "object",
},
- "Item": {
- "properties": {
- "description": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
},
- ],
- "title": "Description",
- },
- "timestamp": {
- "format": "date-time",
- "title": "Timestamp",
- "type": "string",
- },
- "title": {
- "title": "Title",
- "type": "string",
+ "title": "Detail",
+ "type": "array",
+ },
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "required": [
- "title",
- "timestamp",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
+ "Item": {
+ "properties": {
+ "description": {
"anyOf": [
{
"type": "string",
},
{
- "type": "integer",
+ "type": "null",
},
],
+ "title": "Description",
+ },
+ "timestamp": {
+ "format": "date-time",
+ "title": "Timestamp",
+ "type": "string",
+ },
+ "title": {
+ "title": "Title",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
},
- "type": {
- "title": "Error Type",
- "type": "string",
+ "required": [
+ "title",
+ "timestamp",
+ ],
+ "title": "Item",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
+ },
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(name="app", scope="module")
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "integer"},
+ ]
+ },
},
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
},
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ValidationError"
- },
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(name="app", scope="module")
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.events.tutorial003_py39 import (
app,
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/predict": {
- "get": {
- "summary": "Predict",
- "operationId": "predict_predict_get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "X", "type": "number"},
- "name": "x",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/predict": {
+ "get": {
+ "summary": "Predict",
+ "operationId": "predict_predict_get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "X", "type": "number"},
+ "name": "x",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ValidationError"
- },
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "integer"},
+ ]
+ },
},
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
},
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.extending_openapi.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "Custom title",
- "summary": "This is a very custom OpenAPI schema",
- "description": "Here's a longer description of the custom **OpenAPI** schema",
- "version": "2.5.0",
- "x-logo": {
- "url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "Custom title",
+ "summary": "This is a very custom OpenAPI schema",
+ "description": "Here's a longer description of the custom **OpenAPI** schema",
+ "version": "2.5.0",
+ "x-logo": {
+ "url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"
+ },
},
- },
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
openapi_schema = response.json()
# Request again to test the custom cache
response = client.get("/openapi.json")
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/user/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/UserOut",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/user/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/UserOut",
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create User",
+ "operationId": "create_user_user__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/UserIn"}
}
},
+ "required": True,
},
- },
- "summary": "Create User",
- "operationId": "create_user_user__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/UserIn"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "UserIn": {
- "title": "UserIn",
- "required": IsList(
- "username", "password", "email", check_order=False
- ),
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
- "email": {
- "title": "Email",
- "type": "string",
- "format": "email",
- },
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "UserIn": {
+ "title": "UserIn",
+ "required": IsList(
+ "username", "password", "email", check_order=False
+ ),
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ "email": {
+ "title": "Email",
+ "type": "string",
+ "format": "email",
+ },
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "UserOut": {
- "title": "UserOut",
- "required": ["username", "email"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "email": {
- "title": "Email",
- "type": "string",
- "format": "email",
- },
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "UserOut": {
+ "title": "UserOut",
+ "required": ["username", "email"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "email": {
+ "title": "Email",
+ "type": "string",
+ "format": "email",
+ },
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Read Items Items Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Read Items Items Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
- },
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
+ },
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "description"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {"title": "Description", "type": "string"},
- },
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "description"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {"title": "Description", "type": "string"},
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/keyword-weights/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Read Keyword Weights Keyword Weights Get",
- "type": "object",
- "additionalProperties": {"type": "number"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/keyword-weights/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Read Keyword Weights Keyword Weights Get",
+ "type": "object",
+ "additionalProperties": {"type": "number"},
+ }
}
- }
- },
- }
- },
- "summary": "Read Keyword Weights",
- "operationId": "read_keyword_weights_keyword_weights__get",
+ },
+ }
+ },
+ "summary": "Read Keyword Weights",
+ "operationId": "read_keyword_weights_keyword_weights__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Root",
- "operationId": "root__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Root",
+ "operationId": "root__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Get Items",
- "operationId": "get_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Get Items Items Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Get Items",
+ "operationId": "get_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Get Items Items Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseMessage"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- },
- "ResponseMessage": {
- "title": "ResponseMessage",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ResponseMessage": {
+ "title": "ResponseMessage",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.generate_clients.tutorial002_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Get Items",
- "operationId": "get_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Get Items Items Get",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Get Items",
+ "operationId": "get_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Get Items Items Get",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "tags": ["items"],
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "tags": ["items"],
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseMessage"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
- },
- "/users/": {
- "post": {
- "tags": ["users"],
- "summary": "Create User",
- "operationId": "create_user_users__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ "/users/": {
+ "post": {
+ "tags": ["users"],
+ "summary": "Create User",
+ "operationId": "create_user_users__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseMessage"
- }
+ "schema": {"$ref": "#/components/schemas/User"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- },
- "ResponseMessage": {
- "title": "ResponseMessage",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
- },
- "User": {
- "title": "User",
- "required": ["username", "email"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "email": {"title": "Email", "type": "string"},
+ "ResponseMessage": {
+ "title": "ResponseMessage",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "User": {
+ "title": "User",
+ "required": ["username", "email"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "email": {"title": "Email", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.generate_clients.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Get Items",
- "operationId": "items-get_items",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "title": "Response Items-Get Items",
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Get Items",
+ "operationId": "items-get_items",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "title": "Response Items-Get Items",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "tags": ["items"],
- "summary": "Create Item",
- "operationId": "items-create_item",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "tags": ["items"],
+ "summary": "Create Item",
+ "operationId": "items-create_item",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseMessage"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
- },
- "/users/": {
- "post": {
- "tags": ["users"],
- "summary": "Create User",
- "operationId": "users-create_user",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ "/users/": {
+ "post": {
+ "tags": ["users"],
+ "summary": "Create User",
+ "operationId": "users-create_user",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/ResponseMessage"
- }
+ "schema": {"$ref": "#/components/schemas/User"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
- }
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ },
},
- },
- "ResponseMessage": {
- "title": "ResponseMessage",
- "required": ["message"],
- "type": "object",
- "properties": {"message": {"title": "Message", "type": "string"}},
- },
- "User": {
- "title": "User",
- "required": ["username", "email"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "email": {"title": "Email", "type": "string"},
+ "ResponseMessage": {
+ "title": "ResponseMessage",
+ "required": ["message"],
+ "type": "object",
+ "properties": {
+ "message": {"title": "Message", "type": "string"}
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "User": {
+ "title": "User",
+ "required": ["username", "email"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "email": {"title": "Email", "type": "string"},
+ },
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pathlib
from unittest.mock import patch
+from inline_snapshot import snapshot
+
from docs_src.generate_clients import tutorial003_py39
importlib.import_module("docs_src.generate_clients.tutorial004_py39")
modified_openapi = json.loads(tmp_file.read_text())
- assert modified_openapi == {
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
- },
- "title": "Detail",
- "type": "array",
- },
- },
- "title": "HTTPValidationError",
- "type": "object",
- },
- "Item": {
- "properties": {
- "name": {
- "title": "Name",
- "type": "string",
- },
- "price": {
- "title": "Price",
- "type": "number",
+ assert modified_openapi == snapshot(
+ {
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
+ },
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ResponseMessage": {
- "properties": {
- "message": {
- "title": "Message",
- "type": "string",
+ "Item": {
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
},
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
},
- "required": [
- "message",
- ],
- "title": "ResponseMessage",
- "type": "object",
- },
- "User": {
- "properties": {
- "email": {
- "title": "Email",
- "type": "string",
- },
- "username": {
- "title": "Username",
- "type": "string",
+ "ResponseMessage": {
+ "properties": {
+ "message": {
+ "title": "Message",
+ "type": "string",
+ },
},
+ "required": [
+ "message",
+ ],
+ "title": "ResponseMessage",
+ "type": "object",
},
- "required": [
- "username",
- "email",
- ],
- "title": "User",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "User": {
+ "properties": {
+ "email": {
+ "title": "Email",
+ "type": "string",
+ },
+ "username": {
+ "title": "Username",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "username",
+ "email",
+ ],
+ "title": "User",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
- },
- },
- },
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/items/": {
- "get": {
- "operationId": "get_items",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {
- "items": {
- "$ref": "#/components/schemas/Item",
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
},
- "title": "Response Items-Get Items",
- "type": "array",
- },
+ {
+ "type": "integer",
+ },
+ ],
},
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "description": "Successful Response",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "summary": "Get Items",
- "tags": [
- "items",
- ],
},
- "post": {
- "operationId": "create_item",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
+ },
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/items/": {
+ "get": {
+ "operationId": "get_items",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "items": {
+ "$ref": "#/components/schemas/Item",
+ },
+ "title": "Response Items-Get Items",
+ "type": "array",
+ },
+ },
},
+ "description": "Successful Response",
},
},
- "required": True,
+ "summary": "Get Items",
+ "tags": [
+ "items",
+ ],
},
- "responses": {
- "200": {
+ "post": {
+ "operationId": "create_item",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ResponseMessage",
+ "$ref": "#/components/schemas/Item",
},
},
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage",
+ },
},
},
+ "description": "Successful Response",
},
- "description": "Validation Error",
- },
- },
- "summary": "Create Item",
- "tags": [
- "items",
- ],
- },
- },
- "/users/": {
- "post": {
- "operationId": "create_user",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/User",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
+ },
},
+ "description": "Validation Error",
},
},
- "required": True,
+ "summary": "Create Item",
+ "tags": [
+ "items",
+ ],
},
- "responses": {
- "200": {
+ },
+ "/users/": {
+ "post": {
+ "operationId": "create_user",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/ResponseMessage",
+ "$ref": "#/components/schemas/User",
},
},
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ResponseMessage",
+ },
+ },
+ },
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Create User",
+ "tags": [
+ "users",
+ ],
},
- "summary": "Create User",
- "tags": [
- "users",
- ],
},
},
- },
- }
+ }
+ )
import warnings
import pytest
+from inline_snapshot import snapshot
from starlette.testclient import TestClient
warnings.filterwarnings(
def test_openapi(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/graphql": {
- "get": {
- "operationId": "handle_http_get_graphql_get",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/graphql": {
+ "get": {
+ "operationId": "handle_http_get_graphql_get",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "The GraphiQL integrated development environment.",
+ },
+ "404": {
+ "description": "Not found if GraphiQL or query via GET are not enabled.",
},
- "description": "The GraphiQL integrated development environment.",
- },
- "404": {
- "description": "Not found if GraphiQL or query via GET are not enabled.",
},
+ "summary": "Handle Http Get",
},
- "summary": "Handle Http Get",
- },
- "post": {
- "operationId": "handle_http_post_graphql_post",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ "post": {
+ "operationId": "handle_http_post_graphql_post",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
},
+ "summary": "Handle Http Post",
},
- "summary": "Handle Http Post",
},
},
- },
- }
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial002_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items-header/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items-header/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item Header",
- "operationId": "read_item_header_items_header__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item Header",
+ "operationId": "read_item_header_items_header__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/unicorns/{name}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/unicorns/{name}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Unicorn",
- "operationId": "read_unicorn_unicorns__name__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Name", "type": "string"},
- "name": "name",
- "in": "path",
- }
- ],
+ "summary": "Read Unicorn",
+ "operationId": "read_unicorn_unicorns__name__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Name", "type": "string"},
+ "name": "name",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial004_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial005_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Item": {
- "title": "Item",
- "required": ["title", "size"],
- "type": "object",
- "properties": {
- "title": {"title": "Title", "type": "string"},
- "size": {"title": "Size", "type": "integer"},
+ "Item": {
+ "title": "Item",
+ "required": ["title", "size"],
+ "type": "object",
+ "properties": {
+ "title": {"title": "Title", "type": "string"},
+ "size": {"title": "Size", "type": "integer"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.handling_errors.tutorial006_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "User-Agent",
- },
- "name": "user-agent",
- "in": "header",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "User-Agent",
+ },
+ "name": "user-agent",
+ "in": "header",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Strange Header",
- },
- "name": "strange_header",
- "in": "header",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Strange Header",
+ },
+ "name": "strange_header",
+ "in": "header",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "X-Token",
- "anyOf": [
- {"type": "array", "items": {"type": "string"}},
- {"type": "null"},
- ],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "X-Token",
+ "anyOf": [
+ {"type": "array", "items": {"type": "string"}},
+ {"type": "null"},
+ ],
+ },
+ "name": "x-token",
+ "in": "header",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "x-token",
- "in": "header",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.metadata.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "ChimichangApp",
- "summary": "Deadpool's favorite app. Nuff said.",
- "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
- "termsOfService": "http://example.com/terms/",
- "contact": {
- "name": "Deadpoolio the Amazing",
- "url": "http://x-force.example.com/contact/",
- "email": "dp@x-force.example.com",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "ChimichangApp",
+ "summary": "Deadpool's favorite app. Nuff said.",
+ "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
+ "termsOfService": "http://example.com/terms/",
+ "contact": {
+ "name": "Deadpoolio the Amazing",
+ "url": "http://x-force.example.com/contact/",
+ "email": "dp@x-force.example.com",
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
+ },
+ "version": "0.0.1",
},
- "license": {
- "name": "Apache 2.0",
- "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
- },
- "version": "0.0.1",
- },
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.metadata.tutorial001_1_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "ChimichangApp",
- "summary": "Deadpool's favorite app. Nuff said.",
- "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
- "termsOfService": "http://example.com/terms/",
- "contact": {
- "name": "Deadpoolio the Amazing",
- "url": "http://x-force.example.com/contact/",
- "email": "dp@x-force.example.com",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "ChimichangApp",
+ "summary": "Deadpool's favorite app. Nuff said.",
+ "description": "\nChimichangApp API helps you do awesome stuff. 🚀\n\n## Items\n\nYou can **read items**.\n\n## Users\n\nYou will be able to:\n\n* **Create users** (_not implemented_).\n* **Read users** (_not implemented_).\n",
+ "termsOfService": "http://example.com/terms/",
+ "contact": {
+ "name": "Deadpoolio the Amazing",
+ "url": "http://x-force.example.com/contact/",
+ "email": "dp@x-force.example.com",
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "identifier": "Apache-2.0",
+ },
+ "version": "0.0.1",
},
- "license": {
- "name": "Apache 2.0",
- "identifier": "Apache-2.0",
- },
- "version": "0.0.1",
- },
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.metadata.tutorial002_py39 import app
def test_openapi_schema():
response = client.get("/api/v1/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.metadata.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
def test_swagger_ui_default_url():
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.metadata.tutorial004_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/": {
- "get": {
- "tags": ["users"],
- "summary": "Get Users",
- "operationId": "get_users_users__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Get Users",
+ "operationId": "get_users_users__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Get Items",
+ "operationId": "get_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
},
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Get Items",
- "operationId": "get_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
+ "tags": [
+ {
+ "name": "users",
+ "description": "Operations with users. The **login** logic is also here.",
+ },
+ {
+ "name": "items",
+ "description": "Manage items. So _fancy_ they have their own docs.",
+ "externalDocs": {
+ "description": "Items external docs",
+ "url": "https://fastapi.tiangolo.com/",
},
- }
- },
- },
- "tags": [
- {
- "name": "users",
- "description": "Operations with users. The **login** logic is also here.",
- },
- {
- "name": "items",
- "description": "Manage items. So _fancy_ they have their own docs.",
- "externalDocs": {
- "description": "Items external docs",
- "url": "https://fastapi.tiangolo.com/",
},
- },
- ],
- }
+ ],
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.middleware.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "paths": {},
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "paths": {},
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from tests.utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/invoices/": {
- "post": {
- "summary": "Create Invoice",
- "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n * At this point is that the API will somehow send a POST request to the\n external API with the notification of the invoice event\n (e.g. "payment successful").',
- "operationId": "create_invoice_invoices__post",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "format": "uri",
- "minLength": 1,
- "maxLength": 2083,
- },
- {"type": "null"},
- ],
- "title": "Callback Url",
- },
- "name": "callback_url",
- "in": "query",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Invoice"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/invoices/": {
+ "post": {
+ "summary": "Create Invoice",
+ "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n * At this point is that the API will somehow send a POST request to the\n external API with the notification of the invoice event\n (e.g. "payment successful").',
+ "operationId": "create_invoice_invoices__post",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "format": "uri",
+ "minLength": 1,
+ "maxLength": 2083,
+ },
+ {"type": "null"},
+ ],
+ "title": "Callback Url",
+ },
+ "name": "callback_url",
+ "in": "query",
}
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Invoice"}
}
},
+ "required": True,
},
- },
- "callbacks": {
- "invoice_notification": {
- "{$callback_url}/invoices/{$request.body.id}": {
- "post": {
- "summary": "Invoice Notification",
- "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/InvoiceEvent"
- }
- }
- },
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ "callbacks": {
+ "invoice_notification": {
+ "{$callback_url}/invoices/{$request.body.id}": {
+ "post": {
+ "summary": "Invoice Notification",
+ "operationId": "invoice_notification__callback_url__invoices___request_body_id__post",
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/InvoiceEventReceived"
+ "$ref": "#/components/schemas/InvoiceEvent"
}
}
},
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/InvoiceEventReceived"
+ }
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- },
+ }
}
}
- }
- },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "Invoice": {
- "title": "Invoice",
- "required": ["id", "customer", "total"],
- "type": "object",
- "properties": {
- "id": {"title": "Id", "type": "string"},
- "title": {
- "title": "Title",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "Invoice": {
+ "title": "Invoice",
+ "required": ["id", "customer", "total"],
+ "type": "object",
+ "properties": {
+ "id": {"title": "Id", "type": "string"},
+ "title": {
+ "title": "Title",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "customer": {"title": "Customer", "type": "string"},
+ "total": {"title": "Total", "type": "number"},
},
- "customer": {"title": "Customer", "type": "string"},
- "total": {"title": "Total", "type": "number"},
},
- },
- "InvoiceEvent": {
- "title": "InvoiceEvent",
- "required": ["description", "paid"],
- "type": "object",
- "properties": {
- "description": {"title": "Description", "type": "string"},
- "paid": {"title": "Paid", "type": "boolean"},
+ "InvoiceEvent": {
+ "title": "InvoiceEvent",
+ "required": ["description", "paid"],
+ "type": "object",
+ "properties": {
+ "description": {"title": "Description", "type": "string"},
+ "paid": {"title": "Paid", "type": "boolean"},
+ },
},
- },
- "InvoiceEventReceived": {
- "title": "InvoiceEventReceived",
- "required": ["ok"],
- "type": "object",
- "properties": {"ok": {"title": "Ok", "type": "boolean"}},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "InvoiceEventReceived": {
+ "title": "InvoiceEventReceived",
+ "required": ["ok"],
+ "type": "object",
+ "properties": {"ok": {"title": "Ok", "type": "boolean"}},
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.openapi_webhooks.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/": {
- "get": {
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- }
- },
- "webhooks": {
- "new-subscription": {
- "post": {
- "summary": "New Subscription",
- "description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.",
- "operationId": "new_subscriptionnew_subscription_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Subscription"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/": {
+ "get": {
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ }
+ }
+ },
+ "webhooks": {
+ "new-subscription": {
+ "post": {
+ "summary": "New Subscription",
+ "description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.",
+ "operationId": "new_subscriptionnew_subscription_post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Subscription"
}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Subscription": {
- "properties": {
- "username": {"type": "string", "title": "Username"},
- "monthly_fee": {"type": "number", "title": "Monthly Fee"},
- "start_date": {
- "type": "string",
- "format": "date-time",
- "title": "Start Date",
+ "Subscription": {
+ "properties": {
+ "username": {"type": "string", "title": "Username"},
+ "monthly_fee": {"type": "number", "title": "Monthly Fee"},
+ "start_date": {
+ "type": "string",
+ "format": "date-time",
+ "title": "Start Date",
+ },
},
+ "type": "object",
+ "required": ["username", "monthly_fee", "start_date"],
+ "title": "Subscription",
},
- "type": "object",
- "required": ["username", "monthly_fee", "start_date"],
- "title": "Subscription",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_advanced_configuration.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "some_specific_id_you_define",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "some_specific_id_you_define",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_advanced_configuration.tutorial002_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_advanced_configuration.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {},
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {},
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create an item",
+ "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Create an item",
- "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "uniqueItems": True,
- "type": "array",
- "items": {"type": "string"},
- "default": [],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "uniqueItems": True,
+ "type": "array",
+ "items": {"type": "string"},
+ "default": [],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_advanced_configuration.tutorial005_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "x-aperture-labs-portal": "blue",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "x-aperture-labs-portal": "blue",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_advanced_configuration.tutorial006_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"type": "string"},
- "price": {"type": "number"},
- "description": {"type": "string"},
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"type": "string"},
+ "price": {"type": "number"},
+ "description": {"type": "string"},
+ },
+ }
}
+ },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/x-yaml": {
- "schema": {
- "title": "Item",
- "required": ["name", "tags"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "tags": {
- "title": "Tags",
- "type": "array",
- "items": {"type": "string"},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
+ "content": {
+ "application/x-yaml": {
+ "schema": {
+ "title": "Item",
+ "required": ["name", "tags"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "tags": {
+ "title": "Tags",
+ "type": "array",
+ "items": {"type": "string"},
+ },
},
- },
+ }
}
+ },
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "201": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "201": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "Item": {
- "properties": {
- "description": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
- },
- ],
- "title": "Description",
- },
- "name": {
- "title": "Name",
- "type": "string",
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tags": {
- "default": [],
- "items": {
+ "Item": {
+ "properties": {
+ "description": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Description",
+ },
+ "name": {
+ "title": "Name",
"type": "string",
},
- "title": "Tags",
- "type": "array",
- "uniqueItems": True,
- },
- "tax": {
- "anyOf": [
- {
- "type": "number",
- },
- {
- "type": "null",
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tags": {
+ "default": [],
+ "items": {
+ "type": "string",
},
- ],
- "title": "Tax",
- },
- },
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
+ "title": "Tags",
+ "type": "array",
+ "uniqueItems": True,
+ },
+ "tax": {
"anyOf": [
{
- "type": "string",
+ "type": "number",
},
{
- "type": "integer",
+ "type": "null",
},
],
+ "title": "Tax",
},
- "title": "Location",
- "type": "array",
},
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
+ },
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- },
- "post": {
- "tags": ["items"],
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "tags": ["items"],
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
- },
- "/users/": {
- "get": {
- "tags": ["users"],
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
- },
- "title": "Detail",
- "type": "array",
+ "/users/": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
},
- },
- "title": "HTTPValidationError",
- "type": "object",
+ }
},
- "Item": {
- "properties": {
- "description": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
},
- ],
- "title": "Description",
- },
- "name": {
- "title": "Name",
- "type": "string",
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tags": {
- "default": [],
- "items": {
- "type": "string",
+ "title": "Detail",
+ "type": "array",
},
- "title": "Tags",
- "type": "array",
- "uniqueItems": True,
- },
- "tax": {
- "anyOf": [
- {
- "type": "number",
- },
- {
- "type": "null",
- },
- ],
- "title": "Tax",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
+ "Item": {
+ "properties": {
+ "description": {
"anyOf": [
{
"type": "string",
},
{
- "type": "integer",
+ "type": "null",
},
],
+ "title": "Description",
+ },
+ "name": {
+ "title": "Name",
+ "type": "string",
+ },
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tags": {
+ "default": [],
+ "items": {
+ "type": "string",
+ },
+ "title": "Tags",
+ "type": "array",
+ "uniqueItems": True,
+ },
+ "tax": {
+ "anyOf": [
+ {
+ "type": "number",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Tax",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
},
- "type": {
- "title": "Error Type",
- "type": "string",
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
+ },
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_configuration.tutorial002b_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "tags": ["items"],
- "summary": "Get Items",
- "operationId": "get_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "tags": ["items"],
+ "summary": "Get Items",
+ "operationId": "get_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
+ "/users/": {
+ "get": {
+ "tags": ["users"],
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
},
- "/users/": {
- "get": {
- "tags": ["users"],
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
- },
- },
- }
+ }
+ )
import pytest
from dirty_equals import IsList
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "summary": "Create an item",
- "description": DESCRIPTIONS[mod_name],
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "summary": "Create an item",
+ "description": DESCRIPTIONS[mod_name],
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
},
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "Item": {
- "properties": {
- "description": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
- },
- ],
- "title": "Description",
- },
- "name": {
- "title": "Name",
- "type": "string",
- },
- "price": {
- "title": "Price",
- "type": "number",
- },
- "tags": {
- "default": [],
- "items": {
+ "Item": {
+ "properties": {
+ "description": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Description",
+ },
+ "name": {
+ "title": "Name",
"type": "string",
},
- "title": "Tags",
- "type": "array",
- "uniqueItems": True,
- },
- "tax": {
- "anyOf": [
- {
- "type": "number",
- },
- {
- "type": "null",
+ "price": {
+ "title": "Price",
+ "type": "number",
+ },
+ "tags": {
+ "default": [],
+ "items": {
+ "type": "string",
},
- ],
- "title": "Tax",
- },
- },
- "required": [
- "name",
- "price",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
+ "title": "Tags",
+ "type": "array",
+ "uniqueItems": True,
+ },
+ "tax": {
"anyOf": [
{
- "type": "string",
+ "type": "number",
},
{
- "type": "integer",
+ "type": "null",
},
],
+ "title": "Tax",
},
- "title": "Location",
- "type": "array",
},
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
+ "required": [
+ "name",
+ "price",
+ ],
+ "title": "Item",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
+ },
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "The created item",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "The created item",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create an item",
+ "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
},
- },
- "summary": "Create an item",
- "description": "Create an item with all the information:\n\n- **name**: each item must have a name\n- **description**: a long description\n- **price**: required\n- **tax**: if the item doesn't have tax, you can omit this\n- **tags**: a set of unique tag strings for this item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "uniqueItems": True,
- "type": "array",
- "items": {"type": "string"},
- "default": [],
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "uniqueItems": True,
+ "type": "array",
+ "items": {"type": "string"},
+ "default": [],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_operation_configuration.tutorial006_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "tags": ["items"],
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "tags": ["items"],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ }
+ },
+ "/users/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "tags": ["users"],
+ "summary": "Read Users",
+ "operationId": "read_users_users__get",
+ }
+ },
+ "/elements/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "tags": ["items"],
+ "summary": "Read Elements",
+ "operationId": "read_elements_elements__get",
+ "deprecated": True,
+ }
+ },
},
- "/users/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "tags": ["users"],
- "summary": "Read Users",
- "operationId": "read_users_users__get",
- }
- },
- "/elements/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "tags": ["items"],
- "summary": "Read Elements",
- "operationId": "read_elements_elements__get",
- "deprecated": True,
- }
- },
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial001_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ },
},
- },
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Read Item",
},
- "summary": "Read Item",
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial002_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "integer",
+ },
},
- },
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Read Item",
},
- "summary": "Read Item",
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial003_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "operationId": "read_user_me_users_me_get",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "operationId": "read_user_me_users_me_get",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
},
+ "summary": "Read User Me",
},
- "summary": "Read User Me",
},
- },
- "/users/{user_id}": {
- "get": {
- "operationId": "read_user_users__user_id__get",
- "parameters": [
- {
- "in": "path",
- "name": "user_id",
- "required": True,
- "schema": {
- "title": "User Id",
- "type": "string",
+ "/users/{user_id}": {
+ "get": {
+ "operationId": "read_user_users__user_id__get",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "user_id",
+ "required": True,
+ "schema": {
+ "title": "User Id",
+ "type": "string",
+ },
},
- },
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Read User",
},
- "summary": "Read User",
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import asyncio
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial003b_py39 import app, read_users2
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users": {
- "get": {
- "operationId": "read_users2_users_get",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users": {
+ "get": {
+ "operationId": "read_users2_users_get",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
},
+ "summary": "Read Users2",
},
- "summary": "Read Users2",
},
},
- },
- }
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial004_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/{file_path}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/{file_path}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read File",
- "operationId": "read_file_files__file_path__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "File Path", "type": "string"},
- "name": "file_path",
- "in": "path",
- }
- ],
+ "summary": "Read File",
+ "operationId": "read_file_files__file_path__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "File Path", "type": "string"},
+ "name": "file_path",
+ "in": "path",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.path_params.tutorial005_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- data = response.json()
- assert data == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/models/{model_name}": {
- "get": {
- "summary": "Get Model",
- "operationId": "get_model_models__model_name__get",
- "parameters": [
- {
- "required": True,
- "schema": {"$ref": "#/components/schemas/ModelName"},
- "name": "model_name",
- "in": "path",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/models/{model_name}": {
+ "get": {
+ "summary": "Get Model",
+ "operationId": "get_model_models__model_name__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"$ref": "#/components/schemas/ModelName"},
+ "name": "model_name",
+ "in": "path",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ModelName": {
- "title": "ModelName",
- "enum": ["alexnet", "resnet", "lenet"],
- "type": "string",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ModelName": {
+ "title": "ModelName",
+ "enum": ["alexnet", "resnet", "lenet"],
+ "type": "string",
+ },
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
- },
- ],
- "title": "Item-Query",
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ "title": "Item-Query",
+ },
+ "name": "item-query",
+ "in": "query",
},
- "name": "item-query",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {},
- }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {},
+ }
+ },
},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "type": "integer",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "type": "integer",
+ },
+ "name": "item_id",
+ "in": "path",
},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {
- "type": "string",
- "title": "Q",
+ {
+ "required": True,
+ "schema": {
+ "type": "string",
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {},
- }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {},
+ }
+ },
},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "type": "integer",
- "minimum": 1,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "type": "integer",
+ "minimum": 1,
+ },
+ "name": "item_id",
+ "in": "path",
},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {
- "type": "string",
- "title": "Q",
+ {
+ "required": True,
+ "schema": {
+ "type": "string",
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {},
- }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {},
+ }
+ },
},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "type": "integer",
- "exclusiveMinimum": 0,
- "maximum": 1000,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "type": "integer",
+ "exclusiveMinimum": 0,
+ "maximum": 1000,
+ },
+ "name": "item_id",
+ "in": "path",
},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {
- "type": "string",
- "title": "Q",
+ {
+ "required": True,
+ "schema": {
+ "type": "string",
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {},
- }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {},
+ }
+ },
},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "title": "The ID of the item to get",
- "type": "integer",
- "minimum": 0,
- "maximum": 1000,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "title": "The ID of the item to get",
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 1000,
+ },
+ "name": "item_id",
+ "in": "path",
},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {
- "type": "string",
- "title": "Q",
+ {
+ "required": True,
+ "schema": {
+ "type": "string",
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "q",
- "in": "query",
- },
- {
- "in": "query",
- "name": "size",
- "required": True,
- "schema": {
- "exclusiveMaximum": 10.5,
- "exclusiveMinimum": 0,
- "title": "Size",
- "type": "number",
+ {
+ "in": "query",
+ "name": "size",
+ "required": True,
+ "schema": {
+ "exclusiveMaximum": 10.5,
+ "exclusiveMinimum": 0,
+ "title": "Size",
+ "type": "number",
+ },
},
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {},
- }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {},
+ }
+ },
},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Item",
- "operationId": "read_item_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Skip",
- "type": "integer",
- "default": 0,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Item",
+ "operationId": "read_item_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Skip",
+ "type": "integer",
+ "default": 0,
+ },
+ "name": "skip",
+ "in": "query",
},
- "name": "skip",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Limit",
- "type": "integer",
- "default": 10,
+ {
+ "required": False,
+ "schema": {
+ "title": "Limit",
+ "type": "integer",
+ "default": 10,
+ },
+ "name": "limit",
+ "in": "query",
},
- "name": "limit",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ ],
+ "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": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "schema": {
- "title": "Q",
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
- },
- ],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "q",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ },
+ "name": "q",
+ "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": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "summary": "Read Item",
- "operationId": "read_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": False,
- "schema": {
- "title": "Q",
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "null",
- },
- ],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "summary": "Read Item",
+ "operationId": "read_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Short",
- "type": "boolean",
- "default": False,
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ },
+ "name": "q",
+ "in": "query",
},
- "name": "short",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ {
+ "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": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/{user_id}/items/{item_id}": {
- "get": {
- "summary": "Read User Item",
- "operationId": "read_user_item_users__user_id__items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "User Id", "type": "integer"},
- "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",
- },
- ],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/{user_id}/items/{item_id}": {
+ "get": {
+ "summary": "Read User Item",
+ "operationId": "read_user_item_users__user_id__items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "User Id", "type": "integer"},
+ "name": "user_id",
+ "in": "path",
},
- "name": "q",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Short",
- "type": "boolean",
- "default": False,
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "short",
- "in": "query",
- },
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "null",
+ },
+ ],
+ },
+ "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": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.query_params.tutorial005_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read User Item",
- "operationId": "read_user_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {"title": "Needy", "type": "string"},
- "name": "needy",
- "in": "query",
- },
- ],
+ "summary": "Read User Item",
+ "operationId": "read_user_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
+ },
+ {
+ "required": True,
+ "schema": {"title": "Needy", "type": "string"},
+ "name": "needy",
+ "in": "query",
+ },
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read User Item",
- "operationId": "read_user_item_items__item_id__get",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "string"},
- "name": "item_id",
- "in": "path",
- },
- {
- "required": True,
- "schema": {"title": "Needy", "type": "string"},
- "name": "needy",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "title": "Skip",
- "type": "integer",
- "default": 0,
+ "summary": "Read User Item",
+ "operationId": "read_user_item_items__item_id__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "string"},
+ "name": "item_id",
+ "in": "path",
},
- "name": "skip",
- "in": "query",
- },
- {
- "required": False,
- "schema": {
- "anyOf": [{"type": "integer"}, {"type": "null"}],
- "title": "Limit",
+ {
+ "required": True,
+ "schema": {"title": "Needy", "type": "string"},
+ "name": "needy",
+ "in": "query",
},
- "name": "limit",
- "in": "query",
- },
- ],
+ {
+ "required": False,
+ "schema": {
+ "title": "Skip",
+ "type": "integer",
+ "default": 0,
+ },
+ "name": "skip",
+ "in": "query",
+ },
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [{"type": "integer"}, {"type": "null"}],
+ "title": "Limit",
+ },
+ "name": "limit",
+ "in": "query",
+ },
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"type": "string"},
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "maxLength": 50,
- },
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 50,
+ },
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "minLength": 3,
- "maxLength": 50,
- },
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 3,
+ "maxLength": 50,
+ },
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "minLength": 3,
- "maxLength": 50,
- "pattern": "^fixedquery$",
- },
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 3,
+ "maxLength": 50,
+ "pattern": "^fixedquery$",
+ },
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "type": "string",
- "default": "fixedquery",
- "minLength": 3,
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "type": "string",
+ "default": "fixedquery",
+ "minLength": 3,
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "type": "string",
- "minLength": 3,
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "type": "string",
+ "minLength": 3,
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": True,
- "schema": {
- "anyOf": [
- {"type": "string", "minLength": 3},
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {
+ "anyOf": [
+ {"type": "string", "minLength": 3},
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "minLength": 3,
- },
- {"type": "null"},
- ],
- "title": "Query string",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 3,
+ },
+ {"type": "null"},
+ ],
+ "title": "Query string",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "description": "Query string for the items to search in the database that have a good match",
- "required": False,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "minLength": 3,
- },
- {"type": "null"},
- ],
- "title": "Query string",
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
"description": "Query string for the items to search in the database that have a good match",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 3,
+ },
+ {"type": "null"},
+ ],
+ "title": "Query string",
+ "description": "Query string for the items to search in the database that have a good match",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "schema": {
- "anyOf": [
- {"type": "string"},
- {"type": "null"},
- ],
- "title": "Item-Query",
- },
- "required": False,
- "name": "item-query",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "schema": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "null"},
+ ],
+ "title": "Item-Query",
+ },
+ "required": False,
+ "name": "item-query",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi._compat import PYDANTIC_VERSION_MINOR_TUPLE
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "description": "Query string for the items to search in the database that have a good match",
- "required": False,
- "deprecated": True,
- "schema": {
- "anyOf": [
- {
- "type": "string",
- "minLength": 3,
- "maxLength": 50,
- "pattern": "^fixedquery$",
- },
- {"type": "null"},
- ],
- "title": "Query string",
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
"description": "Query string for the items to search in the database that have a good match",
- # See https://github.com/pydantic/pydantic/blob/80353c29a824c55dea4667b328ba8f329879ac9f/tests/test_fastapi.sh#L25-L34.
- **(
- {"deprecated": True}
- if PYDANTIC_VERSION_MINOR_TUPLE >= (2, 10)
- else {}
- ),
- },
- "name": "item-query",
- "in": "query",
- }
- ],
+ "required": False,
+ "deprecated": True,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string",
+ "minLength": 3,
+ "maxLength": 50,
+ "pattern": "^fixedquery$",
+ },
+ {"type": "null"},
+ ],
+ "title": "Query string",
+ "description": "Query string for the items to search in the database that have a good match",
+ # See https://github.com/pydantic/pydantic/blob/80353c29a824c55dea4667b328ba8f329879ac9f/tests/test_fastapi.sh#L25-L34.
+ **(
+ {"deprecated": True}
+ if PYDANTIC_VERSION_MINOR_TUPLE >= (2, 10)
+ else {}
+ ),
+ },
+ "name": "item-query",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "anyOf": [
- {"type": "array", "items": {"type": "string"}},
- {"type": "null"},
- ],
- "title": "Q",
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "anyOf": [
+ {"type": "array", "items": {"type": "string"}},
+ {"type": "null"},
+ ],
+ "title": "Q",
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Q",
- "type": "array",
- "items": {"type": "string"},
- "default": ["foo", "bar"],
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "type": "array",
+ "items": {"type": "string"},
+ "default": ["foo", "bar"],
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Q",
- "type": "array",
- "items": {},
- "default": [],
- },
- "name": "q",
- "in": "query",
- }
- ],
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Q",
+ "type": "array",
+ "items": {},
+ "default": [],
+ },
+ "name": "q",
+ "in": "query",
+ }
+ ],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create File",
+ "operationId": "create_file_files__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_file_files__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Create File",
- "operationId": "create_file_files__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_file_files__post"
- }
- }
- },
- "required": True,
- },
- }
- },
- "/uploadfile/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/uploadfile/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Upload File",
+ "operationId": "create_upload_file_uploadfile__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Create Upload File",
- "operationId": "create_upload_file_uploadfile__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
- }
+ }
+ },
+ },
+ "components": {
+ "schemas": {
+ "Body_create_upload_file_uploadfile__post": {
+ "title": "Body_create_upload_file_uploadfile__post",
+ "required": ["file"],
+ "type": "object",
+ "properties": {
+ "file": {
+ "title": "File",
+ "type": "string",
+ "format": "binary",
}
},
- "required": True,
- },
- }
- },
- },
- "components": {
- "schemas": {
- "Body_create_upload_file_uploadfile__post": {
- "title": "Body_create_upload_file_uploadfile__post",
- "required": ["file"],
- "type": "object",
- "properties": {
- "file": {"title": "File", "type": "string", "format": "binary"}
},
- },
- "Body_create_file_files__post": {
- "title": "Body_create_file_files__post",
- "required": ["file"],
- "type": "object",
- "properties": {
- "file": {"title": "File", "type": "string", "format": "binary"}
+ "Body_create_file_files__post": {
+ "title": "Body_create_file_files__post",
+ "required": ["file"],
+ "type": "object",
+ "properties": {
+ "file": {
+ "title": "File",
+ "type": "string",
+ "format": "binary",
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/": {
- "post": {
- "summary": "Create File",
- "operationId": "create_file_files__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_file_files__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/": {
+ "post": {
+ "summary": "Create File",
+ "operationId": "create_file_files__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_file_files__post"
}
}
},
+ "required": True,
},
- },
- }
- },
- "/uploadfile/": {
- "post": {
- "summary": "Create Upload File",
- "operationId": "create_upload_file_uploadfile__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/uploadfile/": {
+ "post": {
+ "summary": "Create Upload File",
+ "operationId": "create_upload_file_uploadfile__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
}
}
},
+ "required": True,
},
- },
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_create_file_files__post": {
- "title": "Body_create_file_files__post",
- "required": ["file"],
- "type": "object",
- "properties": {
- "file": {
- "title": "File",
- "type": "string",
- "description": "A file read as bytes",
- "format": "binary",
- }
+ "components": {
+ "schemas": {
+ "Body_create_file_files__post": {
+ "title": "Body_create_file_files__post",
+ "required": ["file"],
+ "type": "object",
+ "properties": {
+ "file": {
+ "title": "File",
+ "type": "string",
+ "description": "A file read as bytes",
+ "format": "binary",
+ }
+ },
},
- },
- "Body_create_upload_file_uploadfile__post": {
- "title": "Body_create_upload_file_uploadfile__post",
- "required": ["file"],
- "type": "object",
- "properties": {
- "file": {
- "title": "File",
- "type": "string",
- "description": "A file read as UploadFile",
- "format": "binary",
- }
+ "Body_create_upload_file_uploadfile__post": {
+ "title": "Body_create_upload_file_uploadfile__post",
+ "required": ["file"],
+ "type": "object",
+ "properties": {
+ "file": {
+ "title": "File",
+ "type": "string",
+ "description": "A file read as UploadFile",
+ "format": "binary",
+ }
+ },
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Files",
+ "operationId": "create_files_files__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_files_files__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Create Files",
- "operationId": "create_files_files__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_files_files__post"
- }
- }
- },
- "required": True,
- },
- }
- },
- "/uploadfiles/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "/uploadfiles/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create Upload Files",
+ "operationId": "create_upload_files_uploadfiles__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Create Upload Files",
- "operationId": "create_upload_files_uploadfiles__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
- }
+ }
+ },
+ "/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- }
- },
- "/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Main",
- "operationId": "main__get",
- }
+ "summary": "Main",
+ "operationId": "main__get",
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_create_upload_files_uploadfiles__post": {
- "title": "Body_create_upload_files_uploadfiles__post",
- "required": ["files"],
- "type": "object",
- "properties": {
- "files": {
- "title": "Files",
- "type": "array",
- "items": {"type": "string", "format": "binary"},
- }
+ "components": {
+ "schemas": {
+ "Body_create_upload_files_uploadfiles__post": {
+ "title": "Body_create_upload_files_uploadfiles__post",
+ "required": ["files"],
+ "type": "object",
+ "properties": {
+ "files": {
+ "title": "Files",
+ "type": "array",
+ "items": {"type": "string", "format": "binary"},
+ }
+ },
},
- },
- "Body_create_files_files__post": {
- "title": "Body_create_files_files__post",
- "required": ["files"],
- "type": "object",
- "properties": {
- "files": {
- "title": "Files",
- "type": "array",
- "items": {"type": "string", "format": "binary"},
- }
+ "Body_create_files_files__post": {
+ "title": "Body_create_files_files__post",
+ "required": ["files"],
+ "type": "object",
+ "properties": {
+ "files": {
+ "title": "Files",
+ "type": "array",
+ "items": {"type": "string", "format": "binary"},
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/": {
- "post": {
- "summary": "Create Files",
- "operationId": "create_files_files__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_files_files__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/": {
+ "post": {
+ "summary": "Create Files",
+ "operationId": "create_files_files__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_files_files__post"
}
}
},
+ "required": True,
},
- },
- }
- },
- "/uploadfiles/": {
- "post": {
- "summary": "Create Upload Files",
- "operationId": "create_upload_files_uploadfiles__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ }
+ },
+ "/uploadfiles/": {
+ "post": {
+ "summary": "Create Upload Files",
+ "operationId": "create_upload_files_uploadfiles__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_upload_files_uploadfiles__post"
}
}
},
+ "required": True,
},
- },
- }
- },
- "/": {
- "get": {
- "summary": "Main",
- "operationId": "main__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- }
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
+ },
+ "/": {
+ "get": {
+ "summary": "Main",
+ "operationId": "main__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_create_files_files__post": {
- "title": "Body_create_files_files__post",
- "required": ["files"],
- "type": "object",
- "properties": {
- "files": {
- "title": "Files",
- "type": "array",
- "items": {"type": "string", "format": "binary"},
- "description": "Multiple files as bytes",
- }
+ "components": {
+ "schemas": {
+ "Body_create_files_files__post": {
+ "title": "Body_create_files_files__post",
+ "required": ["files"],
+ "type": "object",
+ "properties": {
+ "files": {
+ "title": "Files",
+ "type": "array",
+ "items": {"type": "string", "format": "binary"},
+ "description": "Multiple files as bytes",
+ }
+ },
},
- },
- "Body_create_upload_files_uploadfiles__post": {
- "title": "Body_create_upload_files_uploadfiles__post",
- "required": ["files"],
- "type": "object",
- "properties": {
- "files": {
- "title": "Files",
- "type": "array",
- "items": {"type": "string", "format": "binary"},
- "description": "Multiple files as UploadFile",
- }
+ "Body_create_upload_files_uploadfiles__post": {
+ "title": "Body_create_upload_files_uploadfiles__post",
+ "required": ["files"],
+ "type": "object",
+ "properties": {
+ "files": {
+ "title": "Files",
+ "type": "array",
+ "items": {"type": "string", "format": "binary"},
+ "description": "Multiple files as UploadFile",
+ }
+ },
},
- },
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login__post",
+ "requestBody": {
"content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "application/x-www-form-urlencoded": {
+ "schema": {"$ref": "#/components/schemas/FormData"}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {"$ref": "#/components/schemas/FormData"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "FormData": {
- "properties": {
- "username": {"type": "string", "title": "Username"},
- "password": {"type": "string", "title": "Password"},
+ },
+ "components": {
+ "schemas": {
+ "FormData": {
+ "properties": {
+ "username": {"type": "string", "title": "Username"},
+ "password": {"type": "string", "title": "Password"},
+ },
+ "type": "object",
+ "required": ["username", "password"],
+ "title": "FormData",
},
- "type": "object",
- "required": ["username", "password"],
- "title": "FormData",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login__post",
+ "requestBody": {
"content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "application/x-www-form-urlencoded": {
+ "schema": {"$ref": "#/components/schemas/FormData"}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {"$ref": "#/components/schemas/FormData"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "FormData": {
- "properties": {
- "username": {"type": "string", "title": "Username"},
- "password": {"type": "string", "title": "Password"},
+ },
+ "components": {
+ "schemas": {
+ "FormData": {
+ "properties": {
+ "username": {"type": "string", "title": "Username"},
+ "password": {"type": "string", "title": "Password"},
+ },
+ "additionalProperties": False,
+ "type": "object",
+ "required": ["username", "password"],
+ "title": "FormData",
},
- "additionalProperties": False,
- "type": "object",
- "required": ["username", "password"],
- "title": "FormData",
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/login/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/login/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_login__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_login__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_login__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_login__post"
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Body_login_login__post": {
- "title": "Body_login_login__post",
- "required": ["username", "password"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
+ },
+ "components": {
+ "schemas": {
+ "Body_login_login__post": {
+ "title": "Body_login_login__post",
+ "required": ["username", "password"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/files/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/files/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create File",
+ "operationId": "create_file_files__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "multipart/form-data": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_create_file_files__post"
}
}
},
+ "required": True,
},
- },
- "summary": "Create File",
- "operationId": "create_file_files__post",
- "requestBody": {
- "content": {
- "multipart/form-data": {
- "schema": {
- "$ref": "#/components/schemas/Body_create_file_files__post"
- }
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "Body_create_file_files__post": {
- "title": "Body_create_file_files__post",
- "required": ["file", "fileb", "token"],
- "type": "object",
- "properties": {
- "file": {"title": "File", "type": "string", "format": "binary"},
- "fileb": {
- "title": "Fileb",
- "type": "string",
- "format": "binary",
+ },
+ "components": {
+ "schemas": {
+ "Body_create_file_files__post": {
+ "title": "Body_create_file_files__post",
+ "required": ["file", "fileb", "token"],
+ "type": "object",
+ "properties": {
+ "file": {
+ "title": "File",
+ "type": "string",
+ "format": "binary",
+ },
+ "fileb": {
+ "title": "Fileb",
+ "type": "string",
+ "format": "binary",
+ },
+ "token": {"title": "Token", "type": "string"},
},
- "token": {"title": "Token", "type": "string"},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema_pv2(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/items/{id}": {
- "put": {
- "operationId": "update_item_items__id__put",
- "parameters": [
- {
- "in": "path",
- "name": "id",
- "required": True,
- "schema": {"title": "Id", "type": "string"},
- },
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- },
- },
- },
- "required": True,
- },
- "responses": {
- "200": {
- "content": {
- "application/json": {"schema": {}},
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/items/{id}": {
+ "put": {
+ "operationId": "update_item_items__id__put",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "id",
+ "required": True,
+ "schema": {"title": "Id", "type": "string"},
},
- "description": "Successful Response",
- },
- "422": {
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "$ref": "#/components/schemas/Item",
},
},
},
- "description": "Validation Error",
+ "required": True,
},
- },
- "summary": "Update Item",
- },
- },
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {"schema": {}},
+ },
+ "description": "Successful Response",
+ },
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
+ },
+ },
+ "description": "Validation Error",
},
- "title": "Detail",
- "type": "array",
},
+ "summary": "Update Item",
},
- "title": "HTTPValidationError",
- "type": "object",
},
- "Item": {
- "properties": {
- "description": {
- "anyOf": [
- {"type": "string"},
- {"type": "null"},
- ],
- "title": "Description",
- },
- "timestamp": {
- "format": "date-time",
- "title": "Timestamp",
- "type": "string",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
+ },
},
- "title": {"title": "Title", "type": "string"},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "required": [
- "title",
- "timestamp",
- ],
- "title": "Item",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
+ "Item": {
+ "properties": {
+ "description": {
"anyOf": [
{"type": "string"},
- {"type": "integer"},
+ {"type": "null"},
],
+ "title": "Description",
},
- "title": "Location",
- "type": "array",
+ "timestamp": {
+ "format": "date-time",
+ "title": "Timestamp",
+ "type": "string",
+ },
+ "title": {"title": "Title", "type": "string"},
+ },
+ "required": [
+ "title",
+ "timestamp",
+ ],
+ "title": "Item",
+ "type": "object",
+ },
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "integer"},
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {"title": "Message", "type": "string"},
+ "type": {"title": "Error Type", "type": "string"},
},
- "msg": {"title": "Message", "type": "string"},
- "type": {"title": "Error Type", "type": "string"},
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/legacy/": {
- "get": {
- "operationId": "get_legacy_data_legacy__get",
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/legacy/": {
+ "get": {
+ "operationId": "get_legacy_data_legacy__get",
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
},
+ "summary": "Get Legacy Data",
},
- "summary": "Get Legacy Data",
},
},
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {"$ref": "#/components/schemas/Item"},
- "title": "Response Read Items Items Get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ "title": "Response Read Items Items Get",
+ }
}
- }
- },
- },
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- },
- "post": {
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
},
},
},
- "required": True,
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
},
- "responses": {
- "200": {
- "description": "Successful Response",
+ "post": {
+ "requestBody": {
"content": {
"application/json": {
- "schema": {"$ref": "#/components/schemas/Item"},
- }
+ "schema": {
+ "$ref": "#/components/schemas/Item",
+ },
+ },
},
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"},
}
- }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
},
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- },
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "price": {"title": "Price", "type": "number"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
- },
- "tags": {
- "title": "Tags",
- "type": "array",
- "items": {"type": "string"},
- "default": [],
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "price": {"title": "Price", "type": "number"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "tags": {
+ "title": "Tags",
+ "type": "array",
+ "items": {"type": "string"},
+ "default": [],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/user/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/UserIn"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/user/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/UserIn"
+ }
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Create User",
+ "operationId": "create_user_user__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/UserIn"}
}
},
+ "required": True,
},
- },
- "summary": "Create User",
- "operationId": "create_user_user__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/UserIn"}
- }
- },
- "required": True,
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "UserIn": {
- "title": "UserIn",
- "required": ["username", "password", "email"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "password": {"title": "Password", "type": "string"},
- "email": {
- "title": "Email",
- "type": "string",
- "format": "email",
- },
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "UserIn": {
+ "title": "UserIn",
+ "required": ["username", "password", "email"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "password": {"title": "Password", "type": "string"},
+ "email": {
+ "title": "Email",
+ "type": "string",
+ "format": "email",
+ },
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.response_model.tutorial003_02_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/portal": {
- "get": {
- "summary": "Get Portal",
- "operationId": "get_portal_portal_get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Teleport",
- "type": "boolean",
- "default": False,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/portal": {
+ "get": {
+ "summary": "Get Portal",
+ "operationId": "get_portal_portal_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Teleport",
+ "type": "boolean",
+ "default": False,
+ },
+ "name": "teleport",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "teleport",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.response_model.tutorial003_03_py39 import app
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/teleport": {
- "get": {
- "summary": "Get Teleport",
- "operationId": "get_teleport_teleport_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/teleport": {
+ "get": {
+ "summary": "Get Teleport",
+ "operationId": "get_teleport_teleport_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/portal": {
- "get": {
- "summary": "Get Portal",
- "operationId": "get_portal_portal_get",
- "parameters": [
- {
- "required": False,
- "schema": {
- "title": "Teleport",
- "type": "boolean",
- "default": False,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/portal": {
+ "get": {
+ "summary": "Get Portal",
+ "operationId": "get_portal_portal_get",
+ "parameters": [
+ {
+ "required": False,
+ "schema": {
+ "title": "Teleport",
+ "type": "boolean",
+ "default": False,
+ },
+ "name": "teleport",
+ "in": "query",
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
},
- "name": "teleport",
- "in": "query",
- }
- ],
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "parameters": [
- {
- "name": "name",
- "in": "query",
- "required": True,
- "schema": {"title": "Name", "type": "string"},
- }
- ],
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "responses": {
- "201": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "parameters": [
+ {
+ "name": "name",
+ "in": "query",
+ "required": True,
+ "schema": {"title": "Name", "type": "string"},
+ }
+ ],
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "responses": {
+ "201": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "components": {
+ "schemas": {
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- # insert_assert(response.json())
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "name": "item_id",
- "in": "path",
- "required": True,
- "schema": {"type": "integer", "title": "Item Id"},
- }
- ],
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "name": "item_id",
+ "in": "path",
+ "required": True,
+ "schema": {"type": "integer", "title": "Item Id"},
}
- },
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
- },
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
},
- "price": {"type": "number", "title": "Price"},
- "tax": {
- "anyOf": [{"type": "number"}, {"type": "null"}],
- "title": "Tax",
+ "type": "object",
+ "title": "HTTPValidationError",
+ },
+ "Item": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
+ "price": {"type": "number", "title": "Price"},
+ "tax": {
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ "title": "Tax",
+ },
},
+ "type": "object",
+ "required": ["name", "price"],
+ "title": "Item",
+ "examples": [
+ {
+ "description": "A very nice Item",
+ "name": "Foo",
+ "price": 35.4,
+ "tax": 3.2,
+ }
+ ],
},
- "type": "object",
- "required": ["name", "price"],
- "title": "Item",
- "examples": [
- {
- "description": "A very nice Item",
- "name": "Foo",
- "price": 35.4,
- "tax": 3.2,
- }
- ],
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- # insert_assert(response.json())
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "name": "item_id",
- "in": "path",
- "required": True,
- "schema": {"type": "integer", "title": "Item Id"},
- }
- ],
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "name": "item_id",
+ "in": "path",
+ "required": True,
+ "schema": {"type": "integer", "title": "Item Id"},
}
- },
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
},
- },
- }
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
- },
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {
- "type": "string",
- "title": "Name",
- "examples": ["Foo"],
- },
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
- "examples": ["A very nice Item"],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "price": {
- "type": "number",
- "title": "Price",
- "examples": [35.4],
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
},
- "tax": {
- "anyOf": [{"type": "number"}, {"type": "null"}],
- "title": "Tax",
- "examples": [3.2],
+ "type": "object",
+ "title": "HTTPValidationError",
+ },
+ "Item": {
+ "properties": {
+ "name": {
+ "type": "string",
+ "title": "Name",
+ "examples": ["Foo"],
+ },
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ "examples": ["A very nice Item"],
+ },
+ "price": {
+ "type": "number",
+ "title": "Price",
+ "examples": [35.4],
+ },
+ "tax": {
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ "title": "Tax",
+ "examples": [3.2],
+ },
},
+ "type": "object",
+ "required": ["name", "price"],
+ "title": "Item",
},
- "type": "object",
- "required": ["name", "price"],
- "title": "Item",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- # insert_assert(response.json())
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "name": "item_id",
- "in": "path",
- "required": True,
- "schema": {"type": "integer", "title": "Item Id"},
- }
- ],
- "requestBody": {
- "required": True,
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- "examples": [
- {
- "description": "A very nice Item",
- "name": "Foo",
- "price": 35.4,
- "tax": 3.2,
- }
- ],
- },
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "name": "item_id",
+ "in": "path",
+ "required": True,
+ "schema": {"type": "integer", "title": "Item Id"},
}
- },
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
+ "required": True,
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "$ref": "#/components/schemas/Item",
+ "examples": [
+ {
+ "description": "A very nice Item",
+ "name": "Foo",
+ "price": 35.4,
+ "tax": 3.2,
+ }
+ ],
+ },
}
},
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
- },
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
},
- "price": {"type": "number", "title": "Price"},
- "tax": {
- "anyOf": [{"type": "number"}, {"type": "null"}],
- "title": "Tax",
+ "type": "object",
+ "title": "HTTPValidationError",
+ },
+ "Item": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
+ "price": {"type": "number", "title": "Price"},
+ "tax": {
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ "title": "Tax",
+ },
},
+ "type": "object",
+ "required": ["name", "price"],
+ "title": "Item",
},
- "type": "object",
- "required": ["name", "price"],
- "title": "Item",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/Item",
- "examples": [
- {
- "name": "Foo",
- "description": "A very nice Item",
- "price": 35.4,
- "tax": 3.2,
- },
- {"name": "Bar", "price": "35.4"},
- {
- "name": "Baz",
- "price": "thirty five point four",
- },
- ],
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
}
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ ],
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Item",
+ "examples": [
+ {
+ "name": "Foo",
+ "description": "A very nice Item",
+ "price": 35.4,
+ "tax": 3.2,
+ },
+ {"name": "Bar", "price": "35.4"},
+ {
+ "name": "Baz",
+ "price": "thirty five point four",
+ },
+ ],
}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
},
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/{item_id}": {
- "put": {
- "summary": "Update Item",
- "operationId": "update_item_items__item_id__put",
- "parameters": [
- {
- "required": True,
- "schema": {"title": "Item Id", "type": "integer"},
- "name": "item_id",
- "in": "path",
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"},
- "examples": {
- "normal": {
- "summary": "A normal example",
- "description": "A **normal** item works correctly.",
- "value": {
- "name": "Foo",
- "description": "A very nice Item",
- "price": 35.4,
- "tax": 3.2,
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/{item_id}": {
+ "put": {
+ "summary": "Update Item",
+ "operationId": "update_item_items__item_id__put",
+ "parameters": [
+ {
+ "required": True,
+ "schema": {"title": "Item Id", "type": "integer"},
+ "name": "item_id",
+ "in": "path",
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Item"},
+ "examples": {
+ "normal": {
+ "summary": "A normal example",
+ "description": "A **normal** item works correctly.",
+ "value": {
+ "name": "Foo",
+ "description": "A very nice Item",
+ "price": 35.4,
+ "tax": 3.2,
+ },
},
- },
- "converted": {
- "summary": "An example with converted data",
- "description": "FastAPI can convert price `strings` to actual `numbers` automatically",
- "value": {"name": "Bar", "price": "35.4"},
- },
- "invalid": {
- "summary": "Invalid data is rejected with an error",
- "value": {
- "name": "Baz",
- "price": "thirty five point four",
+ "converted": {
+ "summary": "An example with converted data",
+ "description": "FastAPI can convert price `strings` to actual `numbers` automatically",
+ "value": {"name": "Bar", "price": "35.4"},
+ },
+ "invalid": {
+ "summary": "Invalid data is rejected with an error",
+ "value": {
+ "name": "Baz",
+ "price": "thirty five point four",
+ },
},
},
- },
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "required": True,
},
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
}
- }
+ },
},
},
- },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
- },
- },
- "Item": {
- "title": "Item",
- "required": ["name", "price"],
- "type": "object",
- "properties": {
- "name": {"title": "Name", "type": "string"},
- "description": {
- "title": "Description",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
},
- "price": {"title": "Price", "type": "number"},
- "tax": {
- "title": "Tax",
- "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
+ "Item": {
+ "title": "Item",
+ "required": ["name", "price"],
+ "type": "object",
+ "properties": {
+ "name": {"title": "Name", "type": "string"},
+ "description": {
+ "title": "Description",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "price": {"title": "Price", "type": "number"},
+ "tax": {
+ "title": "Tax",
+ "anyOf": [{"type": "number"}, {"type": "null"}],
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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"},
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "security": [{"OAuth2PasswordBearer": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+ },
+ "components": {
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Users Me",
- "operationId": "read_users_me_users_me_get",
- "security": [{"OAuth2PasswordBearer": []}],
- }
- }
- },
- "components": {
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Users Me",
+ "operationId": "read_users_me_users_me_get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
}
},
- },
- }
+ "components": {
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+ }
+ },
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/token": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/token": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login",
+ "operationId": "login_token_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_token_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login",
- "operationId": "login_token_post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_token_post"
- }
+ }
+ },
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
}
},
- "required": True,
- },
- }
- },
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Users Me",
- "operationId": "read_users_me_users_me_get",
- "security": [{"OAuth2PasswordBearer": []}],
- }
+ "summary": "Read Users Me",
+ "operationId": "read_users_me_users_me_get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
+ },
},
- },
- "components": {
- "schemas": {
- "Body_login_token_post": {
- "title": "Body_login_token_post",
- "required": ["username", "password"],
- "type": "object",
- "properties": {
- "grant_type": {
- "title": "Grant Type",
- "anyOf": [
- {"pattern": "^password$", "type": "string"},
- {"type": "null"},
- ],
- },
- "username": {"title": "Username", "type": "string"},
- "password": {
- "title": "Password",
- "type": "string",
- "format": "password",
- },
- "scope": {"title": "Scope", "type": "string", "default": ""},
- "client_id": {
- "title": "Client Id",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "client_secret": {
- "title": "Client Secret",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "format": "password",
+ "components": {
+ "schemas": {
+ "Body_login_token_post": {
+ "title": "Body_login_token_post",
+ "required": ["username", "password"],
+ "type": "object",
+ "properties": {
+ "grant_type": {
+ "title": "Grant Type",
+ "anyOf": [
+ {"pattern": "^password$", "type": "string"},
+ {"type": "null"},
+ ],
+ },
+ "username": {"title": "Username", "type": "string"},
+ "password": {
+ "title": "Password",
+ "type": "string",
+ "format": "password",
+ },
+ "scope": {
+ "title": "Scope",
+ "type": "string",
+ "default": "",
+ },
+ "client_id": {
+ "title": "Client Id",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "client_secret": {
+ "title": "Client Secret",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "format": "password",
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
},
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
+ }
+ },
},
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {"password": {"scopes": {}, "tokenUrl": "token"}},
- }
- },
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
client = TestClient(mod.app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/token": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Token"}
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/token": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Token"}
+ }
+ },
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
},
},
- "422": {
- "description": "Validation Error",
+ "summary": "Login For Access Token",
+ "operationId": "login_for_access_token_token_post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
}
}
},
+ "required": True,
},
- },
- "summary": "Login For Access Token",
- "operationId": "login_for_access_token_token_post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
- }
+ }
+ },
+ "/users/me/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/User"}
+ }
+ },
}
},
- "required": True,
- },
- }
+ "summary": "Read Users Me",
+ "operationId": "read_users_me_users_me__get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
+ },
+ "/users/me/items/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Own Items",
+ "operationId": "read_own_items_users_me_items__get",
+ "security": [{"OAuth2PasswordBearer": []}],
+ }
+ },
},
- "/users/me/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/User"}
- }
+ "components": {
+ "schemas": {
+ "User": {
+ "title": "User",
+ "required": ["username"],
+ "type": "object",
+ "properties": {
+ "username": {"title": "Username", "type": "string"},
+ "email": {
+ "title": "Email",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "full_name": {
+ "title": "Full Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "disabled": {
+ "title": "Disabled",
+ "anyOf": [{"type": "boolean"}, {"type": "null"}],
},
- }
- },
- "summary": "Read Users Me",
- "operationId": "read_users_me_users_me__get",
- "security": [{"OAuth2PasswordBearer": []}],
- }
- },
- "/users/me/items/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Own Items",
- "operationId": "read_own_items_users_me_items__get",
- "security": [{"OAuth2PasswordBearer": []}],
- }
- },
- },
- "components": {
- "schemas": {
- "User": {
- "title": "User",
- "required": ["username"],
- "type": "object",
- "properties": {
- "username": {"title": "Username", "type": "string"},
- "email": {
- "title": "Email",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "full_name": {
- "title": "Full Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- },
- "disabled": {
- "title": "Disabled",
- "anyOf": [{"type": "boolean"}, {"type": "null"}],
},
},
- },
- "Token": {
- "title": "Token",
- "required": ["access_token", "token_type"],
- "type": "object",
- "properties": {
- "access_token": {"title": "Access Token", "type": "string"},
- "token_type": {"title": "Token Type", "type": "string"},
- },
- },
- "Body_login_for_access_token_token_post": {
- "title": "Body_login_for_access_token_token_post",
- "required": ["username", "password"],
- "type": "object",
- "properties": {
- "grant_type": {
- "title": "Grant Type",
- "anyOf": [
- {"pattern": "^password$", "type": "string"},
- {"type": "null"},
- ],
- },
- "username": {"title": "Username", "type": "string"},
- "password": {
- "title": "Password",
- "type": "string",
- "format": "password",
- },
- "scope": {"title": "Scope", "type": "string", "default": ""},
- "client_id": {
- "title": "Client Id",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "Token": {
+ "title": "Token",
+ "required": ["access_token", "token_type"],
+ "type": "object",
+ "properties": {
+ "access_token": {"title": "Access Token", "type": "string"},
+ "token_type": {"title": "Token Type", "type": "string"},
},
- "client_secret": {
- "title": "Client Secret",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "format": "password",
+ },
+ "Body_login_for_access_token_token_post": {
+ "title": "Body_login_for_access_token_token_post",
+ "required": ["username", "password"],
+ "type": "object",
+ "properties": {
+ "grant_type": {
+ "title": "Grant Type",
+ "anyOf": [
+ {"pattern": "^password$", "type": "string"},
+ {"type": "null"},
+ ],
+ },
+ "username": {"title": "Username", "type": "string"},
+ "password": {
+ "title": "Password",
+ "type": "string",
+ "format": "password",
+ },
+ "scope": {
+ "title": "Scope",
+ "type": "string",
+ "default": "",
+ },
+ "client_id": {
+ "title": "Client Id",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "client_secret": {
+ "title": "Client Secret",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "format": "password",
+ },
},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
},
+ "securitySchemes": {
+ "OAuth2PasswordBearer": {
+ "type": "oauth2",
+ "flows": {
+ "password": {
+ "scopes": {},
+ "tokenUrl": "token",
+ }
+ },
+ }
+ },
},
- "securitySchemes": {
- "OAuth2PasswordBearer": {
- "type": "oauth2",
- "flows": {
- "password": {
- "scopes": {},
- "tokenUrl": "token",
- }
- },
- }
- },
- },
- }
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBasic": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBasic": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/users/me": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Current User",
- "operationId": "read_current_user_users_me_get",
- "security": [{"HTTPBasic": []}],
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/users/me": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Current User",
+ "operationId": "read_current_user_users_me_get",
+ "security": [{"HTTPBasic": []}],
+ }
}
- }
- },
- "components": {
- "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
- },
- }
+ },
+ "components": {
+ "securitySchemes": {"HTTPBasic": {"type": "http", "scheme": "basic"}}
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "items": {"$ref": "#/components/schemas/Item"},
- "type": "array",
- "title": "Response Read Items Items Get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ "type": "array",
+ "title": "Response Read Items Items Get",
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
},
- },
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
+ "Item": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
},
+ "type": "object",
+ "required": ["name"],
+ "title": "Item",
},
- "type": "object",
- "required": ["name"],
- "title": "Item",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from ...utils import needs_py310
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "get": {
- "summary": "Read Items",
- "operationId": "read_items_items__get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "items": {"$ref": "#/components/schemas/Item"},
- "type": "array",
- "title": "Response Read Items Items Get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "get": {
+ "summary": "Read Items",
+ "operationId": "read_items_items__get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "items": {
+ "$ref": "#/components/schemas/Item"
+ },
+ "type": "array",
+ "title": "Response Read Items Items Get",
+ }
}
- }
- },
- }
- },
- },
- "post": {
- "summary": "Create Item",
- "operationId": "create_item_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Item"}
+ },
}
},
- "required": True,
},
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ "post": {
+ "summary": "Create Item",
+ "operationId": "create_item_items__post",
+ "requestBody": {
"content": {
"application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
- }
+ "schema": {"$ref": "#/components/schemas/Item"}
}
},
+ "required": True,
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
},
- },
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Item": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "description": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Description",
+ "Item": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "description": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Description",
+ },
},
+ "type": "object",
+ "required": ["name"],
+ "title": "Item",
},
- "type": "object",
- "required": ["name"],
- "title": "Item",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
import pytest
from dirty_equals import IsAnyStr
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import ValidationError
from pytest import MonkeyPatch
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/info": {
- "get": {
- "operationId": "info_info_get",
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Info",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/info": {
+ "get": {
+ "operationId": "info_info_get",
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Info",
+ }
}
- }
- },
- }
+ },
+ }
+ )
import pytest
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
@pytest.fixture(scope="module")
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {},
- }
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {},
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.sub_applications.tutorial001_py39 import app
client = TestClient(app)
-openapi_schema_main = {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/app": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Main",
- "operationId": "read_main_app_get",
- }
- }
- },
-}
-openapi_schema_sub = {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/sub": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Sub",
- "operationId": "read_sub_sub_get",
- }
- }
- },
- "servers": [{"url": "/subapi"}],
-}
-
-
-def test_openapi_schema_main():
- response = client.get("/openapi.json")
- assert response.status_code == 200, response.text
- assert response.json() == openapi_schema_main
-
def test_main():
response = client.get("/app")
assert response.json() == {"message": "Hello World from main app"}
-def test_openapi_schema_sub():
- response = client.get("/subapi/openapi.json")
- assert response.status_code == 200, response.text
- assert response.json() == openapi_schema_sub
-
-
def test_sub():
response = client.get("/subapi/sub")
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World from sub API"}
+
+
+def test_openapi_schema_main():
+ response = client.get("/openapi.json")
+ assert response.status_code == 200, response.text
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/app": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Main",
+ "operationId": "read_main_app_get",
+ }
+ }
+ },
+ }
+ )
+
+
+def test_openapi_schema_sub():
+ response = client.get("/subapi/openapi.json")
+ assert response.status_code == 200, response.text
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/sub": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Sub",
+ "operationId": "read_sub_sub_get",
+ }
+ }
+ },
+ "servers": [{"url": "/subapi"}],
+ }
+ )
+from inline_snapshot import snapshot
+
from docs_src.app_testing.app_a_py39.test_main import client, test_read_main
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Main",
- "operationId": "read_main__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Main",
+ "operationId": "read_main__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
+from inline_snapshot import snapshot
+
from docs_src.app_testing.tutorial001_py39 import client, test_read_main
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/": {
- "get": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- }
- },
- "summary": "Read Main",
- "operationId": "read_main__get",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ }
+ },
+ "summary": "Read Main",
+ "operationId": "read_main__get",
+ }
}
- }
- },
- }
+ },
+ }
+ )
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from docs_src.using_request_directly.tutorial001_py39 import app
def test_openapi():
response = client.get("/openapi.json")
assert response.status_code == 200
- assert response.json() == {
- "info": {
- "title": "FastAPI",
- "version": "0.1.0",
- },
- "openapi": "3.1.0",
- "paths": {
- "/items/{item_id}": {
- "get": {
- "operationId": "read_root_items__item_id__get",
- "parameters": [
- {
- "in": "path",
- "name": "item_id",
- "required": True,
- "schema": {
- "title": "Item Id",
- "type": "string",
+ assert response.json() == snapshot(
+ {
+ "info": {
+ "title": "FastAPI",
+ "version": "0.1.0",
+ },
+ "openapi": "3.1.0",
+ "paths": {
+ "/items/{item_id}": {
+ "get": {
+ "operationId": "read_root_items__item_id__get",
+ "parameters": [
+ {
+ "in": "path",
+ "name": "item_id",
+ "required": True,
+ "schema": {
+ "title": "Item Id",
+ "type": "string",
+ },
},
- },
- ],
- "responses": {
- "200": {
- "content": {
- "application/json": {
- "schema": {},
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {},
+ },
},
+ "description": "Successful Response",
},
- "description": "Successful Response",
- },
- "422": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/HTTPValidationError",
+ "422": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError",
+ },
},
},
+ "description": "Validation Error",
},
- "description": "Validation Error",
},
+ "summary": "Read Root",
},
- "summary": "Read Root",
},
},
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {
- "$ref": "#/components/schemas/ValidationError",
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError",
+ },
+ "title": "Detail",
+ "type": "array",
},
- "title": "Detail",
- "type": "array",
},
+ "title": "HTTPValidationError",
+ "type": "object",
},
- "title": "HTTPValidationError",
- "type": "object",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [
- {
- "type": "string",
- },
- {
- "type": "integer",
- },
- ],
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [
+ {
+ "type": "string",
+ },
+ {
+ "type": "integer",
+ },
+ ],
+ },
+ "title": "Location",
+ "type": "array",
+ },
+ "msg": {
+ "title": "Message",
+ "type": "string",
+ },
+ "type": {
+ "title": "Error Type",
+ "type": "string",
},
- "title": "Location",
- "type": "array",
- },
- "msg": {
- "title": "Message",
- "type": "string",
- },
- "type": {
- "title": "Error Type",
- "type": "string",
},
+ "required": [
+ "loc",
+ "msg",
+ "type",
+ ],
+ "title": "ValidationError",
+ "type": "object",
},
- "required": [
- "loc",
- "msg",
- "type",
- ],
- "title": "ValidationError",
- "type": "object",
},
},
- },
- }
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Save Union Body",
+ "operationId": "save_union_body_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Item",
+ "anyOf": [
+ {"$ref": "#/components/schemas/OtherItem"},
+ {"$ref": "#/components/schemas/Item"},
+ ],
}
}
},
+ "required": True,
},
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "OtherItem": {
+ "title": "OtherItem",
+ "required": ["price"],
+ "type": "object",
+ "properties": {"price": {"title": "Price", "type": "integer"}},
},
- "summary": "Save Union Body",
- "operationId": "save_union_body_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Item",
- "anyOf": [
- {"$ref": "#/components/schemas/OtherItem"},
- {"$ref": "#/components/schemas/Item"},
- ],
- }
+ "Item": {
+ "title": "Item",
+ "type": "object",
+ "properties": {
+ "name": {
+ "title": "Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
}
},
- "required": True,
},
- }
- }
- },
- "components": {
- "schemas": {
- "OtherItem": {
- "title": "OtherItem",
- "required": ["price"],
- "type": "object",
- "properties": {"price": {"title": "Price", "type": "integer"}},
- },
- "Item": {
- "title": "Item",
- "type": "object",
- "properties": {
- "name": {
- "title": "Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- }
- },
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
-
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/form-union/": {
- "post": {
- "summary": "Post Union Form",
- "operationId": "post_union_form_form_union__post",
- "requestBody": {
- "content": {
- "application/x-www-form-urlencoded": {
- "schema": {
- "anyOf": [
- {"$ref": "#/components/schemas/UserForm"},
- {"$ref": "#/components/schemas/CompanyForm"},
- ],
- "title": "Data",
- }
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/form-union/": {
+ "post": {
+ "summary": "Post Union Form",
+ "operationId": "post_union_form_form_union__post",
+ "requestBody": {
"content": {
- "application/json": {
+ "application/x-www-form-urlencoded": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "anyOf": [
+ {"$ref": "#/components/schemas/UserForm"},
+ {
+ "$ref": "#/components/schemas/CompanyForm"
+ },
+ ],
+ "title": "Data",
}
}
},
+ "required": True,
},
- },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ }
}
- }
- },
- "components": {
- "schemas": {
- "CompanyForm": {
- "properties": {
- "company_name": {"type": "string", "title": "Company Name"},
- "industry": {"type": "string", "title": "Industry"},
+ },
+ "components": {
+ "schemas": {
+ "CompanyForm": {
+ "properties": {
+ "company_name": {"type": "string", "title": "Company Name"},
+ "industry": {"type": "string", "title": "Industry"},
+ },
+ "type": "object",
+ "required": ["company_name", "industry"],
+ "title": "CompanyForm",
},
- "type": "object",
- "required": ["company_name", "industry"],
- "title": "CompanyForm",
- },
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "UserForm": {
- "properties": {
- "name": {"type": "string", "title": "Name"},
- "email": {"type": "string", "title": "Email"},
+ "UserForm": {
+ "properties": {
+ "name": {"type": "string", "title": "Name"},
+ "email": {"type": "string", "title": "Email"},
+ },
+ "type": "object",
+ "required": ["name", "email"],
+ "title": "UserForm",
},
- "type": "object",
- "required": ["name", "email"],
- "title": "UserForm",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {
- "/items/": {
- "post": {
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {
+ "/items/": {
+ "post": {
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
},
- "422": {
- "description": "Validation Error",
+ "summary": "Save Union Different Body",
+ "operationId": "save_union_different_body_items__post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "title": "Item",
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ExtendedItem"
+ },
+ {"$ref": "#/components/schemas/Item"},
+ ],
}
}
},
+ "required": True,
},
- },
- "summary": "Save Union Different Body",
- "operationId": "save_union_different_body_items__post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "title": "Item",
- "anyOf": [
- {"$ref": "#/components/schemas/ExtendedItem"},
- {"$ref": "#/components/schemas/Item"},
- ],
- }
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "Item": {
+ "title": "Item",
+ "type": "object",
+ "properties": {
+ "name": {
+ "title": "Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
}
},
- "required": True,
},
- }
- }
- },
- "components": {
- "schemas": {
- "Item": {
- "title": "Item",
- "type": "object",
- "properties": {
- "name": {
- "title": "Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
- }
- },
- },
- "ExtendedItem": {
- "title": "ExtendedItem",
- "required": ["age"],
- "type": "object",
- "properties": {
- "name": {
- "title": "Name",
- "anyOf": [{"type": "string"}, {"type": "null"}],
+ "ExtendedItem": {
+ "title": "ExtendedItem",
+ "required": ["age"],
+ "type": "object",
+ "properties": {
+ "name": {
+ "title": "Name",
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ },
+ "age": {"title": "Age", "type": "integer"},
},
- "age": {"title": "Age", "type": "integer"},
},
- },
- "ValidationError": {
- "title": "ValidationError",
- "required": ["loc", "msg", "type"],
- "type": "object",
- "properties": {
- "loc": {
- "title": "Location",
- "type": "array",
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "title": "ValidationError",
+ "required": ["loc", "msg", "type"],
+ "type": "object",
+ "properties": {
+ "loc": {
+ "title": "Location",
+ "type": "array",
+ "items": {
+ "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": {
- "title": "HTTPValidationError",
- "type": "object",
- "properties": {
- "detail": {
- "title": "Detail",
- "type": "array",
- "items": {"$ref": "#/components/schemas/ValidationError"},
- }
+ "HTTPValidationError": {
+ "title": "HTTPValidationError",
+ "type": "object",
+ "properties": {
+ "detail": {
+ "title": "Detail",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ }
+ },
},
- },
- }
- },
- }
+ }
+ },
+ }
+ )
from fastapi import FastAPI, Security
from fastapi.security import HTTPBearer
from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
from pydantic import BaseModel
app = FastAPI()
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
- # insert_assert(response.json())
- assert response.json() == {
- "openapi": "3.1.0",
- "info": {"title": "FastAPI", "version": "0.1.0"},
- "paths": {},
- "webhooks": {
- "new-subscription": {
- "post": {
- "summary": "New Subscription",
- "description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.",
- "operationId": "new_subscriptionnew_subscription_post",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {"$ref": "#/components/schemas/Subscription"}
- }
- },
- "required": True,
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {"application/json": {"schema": {}}},
- },
- "422": {
- "description": "Validation Error",
+ assert response.json() == snapshot(
+ {
+ "openapi": "3.1.0",
+ "info": {"title": "FastAPI", "version": "0.1.0"},
+ "paths": {},
+ "webhooks": {
+ "new-subscription": {
+ "post": {
+ "summary": "New Subscription",
+ "description": "When a new user subscribes to your service we'll send you a POST request with this\ndata to the URL that you register for the event `new-subscription` in the dashboard.",
+ "operationId": "new_subscriptionnew_subscription_post",
+ "requestBody": {
"content": {
"application/json": {
"schema": {
- "$ref": "#/components/schemas/HTTPValidationError"
+ "$ref": "#/components/schemas/Subscription"
}
}
},
+ "required": True,
},
- },
- "security": [{"HTTPBearer": []}],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {"application/json": {"schema": {}}},
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ },
+ },
+ },
+ "security": [{"HTTPBearer": []}],
+ }
}
- }
- },
- "components": {
- "schemas": {
- "HTTPValidationError": {
- "properties": {
- "detail": {
- "items": {"$ref": "#/components/schemas/ValidationError"},
- "type": "array",
- "title": "Detail",
- }
+ },
+ "components": {
+ "schemas": {
+ "HTTPValidationError": {
+ "properties": {
+ "detail": {
+ "items": {
+ "$ref": "#/components/schemas/ValidationError"
+ },
+ "type": "array",
+ "title": "Detail",
+ }
+ },
+ "type": "object",
+ "title": "HTTPValidationError",
},
- "type": "object",
- "title": "HTTPValidationError",
- },
- "Subscription": {
- "properties": {
- "username": {"type": "string", "title": "Username"},
- "monthly_fee": {"type": "number", "title": "Monthly Fee"},
- "start_date": {
- "type": "string",
- "format": "date-time",
- "title": "Start Date",
+ "Subscription": {
+ "properties": {
+ "username": {"type": "string", "title": "Username"},
+ "monthly_fee": {"type": "number", "title": "Monthly Fee"},
+ "start_date": {
+ "type": "string",
+ "format": "date-time",
+ "title": "Start Date",
+ },
},
+ "type": "object",
+ "required": ["username", "monthly_fee", "start_date"],
+ "title": "Subscription",
},
- "type": "object",
- "required": ["username", "monthly_fee", "start_date"],
- "title": "Subscription",
- },
- "ValidationError": {
- "properties": {
- "ctx": {"title": "Context", "type": "object"},
- "input": {"title": "Input"},
- "loc": {
- "items": {
- "anyOf": [{"type": "string"}, {"type": "integer"}]
+ "ValidationError": {
+ "properties": {
+ "ctx": {"title": "Context", "type": "object"},
+ "input": {"title": "Input"},
+ "loc": {
+ "items": {
+ "anyOf": [{"type": "string"}, {"type": "integer"}]
+ },
+ "type": "array",
+ "title": "Location",
},
- "type": "array",
- "title": "Location",
+ "msg": {"type": "string", "title": "Message"},
+ "type": {"type": "string", "title": "Error Type"},
},
- "msg": {"type": "string", "title": "Message"},
- "type": {"type": "string", "title": "Error Type"},
+ "type": "object",
+ "required": ["loc", "msg", "type"],
+ "title": "ValidationError",
},
- "type": "object",
- "required": ["loc", "msg", "type"],
- "title": "ValidationError",
},
+ "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}},
},
- "securitySchemes": {"HTTPBearer": {"type": "http", "scheme": "bearer"}},
- },
- }
+ }
+ )