15
15
16
16
use ApiPlatform \Core \Documentation \Documentation ;
17
17
use ApiPlatform \Core \Metadata \Resource \Factory \ResourceNameCollectionFactoryInterface ;
18
+ use ApiPlatform \Core \Swagger \Serializer \ApiGatewayNormalizer ;
18
19
use ApiPlatform \Core \Swagger \Serializer \DocumentationNormalizer ;
19
20
use Symfony \Component \Console \Command \Command ;
20
21
use Symfony \Component \Console \Exception \InvalidOptionException ;
@@ -62,7 +63,8 @@ protected function configure()
62
63
->setDescription ('Dump the OpenAPI documentation ' )
63
64
->addOption ('yaml ' , 'y ' , InputOption::VALUE_NONE , 'Dump the documentation in YAML ' )
64
65
->addOption ('spec-version ' , null , InputOption::VALUE_OPTIONAL , 'OpenAPI version to use ("2" or "3") ' , '2 ' )
65
- ->addOption ('output ' , 'o ' , InputOption::VALUE_OPTIONAL , 'Write output to file ' );
66
+ ->addOption ('output ' , 'o ' , InputOption::VALUE_OPTIONAL , 'Write output to file ' )
67
+ ->addOption ('api-gateway ' , null , InputOption::VALUE_NONE , 'API Gateway compatibility ' );
66
68
}
67
69
68
70
/**
@@ -79,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
79
81
}
80
82
81
83
$ documentation = new Documentation ($ this ->resourceNameCollectionFactory ->create (), $ this ->apiTitle , $ this ->apiDescription , $ this ->apiVersion , $ this ->apiFormats );
82
- $ data = $ this ->normalizer ->normalize ($ documentation , DocumentationNormalizer::FORMAT , ['spec_version ' => (int ) $ version ]);
84
+ $ data = $ this ->normalizer ->normalize ($ documentation , DocumentationNormalizer::FORMAT , ['spec_version ' => (int ) $ version, ApiGatewayNormalizer:: API_GATEWAY => $ input -> getOption ( ' api-gateway ' ) ]);
83
85
$ content = $ input ->getOption ('yaml ' ) ? Yaml::dump ($ data , 10 , 2 , Yaml::DUMP_OBJECT_AS_MAP | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK ) : (json_encode ($ data , JSON_PRETTY_PRINT ) ?: '' );
84
86
85
87
if (!empty ($ filename = $ input ->getOption ('output ' )) && \is_string ($ filename )) {
0 commit comments