ash_json_api icon indicating copy to clipboard operation
ash_json_api copied to clipboard

See all project's routes with a simple command

Open gcugnet opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. It is always useful to have a global and concise view of all routes available on your project.

Describe the solution you'd like It would be nice to be able to see the routes in you app's default router + the routes generated from Ash framework in a single view. Something like

mix phx.route

But which would show Ash generated routes in addition to the default router's "hand-written" routes.

Describe alternatives you've considered For now we can use the command described in the AshJsonApi doc:

AshJsonApi.Resource.Info.routes/1

source = https://hexdocs.pm/ash_json_api/getting-started-with-json-api.html#run-your-api

Express the feature either with a change to resource syntax, or with a change to the resource interface

I don’t know.

Additional context

I have nothing more to say.

gcugnet avatar Apr 30 '24 13:04 gcugnet

Great idea :)

zachdaniel avatar Apr 30 '24 16:04 zachdaniel

@zachdaniel I'd like to tackle this one, just need a few pointers: I reckon it should be similar to phx.routes task but it gets all domains (which function should I use for that) and calls the function above on them, extract routes and print similar to phx.routes.

Not sure how to get domains. Also, an argument --domain Domain would scope to that domain; or maybe the argument would be required to get the domain? wdyt?

ken-kost avatar Jan 24 '25 12:01 ken-kost

Yep! You could take a look at how the task is implemented in AshAuthentication as well. That should be a basis for this :)

zachdaniel avatar Jan 24 '25 14:01 zachdaniel

We could then add an alias for mix phx.routes that calls this task after calling phx.routes 🎉

zachdaniel avatar Jan 24 '25 14:01 zachdaniel