Skip to content

Commit

Permalink
Make AugmentTags the last processor
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann committed Jul 16, 2024
1 parent 4562bb9 commit 525f99f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ public function getProcessorPipeline(): Pipeline
new Processors\MergeJsonContent(),
new Processors\MergeXmlContent(),
new Processors\OperationId(),
new Processors\AugmentTags(),
new Processors\CleanUnmerged(),
new Processors\PathFilter(),
new Processors\CleanUnusedComponents(),
new Processors\AugmentTags(),
]);
}

Expand Down
25 changes: 25 additions & 0 deletions tests/Fixtures/SurplusTag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Tests\Fixtures;

use OpenApi\Attributes as OAT;

#[OAT\OpenApi(
info: new OAT\Info(
title: 'test',
description: 'test',
version: '2.0.0'
),
)]
class SurplusTag
{
#[OAT\Get(path: '/world/', tags: ['tag world'], responses: [new OAT\Response(response: '200', description: 'success')])]
#[OAT\Get(path: '/hello/', tags: ['tag hello'], responses: [new OAT\Response(response: '200', description: 'success')])]
public function hello(): void
{
}
}
28 changes: 28 additions & 0 deletions tests/Processors/AugmentTagsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Tests\Processors;

use OpenApi\Tests\OpenApiTestCase;

class AugmentTagsTest extends OpenApiTestCase
{
/**
* @requires PHP 8.1
*/
public function testAugmentTags(): void
{
$this->skipLegacy();

$config = [
'pathFilter' => ['paths' => ['#^/hello/#']],
'cleanUnusedComponents' => ['enabled' => true],
];
$analysis = $this->analysisFromFixtures(['SurplusTag.php'], static::processors(), null, $config);

$this->assertCount(1, $analysis->openapi->tags);
}
}

0 comments on commit 525f99f

Please sign in to comment.