Debian Codegraph @

vendor/zircote/swagger-php/src/Console/GenerateInput.php

raw
1 <?php declare(strict_types=1);
2
3 /**
4 * @license Apache 2.0
5 */
6
7 namespace OpenApi\Console;
8
9 use Symfony\Component\Console\Attribute\Argument;
10 use Symfony\Component\Console\Attribute\Option;
11 use Symfony\Component\Console\Exception\InvalidArgumentException;
12
13 class GenerateInput
14 {
15 #[Argument('Source path(s) to scan')]
16 public array $paths;
17
18 #[Option('Generator config (e.g. -c operationId.hash=false)', shortcut: 'c')]
19 public array $config = [];
20
21 #[Option('Show default config', shortcut: 'D')]
22 public bool $defaults = false;
23
24 #[Option('Path to store the generated documentation (e.g. -o openapi.yaml)', shortcut: 'o')]
25 public ?string $output = null;
26
27 #[Option('Force yaml or json', shortcut: 'f')]
28 public GenerateFormat $format = GenerateFormat::AUTO;
29
30 #[Option('Exclude path(s) (e.g. -e vendor -e library/Zend)', shortcut: 'e')]
31 public array $exclude = [];
32
33 #[Option('Pattern of files to scan (e.g. -n "/\.(phps|php)$/")', shortcut: 'n')]
34 public string $pattern = '*.php';
35
36 #[Option('Bootstrap php file(s) for defining constants, etc. (e.g. -b config/constants.php)', shortcut: 'b')]
37 public array $bootstrap = [];
38
39 #[Option('Register an additional processor', shortcut: 'a')]
40 public array $addProcessor = [];
41
42 #[Option('Remove an existing processor', shortcut: 'r')]
43 public array $removeProcessor = [];
44
45 #[Option('The OpenAPI version')]
46 public ?string $version = null;
47
48 #[Option('Show additional error information', shortcut: 'd')]
49 public bool $debug = false;
50
51 /**
52 * @return iterable<string>
53 */
54 public function getBootstrapFilenames(): iterable
55 {
56 foreach ($this->bootstrap as $bootstrapPattern) {
57 $filenames = glob($bootstrapPattern);
58
59 if (!$filenames) {
60 throw new InvalidArgumentException('Invalid `--bootstrap` value: "' . $bootstrapPattern . '"');
61 }
62
63 yield from $filenames;
64 }
65 }
66 }