Closed cody-gawr closed 1 year ago
Hmm, it may be hard for Scribe to figure that out, since it doesn't "read" the resolving code. Have you tried the normalizeEndpointUrlUsing()
hook?
https://scribe.knuckles.wtf/laravel/hooks#normalizeendpointurlusing
It should solve your problem.
I didn't know that Scribe was providing a Hook functionality. I think it will fix my problems. Thank you very much.
Scribe version
4.19
Your question
Scribe doesn't overwrite URL parameters which bound to corresponding Models
Hello
I love this library to make my life easy. I have been having some issues recently where I have been trying to generate an api documentation for routes which include URL parameters of binding to Models. It seems it's treating them as ID which is primary key of a corresponding model.![image](https://github.com/knuckleswtf/scribe/assets/67745108/22144a3d-5a70-4eb7-8c51-0033b8c9584b)
Route::post('/{restaurant}/profile', [RestaurantProfileController::class, 'create']);
Since {restaurant} is a parameter which indicates uuid field of restaurant table, I defined resolveRouteBinding function in Restaurant model and attributes in RestaurantProfileController to let scribe know that the controller has a URL parameter of which name is restaurant using URLParam attribute.public function resolveRouteBinding($value, $field = null) { return $this->where('uuid', $value)->firstOrFail(); }
#[UrlParam(name: "restaurant", type: "string", description: "The uuid of the restaurant.", example: "3315946")]
However, a final API documentation is as below.![image](https://github.com/knuckleswtf/scribe/assets/67745108/f1a78b8d-dbf7-4321-8dbc-26a177620ff6)
Any guidance will be greatly appreciated. Thank you!
Docs