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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.13.0
current_version = 1.13.1
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rasenmaeher_api"
version = "1.13.0"
version = "1.13.1"
description = "python-rasenmaeher-api"
authors = [
"Aciid <703382+Aciid@users.noreply.github.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/rasenmaeher_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""python-rasenmaeher-api"""

__version__ = "1.13.0" # NOTE Use `bump2version --config-file patch` to bump versions correctly
__version__ = "1.13.1" # NOTE Use `bump2version --config-file patch` to bump versions correctly
20 changes: 19 additions & 1 deletion src/rasenmaeher_api/web/application.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Main API entrypoint"""

from typing import AsyncGenerator
from typing import AsyncGenerator, Dict, Any
import asyncio
import datetime
import logging
from contextlib import asynccontextmanager

from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from libpvarki.logging import init_logging, add_trace_and_audit
import aiohttp
from libadvian.tasks import TaskMaster
Expand Down Expand Up @@ -50,6 +52,22 @@ def get_app_no_init() -> FastAPI:
app.include_router(router=api_router_v2, prefix="/api/v2")
# FIXME: figure out WTF mypy wants here, or has FastAPI changed something ?
app.add_middleware(DBConnectionMiddleware, config=DBConfig.singleton()) # type: ignore

def custom_openapi() -> Dict[str, Any]:
"""Return OpenAPI schema enriched with a generation timestamp."""
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
title=app.title,
version=app.version,
description=app.description,
routes=app.routes,
)
openapi_schema["x-generated-date"] = datetime.datetime.now(datetime.timezone.utc).isoformat()
app.openapi_schema = openapi_schema
return app.openapi_schema

app.openapi = custom_openapi # type: ignore[method-assign]
return app


Expand Down
2 changes: 1 addition & 1 deletion tests/test_rasenmaeher_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def test_version() -> None:
"""Make sure version matches expected"""
assert __version__ == "1.13.0"
assert __version__ == "1.13.1"


@pytest.mark.asyncio(loop_scope="session")
Expand Down