2
2
3
3
namespace ApiClients \Tools \OpenApiClientGenerator ;
4
4
5
+ use ApiClients \Tools \OpenApiClientGenerator \Generator \Client ;
6
+ use ApiClients \Tools \OpenApiClientGenerator \Generator \Clients ;
5
7
use ApiClients \Tools \OpenApiClientGenerator \Generator \Operation ;
6
8
use ApiClients \Tools \OpenApiClientGenerator \Generator \Path ;
7
9
use ApiClients \Tools \OpenApiClientGenerator \Generator \Schema ;
@@ -81,6 +83,7 @@ private function all(string $namespace): iterable
81
83
}
82
84
}
83
85
86
+ $ clients = [];
84
87
if (count ($ this ->spec ->paths ?? []) > 0 ) {
85
88
foreach ($ this ->spec ->paths as $ path => $ pathItem ) {
86
89
$ pathClassName = $ this ->className ($ path );
@@ -97,7 +100,7 @@ private function all(string $namespace): iterable
97
100
);
98
101
99
102
foreach ($ pathItem ->getOperations () as $ method => $ operation ) {
100
- $ operationClassName = $ this ->className ((new Convert ($ operation ->operationId ))->fromTrain ()->toPascal ());
103
+ $ operationClassName = $ this ->className ((new Convert ($ operation ->operationId ))->fromTrain ()->toPascal ()) . ' _ ' ;
101
104
$ operations [$ method ] = $ operationClassName ;
102
105
if (strlen ($ operationClassName ) === 0 ) {
103
106
continue ;
@@ -110,10 +113,35 @@ private function all(string $namespace): iterable
110
113
$ this ->basename ($ namespace . 'Operation/ ' . $ operationClassName ),
111
114
$ operation
112
115
);
116
+
117
+ [$ operationGroup , $ operationOperation ] = explode ('/ ' , $ operationClassName );
118
+ if (!array_key_exists ($ operationGroup , $ clients )) {
119
+ $ clients [$ operationGroup ] = [];
120
+ }
121
+ $ clients [$ operationGroup ][$ operationOperation ] = [
122
+ 'class ' => $ operationClassName ,
123
+ 'operation ' => $ operation ,
124
+ ];
113
125
}
114
126
}
115
127
}
116
128
129
+ yield from (function (array $ clients , string $ namespace ): \Generator {
130
+ foreach ($ clients as $ operationGroup => $ operations ) {
131
+ yield from Client::generate (
132
+ $ operationGroup ,
133
+ $ this ->dirname ($ namespace . 'Operation/ ' . $ operationGroup ),
134
+ $ this ->basename ($ namespace . 'Operation/ ' . $ operationGroup ),
135
+ $ operations ,
136
+ );
137
+
138
+ }
139
+ yield from Clients::generate (
140
+ $ namespace ,
141
+ $ clients ,
142
+ );
143
+ })($ clients , $ namespace );
144
+
117
145
if (count ($ this ->spec ->webhooks ?? []) > 0 ) {
118
146
$ pathClassNameMapping = [];
119
147
foreach ($ this ->spec ->webhooks as $ path => $ pathItem ) {
0 commit comments