From 1d924852125f789def81cafabf7b639e57414389 Mon Sep 17 00:00:00 2001 From: Kiina Date: Mon, 7 Oct 2024 23:52:42 +0200 Subject: [PATCH] Update generator.md example code (#1662) --- docs/reference/generator.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/reference/generator.md b/docs/reference/generator.md index 48c997df..83867070 100644 --- a/docs/reference/generator.md +++ b/docs/reference/generator.md @@ -56,13 +56,15 @@ $logger = new \Psr\Log\NullLogger(); $processors = [/* my processors */]; $finder = \Symfony\Component\Finder\Finder::create()->files()->name('*.php')->in(__DIR__); +$context = new OpenApi\Context(); + $openapi = (new \OpenApi\Generator($logger)) ->setProcessorPipeline(new \OpenApi\Pipeline($processors)) ->setAliases(['MY' => 'My\Annotations']) ->setNamespaces(['My\\Annotations\\']) - ->setAnalyser(new \OpenApi\Analysers\TokenAnalyser()) + ->setAnalyser(new \OpenApi\Analysers\ReflectionAnalyser([new OpenApi\Analysers\DocBlockAnnotationFactory(), new OpenApi\Analysers\AttributeAnnotationFactory()])) ->setVersion(\OpenApi\Annotations\OpenApi::VERSION_3_0_0) - ->generate(['/path1/to/project', $finder], new \OpenApi\Analysis(), $validate); + ->generate(['/path1/to/project', $finder], new \OpenApi\Analysis([], $context)), $validate); ``` `Aliases` and `namespaces` are additional options that allow to customize the parsing of docblocks.