-
-
Notifications
You must be signed in to change notification settings - Fork 485
Open
Labels
EnhancementThis is a new feature or requestThis is a new feature or request
Description
Summary
Feature Request: Add --json Option to routes Command
Description
Currently, the routes command outputs the list of application routes in a human-readable table format.
It would be useful to add a --json flag to allow users to export the routes in JSON format, making it easier to programmatically consume the route information.
Proposed Solution
- Add a
--jsonoption to theroutesCLI command. - When
--jsonis provided, output the list of routes as a JSON array instead of the default table. - Ensure that the JSON output includes all relevant route details (e.g., path, methods, name, handler, etc.).
- Update or add tests to validate JSON output.
Benefits
- Programmatic access to route data for tooling or documentation generation.
- Improves automation and integration with other tools.
Additional Context
This feature is especially useful for larger applications where manual inspection of routes is cumbersome, or when generating automated documentation.
Basic Example
Example Usage
$ litestar routes --json
[
{
"name": h.name,
"path": h.paths,
"handler": h.handler_name,
"methods": sorted(h.http_methods),
"async": inspect.iscoroutinefunction(unwrap_partial(h.fn))
},
]Drawbacks and Impact
Drawbacks
Some drawbacks only occurs in particular cases.
- Potential for sensitive information exposure
- Performance impact
- Maintenance overhead
Unresolved questions
No response
FHU-yezi
Metadata
Metadata
Assignees
Labels
EnhancementThis is a new feature or requestThis is a new feature or request