Skip to content

Make the http flag correct for Go (Gin: suppress) and Python (FastAPI: no-op + document override) #95

Description

@cultron

Summary

Make the per-entity http flag (#93) behave correctly in the Go (Gin) and Python (FastAPI) generators. The flag is generic — it only does real work where a generated route can't be cleanly overridden. So the two languages need different follow-ups:

Generator Can override a generated route without suppressing? What http: false must do
NestJS (done, #93) No Suppress the controller
Go / Gin NoRegisterAllRoutes loops handlers and Gin panics on a duplicate method+path Implement suppression (real action)
Python / FastAPI Yesmain.py includes autogen_router; FastAPI matches in registration order, so an app router registered first shadows the generated route No-op + document the override pattern

Current state (after #93 / PR #94)

Entity.http (+ top-level default) is parsed generically. In generate.ts the controller skip is scoped to language === "typescript", so for Go and Python the flag is currently a no-op (controllers always generated — safe, no broken output).

Work

Go (Gin) — implement suppression

When http: false for an entity: don't generate its handler/routes and don't register them in RegisterAllRoutes (src/lib/templates/go/index-module.eta + the handler template), while still emitting the model and service. Then extend the generate.ts guard to include go. Tests mirroring the TS ones.

Python (FastAPI) — no-op + document override

http: false should remain a no-op for FastAPI (don't suppress). Instead document the idiomatic override: register your APIRouter for the path before autogen_router is included in main.py (first match wins). Optionally emit an informational notice if http: false is set on a FastAPI entity, pointing at the override pattern. Covered in the custom-endpoints skill (see below).

Docs

Add a per-framework "replacing a generated endpoint" section to the custom-endpoints skill (apsoai/skills): NestJS → http: false + write the controller; Gin → http: false; FastAPI → register your router ahead of autogen_router (no flag).

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions