88use DoclerLabs \ApiClientGenerator \Generator \Implementation \HttpMessageImplementationStrategy ;
99use DoclerLabs \ApiClientGenerator \Input \Configuration ;
1010use DoclerLabs \ApiClientGenerator \Input \Specification ;
11+ use DoclerLabs \ApiClientGenerator \Output \Copy \Serializer \ContentType \JsonContentTypeSerializer ;
12+ use DoclerLabs \ApiClientGenerator \Output \Copy \Serializer \ContentType \XmlContentTypeSerializer ;
1113use DoclerLabs \ApiClientGenerator \Output \Meta \MetaFile ;
1214use DoclerLabs \ApiClientGenerator \Output \Meta \MetaFileCollection ;
1315use Twig \Environment ;
@@ -40,6 +42,7 @@ public function render(Specification $specification, MetaFileCollection $fileReg
4042 {
4143 $ packages = array_merge (
4244 $ this ->getCommonPackages (),
45+ $ this ->getPackagesForSpecification ($ specification ),
4346 $ this ->messageImplementation ->getPackages (),
4447 $ this ->containerImplementation ->getPackages ()
4548 );
@@ -63,9 +66,27 @@ private function getCommonPackages(): array
6366 {
6467 return [
6568 'docler-labs/api-client-exception ' => '^1.0 ' ,
66- 'ext-intl ' => '* ' ,
6769 'psr/container ' => '^1.0 ' ,
6870 'psr/http-client ' => '^1.0 ' ,
6971 ];
7072 }
73+
74+ private function getPackagesForSpecification (Specification $ specification ): array
75+ {
76+ $ packages = [];
77+
78+ if ($ specification ->requiresIntlExtension ()) {
79+ $ packages ['ext-intl ' ] = '* ' ;
80+ }
81+
82+ if (in_array (JsonContentTypeSerializer::MIME_TYPE , $ specification ->getAllContentTypes (), true )) {
83+ $ packages ['ext-json ' ] = '* ' ;
84+ }
85+
86+ if (in_array (XmlContentTypeSerializer::MIME_TYPE , $ specification ->getAllContentTypes (), true )) {
87+ $ packages ['ext-dom ' ] = '* ' ;
88+ }
89+
90+ return $ packages ;
91+ }
7192}
0 commit comments