@@ -119,18 +119,18 @@ public function getFiles()
119119 'template ' => 'swift/Package.swift.twig ' ,
120120 'minify ' => false ,
121121 ],
122- [
123- 'scope ' => 'service ' ,
124- 'destination ' => 'docs/{{service.name | caseLower}}.md ' ,
125- 'template ' => 'swift/docs/service.md.twig ' ,
126- 'minify ' => false ,
127- ],
128122 [
129123 'scope ' => 'method ' ,
130124 'destination ' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md ' ,
131125 'template ' => 'swift/docs/example.md.twig ' ,
132126 'minify ' => false ,
133127 ],
128+ [
129+ 'scope ' => 'default ' ,
130+ 'destination ' => '/Tests/{{ spec.title | caseUcfirst}}Tests/Tests.swift ' ,
131+ 'template ' => 'swift/Tests/Tests.swift.twig ' ,
132+ 'minify ' => false ,
133+ ],
134134 [
135135 'scope ' => 'default ' ,
136136 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Client.swift ' ,
@@ -139,16 +139,130 @@ public function getFiles()
139139 ],
140140 [
141141 'scope ' => 'default ' ,
142- 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Service.swift ' ,
142+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Models/{{ spec.title | caseUcfirst}}Error.swift ' ,
143+ 'template ' => '/swift/Sources/Models/Error.swift.twig ' ,
144+ 'minify ' => false ,
145+ ],
146+ [
147+ 'scope ' => 'default ' ,
148+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Models/File.swift ' ,
149+ 'template ' => 'swift/Sources/Models/File.swift.twig ' ,
150+ 'minify ' => false ,
151+ ],
152+ [
153+ 'scope ' => 'default ' ,
154+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/Codable+JSON.swift ' ,
155+ 'template ' => 'swift/Sources/Extensions/Codable+JSON.swift.twig ' ,
156+ 'minify ' => false ,
157+ ],
158+ [
159+ 'scope ' => 'default ' ,
160+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/Cookie+Codable.swift ' ,
161+ 'template ' => 'swift/Sources/Extensions/Cookie+Codable.swift.twig ' ,
162+ 'minify ' => false ,
163+ ],
164+ [
165+ 'scope ' => 'default ' ,
166+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/HTTPClientRequest+Cookies.swift ' ,
167+ 'template ' => 'swift/Sources/Extensions/HTTPClientRequest+Cookies.swift.twig ' ,
168+ 'minify ' => false ,
169+ ],
170+ [
171+ 'scope ' => 'default ' ,
172+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/StreamingDelegate.swift ' ,
173+ 'template ' => 'swift/Sources/StreamingDelegate.swift.twig ' ,
174+ 'minify ' => false ,
175+ ],
176+ [
177+ 'scope ' => 'default ' ,
178+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Services/Service.swift ' ,
143179 'template ' => 'swift/Sources/Service.swift.twig ' ,
144180 'minify ' => false ,
145181 ],
182+ [
183+ 'scope ' => 'default ' ,
184+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/iOSDeviceInfo.swift ' ,
185+ 'template ' => 'swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift ' ,
186+ 'minify ' => false ,
187+ ],
188+ [
189+ 'scope ' => 'default ' ,
190+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/UIDevice+ModelName.swift ' ,
191+ 'template ' => 'swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift ' ,
192+ 'minify ' => false ,
193+ ],
194+ [
195+ 'scope ' => 'default ' ,
196+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/Linux/LinuxDeviceInfo.swift ' ,
197+ 'template ' => 'swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift ' ,
198+ 'minify ' => false ,
199+ ],
200+ [
201+ 'scope ' => 'default ' ,
202+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/MacOSDeviceInfo.swift ' ,
203+ 'template ' => 'swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift ' ,
204+ 'minify ' => false ,
205+ ],
206+ [
207+ 'scope ' => 'default ' ,
208+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/CwlSysCtl.swift ' ,
209+ 'template ' => 'swift/Sources/DeviceInfo/MacOS/CwlSysCtl.swift ' ,
210+ 'minify ' => false ,
211+ ],
212+ [
213+ 'scope ' => 'default ' ,
214+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/Windows/WindowsDeviceInfo.swift ' ,
215+ 'template ' => 'swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift ' ,
216+ 'minify ' => false ,
217+ ],
218+ [
219+ 'scope ' => 'default ' ,
220+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/OSDeviceInfo.swift ' ,
221+ 'template ' => 'swift/Sources/DeviceInfo/OSDeviceInfo.swift ' ,
222+ 'minify ' => false ,
223+ ],
224+ [
225+ 'scope ' => 'default ' ,
226+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Apple/PackageInfo+Apple.swift ' ,
227+ 'template ' => 'swift/Sources/PackageInfo/Apple/PackageInfo+Apple.swift ' ,
228+ 'minify ' => false ,
229+ ],
230+ [
231+ 'scope ' => 'default ' ,
232+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Linux/PackageInfo+Linux.swift ' ,
233+ 'template ' => 'swift/Sources/PackageInfo/Linux/PackageInfo+Linux.swift ' ,
234+ 'minify ' => false ,
235+ ],
236+ [
237+ 'scope ' => 'default ' ,
238+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Windows/PackageInfo+Windows.swift ' ,
239+ 'template ' => 'swift/Sources/PackageInfo/Windows/PackageInfo+Windows.swift ' ,
240+ 'minify ' => false ,
241+ ],
242+ [
243+ 'scope ' => 'default ' ,
244+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/OSPackageInfo.swift ' ,
245+ 'template ' => 'swift/Sources/PackageInfo/OSPackageInfo.swift ' ,
246+ 'minify ' => false ,
247+ ],
248+ [
249+ 'scope ' => 'default ' ,
250+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/PackageInfo.swift ' ,
251+ 'template ' => 'swift/Sources/PackageInfo/PackageInfo.swift ' ,
252+ 'minify ' => false ,
253+ ],
146254 [
147255 'scope ' => 'service ' ,
148256 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}/Services/{{service.name | caseUcfirst}}.swift ' ,
149257 'template ' => 'swift/Sources/Services/Service.swift.twig ' ,
150258 'minify ' => false ,
151259 ],
260+ [
261+ 'scope ' => 'definition ' ,
262+ 'destination ' => '/Sources/{{ spec.title | caseUcfirst}}Models/{{ definition.name | caseUcfirst }}.swift ' ,
263+ 'template ' => '/swift/Sources/Models/Model.swift.twig ' ,
264+ 'minify ' => false ,
265+ ],
152266 ];
153267 }
154268
@@ -161,19 +275,18 @@ public function getTypeName($type)
161275 switch ($ type ) {
162276 case self ::TYPE_INTEGER :
163277 return 'Int ' ;
164- break ;
278+ case self ::TYPE_NUMBER :
279+ return 'Double ' ;
165280 case self ::TYPE_STRING :
166281 return 'String ' ;
167- break ;
168282 case self ::TYPE_FILE :
169- return 'Array<Any> ' ;
170- break ;
283+ return 'File ' ;
171284 case self ::TYPE_BOOLEAN :
172285 return 'Bool ' ;
173- break ;
174286 case self ::TYPE_ARRAY :
175- return "Array<Any> " ;
176- break ;
287+ return '[Any] ' ;
288+ case self ::TYPE_OBJECT :
289+ return 'Any ' ;
177290 }
178291
179292 return $ type ;
@@ -197,36 +310,44 @@ public function getParamDefault(array $param)
197310
198311 if (empty ($ default ) && $ default !== 0 && $ default !== false ) {
199312 switch ($ type ) {
200- case self ::TYPE_NUMBER :
201313 case self ::TYPE_INTEGER :
314+ case self ::TYPE_NUMBER :
202315 $ output = "0 " ;
203316 break ;
204317 case self ::TYPE_STRING :
205- $ output .= "\"\"" ;
318+ $ output .= ' "" ' ;
206319 break ;
207320 case self ::TYPE_BOOLEAN :
208321 $ output .= 'false ' ;
209322 break ;
210323 case self ::TYPE_ARRAY :
211324 $ output .= '[] ' ;
212325 break ;
326+ case self ::TYPE_OBJECT :
327+ $ output .= 'nil ' ;
328+ break ;
329+ default :
330+ echo $ type ;
213331 }
214332 }
215333 else {
216334 switch ($ type ) {
217- case self ::TYPE_NUMBER :
218335 case self ::TYPE_INTEGER :
219336 $ output .= $ default ;
220337 break ;
221- case self ::TYPE_ARRAY :
222- $ output .= $ default ;
338+ case self ::TYPE_NUMBER :
339+ $ output .= sprintf ( " %.1f " , $ default) ;
223340 break ;
224341 case self ::TYPE_BOOLEAN :
225342 $ output .= ($ default ) ? 'true ' : 'false ' ;
226343 break ;
227344 case self ::TYPE_STRING :
228345 $ output .= "\"{$ default }\"" ;
229346 break ;
347+ case self ::TYPE_ARRAY :
348+ case self ::TYPE_OBJECT :
349+ $ output .= 'nil ' ;
350+ break ;
230351 }
231352 }
232353
@@ -248,7 +369,7 @@ public function getParamExample(array $param)
248369 if (empty ($ example ) && $ example !== 0 && $ example !== false ) {
249370 switch ($ type ) {
250371 case self ::TYPE_FILE :
251- $ output .= " nil " ;
372+ $ output .= ' File(name: "image.jpg", buffer: yourByteBuffer) ' ;
252373 break ;
253374 case self ::TYPE_NUMBER :
254375 case self ::TYPE_INTEGER :
0 commit comments