Closed caixingyue closed 2 months ago
This might be something to be added to the new AugmentTags
processor...
it still doesn't work. I see tags from removed path still listed
my config
'pathFilter' => [
'paths' => ['/^\/admin\/.+/'],
],
'cleanUnusedComponents' => ['enabled' => true],
What can I say. Any chance you could post a single file reproducer?
Test.php
#[\OpenApi\Attributes\OpenApi(
info: new \OpenApi\Attributes\Info(
title: 'test',
description: 'test',
version: '2.0.0'
),
)]
class Test
{
#[\OpenApi\Attributes\Get(path: '/world/', tags: ['tag world'], responses: [new \OpenApi\Attributes\Response(response: '200', description: 'success')])]
#[\OpenApi\Attributes\Get(path: '/hello/', tags: ['tag hello'], responses: [new \OpenApi\Attributes\Response(response: '200', description: 'success')])]
public function hello(): void
{
}
}
testrun.php
require("vendor/autoload.php");
spl_autoload_register(function ($string): void {
if ($string === 'Test') {
require __DIR__ . '/Test.php';
}
});
$openapi = (new \OpenApi\Generator())->setVersion('3.0.0')->setConfig([
'pathFilter' => [
'paths' => ['/^\/hello\//'],
],
'cleanUnusedComponents' => ['enabled' => true],
])->generate(\OpenApi\Util::finder([__DIR__ . '/Test.php']));
$json = json_decode($openapi->toJson(), true);
echo json_encode($json, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR);
Output, with both tags instead of a single one
{
"openapi": "3.0.0",
"info": {
"title": "test",
"description": "test",
"version": "2.0.0"
},
"paths": {
"\/hello\/": {
"get": {
"tags": [
"tag hello"
],
"operationId": "d334274659cc0b24fab8ee0a76559fdf",
"responses": {
"200": {
"description": "success"
}
}
}
}
},
"tags": [
{
"name": "tag world",
"description": "tag world"
},
{
"name": "tag hello",
"description": "tag hello"
}
]
}
When all interfaces in a tag are filtered out, the tag should also be removed because it does not have any effect when displayed here.
As shown by the blue line in the figure, no api appears when I click to expand, so it should not continue to exist.