Skip to main content
ant generate subroute appends a new endpoint to an existing route’s Blueprint, and adds corresponding methods to the service and repository.

Syntax

ant generate subroute <route> <subroute> [--type METHOD] [--mock <json>]
Run this command from the project root. The parent route must already exist.

Arguments

ArgumentDescription
routeName of the existing parent route (e.g. users)
subrouteName of the new endpoint (e.g. profile, create)

Options

OptionDescription
--type METHODHTTP method: GET or POST (case-insensitive). Default: GET.
--mock <json>JSON string or file path. Injected as the mock return value in the service.

Examples

GET subroute

ant generate subroute users profile
Creates GET /users/profile.

POST subroute

ant generate subroute users create --type POST
Creates POST /users/create.

POST with mock data

ant generate subroute users create --type POST --mock '{"id": 3, "name": "Charlie"}'

GET with mock file

ant generate subroute orders items --mock items.json

Machine-readable output

ant --report generate subroute users profile

Files modified

FileChange
api/routes/users_route.pyAppends @users_bp.get("/profile") or .post("/create") with handler function
api/services/users_service.pyAdds get_profile() (GET) or create_create(data) (POST)
api/repositories/users_repository.pyAdds get_profile() (GET) or add_create(data) (POST)

Generated method naming

HTTP methodService methodRepository method
GETget_<subroute>()get_<subroute>()
POSTcreate_<subroute>(data)add_<subroute>(data)

Pre-conditions

The parent route files must exist. If not:
Error: Route 'users' does not exist. Please generate the main route first using:
  ant generate route users

Duplicate detection

If the subroute method already exists in the route file, a warning is printed and the file is left unchanged:
Warning: Subroute 'profile' already exists in api/routes/users_route.py

Success output

Successfully generated GET subroute 'profile' for route 'users'!
Successfully generated POST subroute 'create' for route 'users' with mock data!