@@ -22,6 +22,7 @@ public function __construct(string $specUrl)
2222
2323 public function generate (string $ namespace , string $ destinationPath )
2424 {
25+ $ namespace = $ this ->cleanUpNamespace ($ namespace );
2526 $ codePrinter = new Standard ();
2627 $ schemaClassNameMap = [];
2728 foreach ($ this ->spec ->components ->schemas as $ name => $ schema ) {
@@ -37,7 +38,7 @@ public function generate(string $namespace, string $destinationPath)
3738 file_put_contents ($ destinationPath . '/Schema/ ' . $ schemaClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
3839 Schema::generate (
3940 $ name ,
40- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Schema/ ' . $ schemaClassName )),
41+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Schema/ ' . $ schemaClassName )),
4142 strrev (explode ('/ ' , strrev ($ schemaClassName ))[0 ]),
4243 $ schema ,
4344 $ schemaClassNameMap
@@ -51,7 +52,7 @@ public function generate(string $namespace, string $destinationPath)
5152 file_put_contents ($ destinationPath . '/Path/ ' . $ pathClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
5253 Path::generate (
5354 $ path ,
54- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Path/ ' . $ pathClassName )),
55+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Path/ ' . $ pathClassName )),
5556 $ namespace ,
5657 strrev (explode ('/ ' , strrev ($ pathClassName ))[0 ]),
5758 $ pathItem
@@ -66,7 +67,7 @@ public function generate(string $namespace, string $destinationPath)
6667 Operation::generate (
6768 $ path ,
6869 $ method ,
69- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Operation/ ' . $ operationClassName )),
70+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Operation/ ' . $ operationClassName )),
7071 strrev (explode ('/ ' , strrev ($ operationClassName ))[0 ]),
7172 $ operation
7273 ),
@@ -80,4 +81,12 @@ private function className(string $className): string
8081 {
8182 return str_replace (['{ ' , '} ' , '- ' ], ['Cb ' , 'Rcb ' , 'Dash ' ], (new Convert ($ className ))->toPascal ());
8283 }
83- }
84+
85+ private function cleanUpNamespace (string $ namespace ): string
86+ {
87+ $ namespace = str_replace ('/ ' , '\\' , $ namespace );
88+ $ namespace = str_replace ('\\\\' , '\\' , $ namespace );
89+
90+ return $ namespace ;
91+ }
92+ }
0 commit comments