-
-
Notifications
You must be signed in to change notification settings - Fork 144
Description
--specify-tags option not filtering routes as expected
Description
The --specify-tags option in fastapi-code-generator doesn't seem to filter routes as expected. When I specify a tag, all routers are still generated regardless of the specified tag.
Environment Information
- fastapi-code-generator version: 0.5.3
- Python version: 3.9
- OS: macOS
Current Behavior
When using the --specify-tags option to filter routes by tag name, all routes are still generated regardless of the specified tags.
For example, when running:
python3 -m fastapi_code_generator \
--input "openapi-bundle.yaml" \
--output apps/ai-service/app/models \
--generate-routers \
--specify-tags "AIService"I expect only routes with the "AIService" tag to be generated, but I still see all routes including those tagged with "Gateway", "Health", and "Fake Path".
Expected Behavior
When specifying --specify-tags "AIService", only routes with that tag should be included in the generated code, and routers for other tags should not be generated.
OpenAPI Specification Sample
From our root.yaml, we have defined tags:
tags:
- name: Fake Path
description: Fake path to include all the models
- name: Health
description: Health check endpoints
- name: Authentication
description: Authentication related endpoints
- name: Gateway
description: APIs related to public gateway
- name: AIService
description: APIs related to AI ServiceEach endpoint is properly tagged. For example:
/ai/health:
get:
tags:
- AIService
- HealthGenerated Code Overview
The generated code includes all routers:
# In main.py
from .routers import aiservice, fake_path, gateway, health
app = FastAPI(...)
app.include_router(aiservice.router)
app.include_router(fake_path.router)
app.include_router(gateway.router)
app.include_router(health.router)Additional Notes
- I've verified the OpenAPI spec is correctly tagging each endpoint
- The issue persists even after updating to the latest version
- The script has the proper syntax with line continuation () for all options