From 4a90370e1cf3421655de3cf571668918c617ff57 Mon Sep 17 00:00:00 2001 From: Matthew Evans <7916000+ml-evs@users.noreply.github.com> Date: Sat, 2 Nov 2024 12:03:30 +0000 Subject: [PATCH] Serve API under prefixed URLs for API version (major.minor) and full repo version (major.minor.patch) (#21) --- yard/__init__.py | 2 +- yard/app.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/yard/__init__.py b/yard/__init__.py index 409f9ca..63c7433 100644 --- a/yard/__init__.py +++ b/yard/__init__.py @@ -1,4 +1,4 @@ from importlib.metadata import version __version__ = version("datatractor-yard") -__api_version__ = __version__ +__api_version__ = ".".join(__version__.split(".")[0:2]) diff --git a/yard/app.py b/yard/app.py index 0226e4a..ea5de03 100644 --- a/yard/app.py +++ b/yard/app.py @@ -12,7 +12,7 @@ from fastapi.templating import Jinja2Templates from pydantic import BaseModel -from yard import __api_version__ +from yard import __api_version__, __version__ from .models import Extractor, FileType from .utils import load_registry_collection @@ -200,7 +200,9 @@ async def load_data(): _get_info() +# Serve API under API version (vX.Y) and full API+data version (vX.Y.Z) app.mount(f"/api/v{__api_version__}", api) +app.mount(f"/api/v{__version__}", api) app.mount("/api/", api)