File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ def __get_pydantic_json_schema__(
186186 ) -> _t .Any :
187187 # until https://github.com/pydantic/pydantic/issues/8413 is fixed
188188 json_schema = handler (core_schema )
189- json_schema [ 'required' ] .append ('links' )
189+ json_schema . setdefault ( 'required' , []) .append ('links' )
190190 return json_schema
191191
192192
Original file line number Diff line number Diff line change 11from dirty_equals import IsPartialDict
2- from fastui import FastUI
2+ from fastapi import FastAPI
3+ from fastui import FastUI , components
34from fastui .generate_typescript import generate_json_schema
5+ from httpx import AsyncClient
46
57
68async def test_json_schema ():
@@ -12,3 +14,25 @@ async def test_json_schema():
1214 'type' : 'array' ,
1315 }
1416 # TODO test more specific cases
17+
18+
19+ async def test_openapi ():
20+ app = FastAPI ()
21+
22+ @app .get ('/api/' , response_model = FastUI , response_model_exclude_none = True )
23+ def test_endpoint ():
24+ return [components .Text (text = 'hello' )]
25+
26+ async with AsyncClient (app = app , base_url = 'http://test' ) as client :
27+ r = await client .get ('/openapi.json' )
28+ assert r .status_code == 200
29+ assert r .headers ['content-type' ] == 'application/json'
30+ assert r .json () == {
31+ 'openapi' : '3.1.0' ,
32+ 'info' : {
33+ 'title' : 'FastAPI' ,
34+ 'version' : '0.1.0' ,
35+ },
36+ 'paths' : IsPartialDict (),
37+ 'components' : IsPartialDict (),
38+ }
You can’t perform that action at this time.
0 commit comments