knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.7k stars 303 forks source link

2nd config for different api set for mobile not working #682

Closed jackkitley closed 1 year ago

jackkitley commented 1 year ago

Scribe version

4.21.2

PHP version

8.2.6

Framework

Laravel

Framework version

10.13.2

Scribe config

994d360921a2:/var/www/html$ php artisan scribe:config --config=mobile_scribe
Laravel Framework 10.13.2

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --env[=ENV]       The environment the command should run under
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands for the "scribe:config" namespace:
  scribe:config:diff  Dump your changed config to the console. Use this when posting bug reports

What happened?

php artisan scribe:config --config=mobile_scribe

I created another config to generate another doc to separate my routes for mobile.

It doesnt generate the routes for laravel. 404 not found.

Docs

jackkitley commented 1 year ago

Issue is that the route generated is not dynamic to the config set.

` $prefix = config('scribe_mobile.laravel.docs_url', '/docs'); $middleware = config('scribe_mobile.laravel.middleware', []);

Route::middleware($middleware) ->group(function () use ($prefix) { Route::view($prefix, 'scribe.index')->name('scribe');

    Route::get("$prefix.postman", function () {
        return new JsonResponse(Storage::disk('local')->get('scribe/collection.json'), json: true);
    })->name('scribe_mobile.postman');

    Route::get("$prefix.openapi", function () {
        return response()->file(Storage::disk('local')->path('scribe/openapi.yaml'));
    })->name('scribe_mobile.openapi');
});

`

shalvah commented 1 year ago

It's stated in the docs:

Screenshot_20230609-164939~2

Maybe I should move it to the beginning of the section so it's more obvious?

jackkitley commented 1 year ago

Thanks.

Because I looked in vendor and saw config this was my immediate thought to create another configuration and it would automatically work.

I'll give this a try.

On Fri, 09 Jun 2023, 17:51 Shalvah, @.***> wrote:

It's stated in the docs:

[image: Screenshot_20230609-164939~2] https://user-images.githubusercontent.com/14361073/244743032-f3a63cdb-769a-4565-b761-5b115bfa048c.png

Maybe I should move it to the beginning of the section so it's more obvious?

— Reply to this email directly, view it on GitHub https://github.com/knuckleswtf/scribe/issues/682#issuecomment-1584801074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYXYBUX65UPNYTOMXG4T63XKNBADANCNFSM6AAAAAAZAP62MY . You are receiving this because you authored the thread.Message ID: @.***>

jackkitley commented 1 year ago

@shalvah I tried what was described in docs and i tried this way in routes before the other issues and i get the following:

If i set both to false in config then all works.

Screenshot 2023-06-09 at 20 48 21

jackkitley commented 1 year ago

Had to add two more routes to get openapi and postman.

Route::view('/mobile/docs', 'scribe_mobile.index')->name('scribe-mobile'); Route::get("scribe_mobile.postman", function () { return new JsonResponse(Storage::disk('local')->get('scribe_mobile/collection.json'), json: true); })->name('scribe_mobile.postman'); Route::get("scribe_mobile.openapi", function () { return response()->file(Storage::disk('local')->path('scribe_mobile/openapi.yaml')); })->name('scribe_mobile.openapi');