@@ -22,6 +22,7 @@ public function __construct(string $specUrl)
22
22
23
23
public function generate (string $ namespace , string $ destinationPath )
24
24
{
25
+ $ namespace = $ this ->cleanUpNamespace ($ namespace );
25
26
$ codePrinter = new Standard ();
26
27
$ schemaClassNameMap = [];
27
28
foreach ($ this ->spec ->components ->schemas as $ name => $ schema ) {
@@ -37,7 +38,7 @@ public function generate(string $namespace, string $destinationPath)
37
38
file_put_contents ($ destinationPath . '/Schema/ ' . $ schemaClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
38
39
Schema::generate (
39
40
$ name ,
40
- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Schema/ ' . $ schemaClassName )),
41
+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Schema/ ' . $ schemaClassName )),
41
42
strrev (explode ('/ ' , strrev ($ schemaClassName ))[0 ]),
42
43
$ schema ,
43
44
$ schemaClassNameMap
@@ -51,7 +52,7 @@ public function generate(string $namespace, string $destinationPath)
51
52
file_put_contents ($ destinationPath . '/Path/ ' . $ pathClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
52
53
Path::generate (
53
54
$ path ,
54
- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Path/ ' . $ pathClassName )),
55
+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Path/ ' . $ pathClassName )),
55
56
$ namespace ,
56
57
strrev (explode ('/ ' , strrev ($ pathClassName ))[0 ]),
57
58
$ pathItem
@@ -66,7 +67,7 @@ public function generate(string $namespace, string $destinationPath)
66
67
Operation::generate (
67
68
$ path ,
68
69
$ method ,
69
- $ namespace . str_replace ( ' / ' , '\\' , dirname ('Operation/ ' . $ operationClassName )),
70
+ $ this -> cleanUpNamespace ( $ namespace . dirname ('Operation/ ' . $ operationClassName )),
70
71
strrev (explode ('/ ' , strrev ($ operationClassName ))[0 ]),
71
72
$ operation
72
73
),
@@ -80,4 +81,12 @@ private function className(string $className): string
80
81
{
81
82
return str_replace (['{ ' , '} ' , '- ' ], ['Cb ' , 'Rcb ' , 'Dash ' ], (new Convert ($ className ))->toPascal ());
82
83
}
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