dedoc/scramble

Wrong url when using `registerJsonSpecificationRoute`

Closed this issue · 1 comments

As discussed on discord, the issue with urls when using registerJsonSpecificationRoute.

  1. I have disabled the default route: Scramble::ignoreDefaultRoutes();
  2. I have registered one API (I will need multiple one in the future): Scramble::registerApi('newsletter', ['api_path' => 'newsletter/api']);
  3. I have added the routes:
Route::domain("module.example.test.at")
    ->name("module.newsletter.")
    ->prefix("newsletter/")
    ->group(function(){
        Scramble::registerUiRoute('api/docs', "newsletter")
            ->name("api.docs");
        Scramble::registerJsonSpecificationRoute('api/docs.json', "newsletter")
            ->name("api.docs-json");
    });

Opening now the url http://module.example.test.at/newsletter/api/docs works as expected - I can see my API endpoint.

BUT the Url for the API is wrong, as you can see

image

It shows http://module.example.at.test/api/subscribeinstead of http://module.example.at.test/newsletter/api/subscribe

I tried to debug it a bit and found out, that it uses the api_pathfrom the global scrable.phpinstead of the one from my Scramble::registerApi('newsletter', ['api_path' => 'newsletter/api'])

I think the problem is, that you are using config('scramble.api_path', 'api') in RequestEssentialsExtension::getAlternativeServers

You said:

what a nice catch. Yeah. The way to do that is to pass config object to the extension. Somehow. Will try different approaches