New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to rename tag "Login Check" on swagger ui #1160
Comments
Hello @SimonDevelop,
probably in your case is -
|
This is the bundle controller, so how can you add an attribute if it's not accessible? |
Same question on my mind. |
Hey, You can use OpenApi Decorator for that https://api-platform.com/docs/core/openapi/ Important is to change priority that login_check_post is already added to schema. |
I realize this is several months after the fact, but I recently wanted to make this particular change and found this discussion. Here's a fully working solution. <?php
declare(strict_types=1);
namespace App\ApiPlatform;
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\OpenApi\Model\PathItem;
use ApiPlatform\OpenApi\OpenApi;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\ContainerInterface;
#[AsDecorator(
decorates: 'api_platform.openapi.factory',
priority: -25,
onInvalid: ContainerInterface::IGNORE_ON_INVALID_REFERENCE,
)]
class OpenApiFactoryDecorator implements OpenApiFactoryInterface
{
public function __construct(
private readonly OpenApiFactoryInterface $decorated,
private readonly string $loginCheck,
) {
}
/**
* @param array<string, mixed> $context
*/
public function __invoke(array $context = []): OpenApi
{
$openApi = ($this->decorated)($context);
$authPath = $openApi->getPaths()->getPath($this->loginCheck);
if ($authPath instanceof PathItem && $authPath->getPost() instanceof Operation) {
$post = $authPath->getPost()->withTags(['Auth']);
$openApi->getPaths()->addPath(
$this->loginCheck,
(new PathItem())->withPost($post),
);
}
return $openApi;
}
} |
Hi,
I can't find anything about naming the lexik
Login Check
tag on swagger ui.Change this: image
To get this: image
The text was updated successfully, but these errors were encountered: