Coverage for tests/test_openapi_route_extensions.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi import FastAPI 1abcde
2from fastapi.testclient import TestClient 1abcde
4app = FastAPI() 1abcde
7@app.get("/", openapi_extra={"x-custom-extension": "value"}) 1abcde
8def route_with_extras(): 1abcde
9 return {} 1abcde
12client = TestClient(app) 1abcde
15def test_get_route(): 1abcde
16 response = client.get("/") 1abcde
17 assert response.status_code == 200, response.text 1abcde
18 assert response.json() == {} 1abcde
21def test_openapi(): 1abcde
22 response = client.get("/openapi.json") 1abcde
23 assert response.status_code == 200, response.text 1abcde
24 assert response.json() == { 1abcde
25 "openapi": "3.1.0",
26 "info": {"title": "FastAPI", "version": "0.1.0"},
27 "paths": {
28 "/": {
29 "get": {
30 "responses": {
31 "200": {
32 "description": "Successful Response",
33 "content": {"application/json": {"schema": {}}},
34 },
35 },
36 "summary": "Route With Extras",
37 "operationId": "route_with_extras__get",
38 "x-custom-extension": "value",
39 }
40 },
41 },
42 }