Created
April 13, 2021 08:42
-
-
Save TimoBakx/f0a0bca93f409c1f439242048c411ba9 to your computer and use it in GitHub Desktop.
Extending API Platform generated documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// src/Api/ApiDocsOverride.php | |
declare(strict_types=1); | |
namespace App\Api; | |
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactory; | |
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface; | |
use ApiPlatform\Core\OpenApi\OpenApi; | |
final class ApiDocsServerOverride implements OpenApiFactoryInterface | |
{ | |
private OpenApiFactoryInterface $decorated; | |
public function __construct(OpenApiFactoryInterface $decorated) | |
{ | |
$this->decorated = $decorated; | |
} | |
public function __invoke(array $context = []): OpenApi | |
{ | |
$context[OpenApiFactory::BASE_URL] = '/test/'; | |
return $this->decorated->__invoke($context); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/services.yaml | |
services: | |
# ... | |
App\Api\ApiDocsServerOverride: | |
decorates: 'api_platform.openapi.factory' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment