diff --git a/src/Generator.php b/src/Generator.php index 16d61acd..ab804aaf 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -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(), ]); } diff --git a/tests/Fixtures/SurplusTag.php b/tests/Fixtures/SurplusTag.php new file mode 100644 index 00000000..0ac32cc6 --- /dev/null +++ b/tests/Fixtures/SurplusTag.php @@ -0,0 +1,25 @@ +getContext()); (new Generator($this->getTrackingLogger())) + ->setConfig($config) ->setAnalyser($analyzer ?: $this->getAnalyzer()) ->setProcessorPipeline(new Pipeline($processors)) ->generate($this->fixtures($files), $analysis, false); diff --git a/tests/Processors/AugmentTagsTest.php b/tests/Processors/AugmentTagsTest.php new file mode 100644 index 00000000..059c3f9f --- /dev/null +++ b/tests/Processors/AugmentTagsTest.php @@ -0,0 +1,28 @@ +skipLegacy(); + + $config = [ + 'pathFilter' => ['paths' => ['#^/hello/#']], + 'cleanUnusedComponents' => ['enabled' => true], + ]; + $analysis = $this->analysisFromFixtures(['SurplusTag.php'], static::processors(), null, $config); + + $this->assertCount(1, $analysis->openapi->tags); + } +} diff --git a/tests/Processors/CleanUnusedComponentsTest.php b/tests/Processors/CleanUnusedComponentsTest.php index bcc0fcb6..ab3caa6c 100644 --- a/tests/Processors/CleanUnusedComponentsTest.php +++ b/tests/Processors/CleanUnusedComponentsTest.php @@ -7,29 +7,28 @@ namespace OpenApi\Tests\Processors; use OpenApi\Generator; -use OpenApi\Processors\CleanUnusedComponents; use OpenApi\Tests\OpenApiTestCase; class CleanUnusedComponentsTest extends OpenApiTestCase { public static function countCases(): iterable { - $defaultProcessors = static::processors([CleanUnusedComponents::class]); + $configEnable = ['cleanUnusedComponents' => ['enabled' => true]]; return [ - 'var-default' => [$defaultProcessors, 'UsingVar.php', 2, 5], - 'var-clean' => [array_merge($defaultProcessors, [new CleanUnusedComponents(true)]), 'UsingVar.php', 0, 2], - 'unreferenced-default' => [$defaultProcessors, 'Unreferenced.php', 2, 11], - 'unreferenced-clean' => [array_merge($defaultProcessors, [new CleanUnusedComponents(true)]), 'Unreferenced.php', 0, 5], + 'var-default' => [[], 'UsingVar.php', 2, 5], + 'var-clean' => [$configEnable, 'UsingVar.php', 0, 2], + 'unreferenced-default' => [[], 'Unreferenced.php', 2, 11], + 'unreferenced-clean' => [$configEnable, 'Unreferenced.php', 0, 5], ]; } /** * @dataProvider countCases */ - public function testCounts(array $processors, string $fixture, int $expectedSchemaCount, int $expectedAnnotationCount): void + public function testCounts(array $config, string $fixture, int $expectedSchemaCount, int $expectedAnnotationCount): void { - $analysis = $this->analysisFromFixtures([$fixture], $processors); + $analysis = $this->analysisFromFixtures([$fixture], static::processors(), null, $config); if ($expectedSchemaCount === 0) { $this->assertTrue(Generator::isDefault($analysis->openapi->components->schemas));