-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All bindings exposed even if not in path #480
Comments
I'm not sure exactly what you mean, can you give an example? |
Sure, I have this controller method which has a custom #[
Post(
'/create',
name: 'create',
middleware: ['new:' . Team::class]
)
]
public function create(CreateRequest $request, Team $team) However, ziggy generates the following JSON which includes the {"api.team.create":{"uri":"/create","methods":["POST"],"domain":"localhost","bindings":{"team":"slug"}}} The client doesn't need to know about it at all because it is not part of the path. The reason how I stumbled across this is because I created a TypeScript helper function that uses the generated schema and that lets me know which parameter a specific route requires. In this case it tells me that I need to pass the If you think this is not worth to implement, would you maybe be open for a PR that lets me specify how the actual JavaScript file is generated (i.e. /~https://github.com/tighten/ziggy/blob/main/src/CommandRouteGenerator.php#L38-L52)? Maybe via a custom |
Ziggy version
^1.2
Laravel version
^8.73
Description
Right now, Ziggy exposes all bindings of the controller method even if the variable is not part of the path. This is for example the case when a specific parameter is injected via a custom middleware. Hence, the library exposes more information than it is actually necessary.
My suggestion is to really expose only those parameters that are actually part of the path. Would you accept a PR for this?
Ziggy call and context
-
Ziggy configuration
-
Route definition
The text was updated successfully, but these errors were encountered: