Coverage for tests / test_openapi_route_extensions.py: 100%
16 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1from fastapi import FastAPI 1abcd
2from fastapi.testclient import TestClient 1abcd
3from inline_snapshot import snapshot 1abcd
5app = FastAPI() 1abcd
8@app.get("/", openapi_extra={"x-custom-extension": "value"}) 1abcd
9def route_with_extras(): 1abcd
10 return {} 1efg
13client = TestClient(app) 1abcd
16def test_get_route(): 1abcd
17 response = client.get("/") 1efg
18 assert response.status_code == 200, response.text 1efg
19 assert response.json() == {} 1efg
22def test_openapi_schema(): 1abcd
23 response = client.get("/openapi.json") 1hij
24 assert response.status_code == 200, response.text 1hij
25 assert response.json() == snapshot( 1hij
26 {
27 "openapi": "3.1.0",
28 "info": {"title": "FastAPI", "version": "0.1.0"},
29 "paths": {
30 "/": {
31 "get": {
32 "responses": {
33 "200": {
34 "description": "Successful Response",
35 "content": {"application/json": {"schema": {}}},
36 },
37 },
38 "summary": "Route With Extras",
39 "operationId": "route_with_extras__get",
40 "x-custom-extension": "value",
41 }
42 },
43 },
44 }
45 )