Skip to content

Conversation

@MauricioReisdoefer
Copy link

@MauricioReisdoefer MauricioReisdoefer commented Oct 11, 2025

Description

This PR introduces a --format option for the litestar routes CLI command, allowing routes to be output in a structured JSON format. This is useful for automation, scripts, or integration with external tools.

Usage Example

Example usage:

```bash
$ litestar routes --format=json
[
  {
    "name": h.name,
    "path": h.paths,
    "handler": h.handler_name,
    "methods": sorted(h.http_methods),
    "async": inspect.iscoroutinefunction(unwrap_partial(h.fn))  
  },
]

Motivation and Context

Closing issue #4417. This change allows developers to easily consume route information programmatically, improving automation and tooling support.

Also i added new tests to cover this new feature.

Closes

Copy link
Member

@provinzkraut provinzkraut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add a --format option, with json as a choice, as that is more extendable.

@MauricioReisdoefer
Copy link
Author

I agree. But first i'll fix the unpassed tests.

@MauricioReisdoefer MauricioReisdoefer changed the title FEAT: Adding new --json option in routes CLI command for JSON format feat: Adding new --json option in routes CLI command for JSON format Oct 11, 2025
@MauricioReisdoefer MauricioReisdoefer changed the title feat: Adding new --json option in routes CLI command for JSON format feat: Adding new --json option in routes CLI command for JSON format (#4417) Oct 11, 2025
@codecov
Copy link

codecov bot commented Oct 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (d87e20f) to head (c869c2d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4418      +/-   ##
==========================================
- Coverage   97.83%   97.83%   -0.01%     
==========================================
  Files         296      296              
  Lines       15295    15317      +22     
  Branches     1713     1718       +5     
==========================================
+ Hits        14964    14985      +21     
  Misses        189      189              
- Partials      142      143       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@provinzkraut
Copy link
Member

@MauricioReisdoefer if you want to get this merged, please address the changes I've requested regarding the flag.

@MauricioReisdoefer MauricioReisdoefer changed the title feat: Adding new --json option in routes CLI command for JSON format (#4417) feat: Adding new --format option in routes CLI command for JSON format (#4417) Oct 22, 2025
@MauricioReisdoefer
Copy link
Author

Do you want any more changes in this pr? Like, creating a new format already? Because i want to start contributing in other parts after this pr.

@github-actions
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants