Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ dev = [
"pytest-cov",
"pytest-mock",
"fastapi",
"fastapi-versioning",
"uvloop",
"flask",
"flask_wtf",
Expand Down
31 changes: 16 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# This file was autogenerated by uv via the following command:
# uv export --no-dev --no-hashes --no-editable -o requirements.txt
.
annotated-types==0.7.0
annotated-types==0.8.0
# via pydantic
anyio==4.13.0
anyio==4.14.2
# via httpx2
certifi==2026.4.22
# via
# httpcore2
# httpx2
dnspython==2.8.0
# via email-validator
email-validator==2.3.0
Expand All @@ -17,44 +13,49 @@ exceptiongroup==1.3.1 ; python_full_version < '3.11'
# via anyio
h11==0.16.0
# via httpcore2
httpcore2==2.2.0
httpcore2==2.9.0
# via httpx2
httpx2==2.2.0
httpx2==2.9.0
# via aiopenapi3
idna==3.15
idna==3.18
# via
# anyio
# email-validator
# httpx2
# yarl
ijson==3.5.0
ijson==3.5.1
# via aiopenapi3
jmespath==1.1.0
# via aiopenapi3
jsonseq==1.0.0
# via aiopenapi3
more-itertools==11.0.2
more-itertools==11.1.0
# via aiopenapi3
multidict==6.7.1
# via yarl
propcache==0.5.2
# via yarl
pydantic==2.13.4
pydantic==2.14.0a1
# via aiopenapi3
pydantic-core==2.46.4
pydantic-core==2.47.0
# via pydantic
pyyaml==6.0.3
# via aiopenapi3
typing-extensions==4.15.0
truststore==0.10.4
# via
# httpcore2
# httpx2
typing-extensions==4.16.0
# via
# aiopenapi3
# anyio
# exceptiongroup
# httpx2
# multidict
# pydantic
# pydantic-core
# typing-inspection
typing-inspection==0.4.2
# via pydantic
yarl==1.23.0
yarl==1.24.5
# via aiopenapi3
17 changes: 0 additions & 17 deletions tests/api/main.py

This file was deleted.

5 changes: 1 addition & 4 deletions tests/api/v1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

from .schema import Pets, Pet, PetCreate, Error


from fastapi_versioning import versioned_api_route

router = APIRouter(route_class=versioned_api_route(1))
router = APIRouter(prefix="/v1")


ZOO = dict()
Expand Down
5 changes: 1 addition & 4 deletions tests/api/v2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

from . import schema

from fastapi_versioning import versioned_api_route


router = APIRouter(route_class=versioned_api_route(2))
router = APIRouter(prefix="/v2")

ZOO = dict()

Expand Down
11 changes: 9 additions & 2 deletions tests/apiv1_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
from hypercorn.asyncio import serve
from hypercorn.config import Config

from fastapi import FastAPI

import aiopenapi3

# pytest.skip(allow_module_level=True)

from api.main import app
from api.v1.main import router

app = FastAPI(
version="1.0.0", title="Dorthu's Petstore", servers=[{"url": "/", "description": "Default, relative server"}]
)
app.include_router(router)


@pytest.fixture(scope="session")
Expand All @@ -35,7 +42,7 @@ async def server(config):

@pytest_asyncio.fixture(loop_scope="session")
async def client(server):
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, f"http://{server.bind[0]}/v1/openapi.json")
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, f"http://{server.bind[0]}/openapi.json")
return api


Expand Down
29 changes: 16 additions & 13 deletions tests/apiv2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@
from aiopenapi3 import OpenAPI
from aiopenapi3.v31.schemas import Schema

from api.main import app
from api.v2.schema import Dog as _Dog

# pytest.skip(allow_module_level=True)

from fastapi import FastAPI
from fastapi.responses import PlainTextResponse


from api.v2.main import router

app = FastAPI(
version="1.0.0", title="Dorthu's Petstore", servers=[{"url": "/", "description": "Default, relative server"}]
)
app.include_router(router)


@app.exception_handler(Exception)
async def validation_exception_handler(request, exc):
return PlainTextResponse(str(exc), status_code=400)
Expand All @@ -50,25 +58,20 @@ async def server(config):
await task


@pytest.fixture(scope="session", params=[2])
def version(request):
return f"v{request.param}"


from aiopenapi3.debug import DescriptionDocumentDumper


@pytest_asyncio.fixture(loop_scope="session")
async def client(server, version):
url = f"http://{server.bind[0]}/{version}/openapi.json"
async def client(server):
url = f"http://{server.bind[0]}/openapi.json"

api = await aiopenapi3.OpenAPI.load_async(url, plugins=[DescriptionDocumentDumper("/tmp/schema.yaml")])
return api


@pytest.mark.asyncio(loop_scope="session")
@pytest.mark.xfail()
def test_Pet():
async def test_Pet():

data = _Dog.model_json_schema()
# print(json.dumps(data, indent=True))
Expand All @@ -80,15 +83,15 @@ def test_Pet():


@pytest.mark.asyncio(loop_scope="session")
async def test_sync(server, version):
url = f"http://{server.bind[0]}/{version}/openapi.json"
async def test_sync(server):
url = f"http://{server.bind[0]}/openapi.json"
api = await asyncio.to_thread(aiopenapi3.OpenAPI.load_sync, url)
return api


@pytest.mark.asyncio(loop_scope="session")
async def test_description_document(server, version):
url = f"http://{server.bind[0]}/{version}/openapi.json"
async def test_description_document(server):
url = f"http://{server.bind[0]}/openapi.json"
api = await aiopenapi3.OpenAPI.load_async(url)
return api

Expand Down
Loading