Skip to content

Commit

Permalink
Update generator.md example code (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiina authored Oct 7, 2024
1 parent 589821f commit 1d92485
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/reference/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1d92485

Please sign in to comment.