Skip to content

--specify-tags not working #488

@abhikedia

Description

@abhikedia

--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 Service

Each endpoint is properly tagged. For example:

/ai/health:
  get:
    tags:
      - AIService
      - Health

Generated 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions