laravel-request-docs icon indicating copy to clipboard operation
laravel-request-docs copied to clipboard

Create separate docs based on scopes

Open pouyasalimi opened this issue 3 years ago • 6 comments

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.

pouyasalimi avatar Apr 11 '22 13:04 pouyasalimi

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.

kevincobain2000 avatar Apr 12 '22 01:04 kevincobain2000

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.

pouyasalimi avatar Apr 12 '22 14:04 pouyasalimi

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.

kevincobain2000 avatar Apr 12 '22 17:04 kevincobain2000

I have a little free time these days and if you think I can help, let me know.

pouyasalimi avatar Apr 13 '22 09:04 pouyasalimi

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.

kevincobain2000 avatar Apr 13 '22 10:04 kevincobain2000

Yes, that's correct, will send a PR.

pouyasalimi avatar Apr 13 '22 10:04 pouyasalimi

Closing for now....Good feature tho. Only open to pull req on this

kevincobain2000 avatar Feb 18 '23 14:02 kevincobain2000