Coverage for tests / test_openapi_model_description_trim_on_formfeed.py: 100%

11 statements  

« 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 pydantic import BaseModel 1abcd

4 

5app = FastAPI() 1abcd

6 

7 

8class MyModel(BaseModel): 1abcd

9 """ 

10 A model with a form feed character in the title. 

11 \f 

12 Text after form feed character. 

13 """ 

14 

15 

16@app.get("/foo") 1abcd

17def foo(v: MyModel): # pragma: no cover 1abcd

18 pass 

19 

20 

21client = TestClient(app) 1abcd

22 

23 

24def test_openapi(): 1abcd

25 response = client.get("/openapi.json") 1efg

26 assert response.status_code == 200, response.text 1efg

27 openapi_schema = response.json() 1efg

28 

29 assert openapi_schema["components"]["schemas"]["MyModel"]["description"] == ( 1efg

30 "A model with a form feed character in the title.\n" 

31 )