1818from aiopenapi3 import OpenAPI
1919from aiopenapi3 .v31 .schemas import Schema
2020
21- from api .main import app
2221from api .v2 .schema import Dog as _Dog
2322
2423# pytest.skip(allow_module_level=True)
2524
25+ from fastapi import FastAPI
2626from fastapi .responses import PlainTextResponse
2727
2828
29+ from api .v2 .main import router
30+
31+ app = FastAPI (
32+ version = "1.0.0" , title = "Dorthu's Petstore" , servers = [{"url" : "/" , "description" : "Default, relative server" }]
33+ )
34+ app .include_router (router )
35+
36+
2937@app .exception_handler (Exception )
3038async def validation_exception_handler (request , exc ):
3139 return PlainTextResponse (str (exc ), status_code = 400 )
@@ -50,25 +58,20 @@ async def server(config):
5058 await task
5159
5260
53- @pytest .fixture (scope = "session" , params = [2 ])
54- def version (request ):
55- return f"v{ request .param } "
56-
57-
5861from aiopenapi3 .debug import DescriptionDocumentDumper
5962
6063
6164@pytest_asyncio .fixture (loop_scope = "session" )
62- async def client (server , version ):
63- url = f"http://{ server .bind [0 ]} /{ version } / openapi.json"
65+ async def client (server ):
66+ url = f"http://{ server .bind [0 ]} /openapi.json"
6467
6568 api = await aiopenapi3 .OpenAPI .load_async (url , plugins = [DescriptionDocumentDumper ("/tmp/schema.yaml" )])
6669 return api
6770
6871
6972@pytest .mark .asyncio (loop_scope = "session" )
7073@pytest .mark .xfail ()
71- def test_Pet ():
74+ async def test_Pet ():
7275
7376 data = _Dog .model_json_schema ()
7477 # print(json.dumps(data, indent=True))
@@ -80,15 +83,15 @@ def test_Pet():
8083
8184
8285@pytest .mark .asyncio (loop_scope = "session" )
83- async def test_sync (server , version ):
84- url = f"http://{ server .bind [0 ]} /{ version } / openapi.json"
86+ async def test_sync (server ):
87+ url = f"http://{ server .bind [0 ]} /openapi.json"
8588 api = await asyncio .to_thread (aiopenapi3 .OpenAPI .load_sync , url )
8689 return api
8790
8891
8992@pytest .mark .asyncio (loop_scope = "session" )
90- async def test_description_document (server , version ):
91- url = f"http://{ server .bind [0 ]} /{ version } / openapi.json"
93+ async def test_description_document (server ):
94+ url = f"http://{ server .bind [0 ]} /openapi.json"
9295 api = await aiopenapi3 .OpenAPI .load_async (url )
9396 return api
9497
0 commit comments