Skip to content

Commit 7b943f5

Browse files
committed
fix(laravel): entrypoint with doc formats
1 parent 5386488 commit 7b943f5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
use ApiPlatform\Laravel\Security\ResourceAccessChecker;
103103
use ApiPlatform\Laravel\State\AccessCheckerProvider;
104104
use ApiPlatform\Laravel\State\SwaggerUiProcessor;
105+
use ApiPlatform\Laravel\State\SwaggerUiProvider;
105106
use ApiPlatform\Laravel\State\ValidateProvider;
106107
use ApiPlatform\Metadata\Exception\NotExposedHttpException;
107108
use ApiPlatform\Metadata\Factory\Property\ClassLevelAttributePropertyNameCollectionFactory;
@@ -395,8 +396,12 @@ public function register(): void
395396
return new ReadProvider($app->make(CallableProvider::class));
396397
});
397398

399+
$this->app->singleton(SwaggerUiProvider::class, function (Application $app) {
400+
return new SwaggerUiProvider($app->make(ReadProvider::class), $app->make(OpenApiFactoryInterface::class));
401+
});
402+
398403
$this->app->singleton(ValidateProvider::class, function (Application $app) {
399-
return new ValidateProvider($app->make(ReadProvider::class), $app);
404+
return new ValidateProvider($app->make(SwaggerUiProvider::class), $app);
400405
});
401406

402407
$this->app->singleton(JsonApiProvider::class, function (Application $app) use ($config) {
@@ -587,7 +592,7 @@ public function register(): void
587592
});
588593

589594
$this->app->singleton(EntrypointAction::class, function (Application $app) use ($config) {
590-
return new EntrypointAction($app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ProviderInterface::class), $app->make(ProcessorInterface::class), $config->get('api-platform.formats'));
595+
return new EntrypointAction($app->make(ResourceNameCollectionFactoryInterface::class), $app->make(ProviderInterface::class), $app->make(ProcessorInterface::class), $config->get('api-platform.docs_formats'));
591596
});
592597

593598
$this->app->singleton(Pagination::class, function () use ($config) {

src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Workbench\App\Providers;
1515

16+
use Illuminate\Config\Repository;
1617
use Illuminate\Console\OutputStyle;
1718
use Illuminate\Console\View\Components\Factory;
1819
use Illuminate\Filesystem\Filesystem;
@@ -30,8 +31,13 @@ class WorkbenchServiceProvider extends ServiceProvider
3031
*/
3132
public function register(): void
3233
{
34+
/** @var Repository */
3335
$config = $this->app['config'];
3436
$config->set('api-platform.resources', [app_path('Models'), app_path('ApiResource')]);
37+
$config->set('api-platform.formats', [
38+
'jsonld' => ['application/ld+json'],
39+
'jsonapi' => ['application/vnd.api+json'],
40+
]);
3541
}
3642

3743
/**

0 commit comments

Comments
 (0)