laravel-request-docs
laravel-request-docs copied to clipboard
Create separate docs based on scopes
What a nice package, I am enjoying it, But one little thing I want to have is: I have different API scopes in my project, some of them are for interacting with the front app, some of them are for mobile and etc.
The package should have a config for separating scopes and for a big project it is better to categorize APIs.
Hi @pouyasalimi Thanks for the issue and thanks for using this package. I am glad it made you a little more productive.
This is an issue, I have been battling with, reference here: https://github.com/rakutentech/laravel-request-docs/issues/44#issuecomment-1040233830
Currently, I receive a list of routes as raw from collect(Route::getRoutes())
Sample below
Illuminate\Routing\Route {#3931
+uri: "mobile/api/v1/health",
+methods: [
"GET",
"HEAD",
],
+action: [
"middleware" => [
"mobileapi",
],
"uses" => "App\Http\Controllers\MobileApi\V1\HealthController@index",
"controller" => "App\Http\Controllers\MobileApi\V1\HealthController@index",
"namespace" => "App\Http\Controllers",
"where" => [],
"as" => "generated::HJasdasdasdDPsmH",
"prefix" => "mobile/api",
],
The issue here is how to go about categorizing. There can be many keys to choose from in order to do it scope based. Such as, by prefix, by middleware, by methods etc. If you have good suggestion for it.
Hi @kevincobain2000
Aha, I see.
Putting a search box above the page is very helpful, but separating API scopes is another thing.
For example, when I have a monolith laravel backend that handles separate scopes of APIs and depending on the team, I don't want to share Admin API's with my mobile app team. So just like the Laravel swagger package, we should have multiple configs for multiple API scopes and we can build our documents according to the config file.
Oh that makes sense to be able to have multi configs. I understand now about what scoping you have in your mind. let me think it during Golden week in Japan.
I have a little free time these days and if you think I can help, let me know.
So just like the Laravel swagger package,
Thanks, we can follow that exact strategy, where for the default we can keep using current route /request-docs so it doesn't bring breaking changes to others. And once the user specifies based on it's needs.
One thing, I would add that I don't think is in swagger would be possibility to have different middle wares for different scopes.
With regards to the index.blade.php changes, first we should challenge this issue, without bringing any changes to there. All changes can be done at the config, getDocs() and ServiceProvider level.
Overall, it shouldn't take more than 2-3 days to put this feature in a pull req. You can start attempting it with structuring the config, registering routes to the service provider and then filtering it on the getDocs() method based on scope.
Yes, that's correct, will send a PR.
Closing for now....Good feature tho. Only open to pull req on this