From 1bcd7c0f1f4a24b3159cc186a06582516ca3a98a Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Sat, 27 Sep 2025 15:59:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Clarify=20routes.router?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++--- src/ohmyapi/core/templates/app/routes.py.j2 | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e0b585..5cc6ec8 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,10 @@ from ohmyapi.db.exceptions import DoesNotExist from .models import Tournament -# If .routes.router exists and is an APIRouter, OhMyAPI will -# automatically pick it up and add it to the app's main APIRouter. -router = APIRouter(prefix="/tournament") +# Expose your app's routes via `router = fastapi.APIRouter`. +# Use prefixes wisely to avoid cross-app namespace-collisions. +# Tags improve the UX of the OpenAPI docs at /docs. +router = APIRouter(prefix="/tournament", tags=['Tournament']) @router.get("/") diff --git a/src/ohmyapi/core/templates/app/routes.py.j2 b/src/ohmyapi/core/templates/app/routes.py.j2 index d6651bb..1e4d792 100644 --- a/src/ohmyapi/core/templates/app/routes.py.j2 +++ b/src/ohmyapi/core/templates/app/routes.py.j2 @@ -1,11 +1,15 @@ from ohmyapi.router import APIRouter + from . import models -router = APIRouter(prefix="/{{ app_name }}") +# Expose your app's routes via `router = fastapi.APIRouter`. +# Use prefixes wisely to avoid cross-app namespace-collisions. +# Tags improve the UX of the OpenAPI docs at /docs. +router = APIRouter(prefix="/{{ app_name }}", tags=[{{ app_name }}]) @router.get("/") -def ping(): +def hello_world(): return { "project": "{{ project_name }}", "app": "{{ app_name }}",