@devlearning/swagger-generator 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ export abstract class ApiAutogeneratedService {
14
14
  protected abstract _handleError(error: any, obs: any): Observable<never>;
15
15
 
16
16
 
17
- public AirlineCompany_Read(idAirlineCompany?: number): Observable<Models.AirlineCompany> {
17
+ public AirlineCompany_Read(idAirlineCompany: number): Observable<Models.AirlineCompany> {
18
18
  return this._http.get<Models.AirlineCompany>(`${this._baseUrl}/api/v1/AirlineCompany/Read?idAirlineCompany=${idAirlineCompany}`, httpOptions)
19
19
  .pipe(
20
20
  map(x => this._handleResponse(x)),
@@ -22,7 +22,7 @@ export abstract class ApiAutogeneratedService {
22
22
  );
23
23
  }
24
24
 
25
- public AirlineCompany_List(filter: string): Observable<Models.AirlineCompanyListQueryResponse> {
25
+ public AirlineCompany_List(filter?: string): Observable<Models.AirlineCompanyListQueryResponse> {
26
26
  return this._http.get<Models.AirlineCompanyListQueryResponse>(`${this._baseUrl}/api/v1/AirlineCompany/List?filter=${filter}`, httpOptions)
27
27
  .pipe(
28
28
  map(x => this._handleResponse(x)),
@@ -89,7 +89,7 @@ export abstract class ApiAutogeneratedService {
89
89
  }
90
90
 
91
91
  public Airport_ListManaged(request: Models.AirportManagedListQuery): Observable<Models.AirportManagedListQueryResponse> {
92
- return this._http.get<Models.AirportManagedListQueryResponse>(`${this._baseUrl}/api/v1/Airport/ListManaged?`, httpOptions)
92
+ return this._http.get<Models.AirportManagedListQueryResponse>(`${this._baseUrl}/api/v1/Airport/ListManaged?request=${request}`, httpOptions)
93
93
  .pipe(
94
94
  map(x => this._handleResponse(x)),
95
95
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -131,7 +131,7 @@ export abstract class ApiAutogeneratedService {
131
131
  }
132
132
 
133
133
  public Hotel_ListSummary(request: Models.HotelListSummaryQuery): Observable<Models.HotelListSummaryQueryResponse> {
134
- return this._http.get<Models.HotelListSummaryQueryResponse>(`${this._baseUrl}/api/v1/Hotel/ListSummary?`, httpOptions)
134
+ return this._http.get<Models.HotelListSummaryQueryResponse>(`${this._baseUrl}/api/v1/Hotel/ListSummary?request=${request}`, httpOptions)
135
135
  .pipe(
136
136
  map(x => this._handleResponse(x)),
137
137
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -146,8 +146,43 @@ export abstract class ApiAutogeneratedService {
146
146
  );
147
147
  }
148
148
 
149
+ public HotelGroup_Read(idHotelGroup?: number): Observable<Models.HotelGroup> {
150
+ return this._http.get<Models.HotelGroup>(`${this._baseUrl}/api/v1/HotelGroup/Read?idHotelGroup=${idHotelGroup}`, httpOptions)
151
+ .pipe(
152
+ map(x => this._handleResponse(x)),
153
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
154
+ );
155
+ }
156
+
149
157
  public HotelGroup_List(request: Models.HotelGroupListQuery): Observable<Models.HotelGroupListQueryResponse> {
150
- return this._http.get<Models.HotelGroupListQueryResponse>(`${this._baseUrl}/api/v1/HotelGroup/List?`, httpOptions)
158
+ return this._http.get<Models.HotelGroupListQueryResponse>(`${this._baseUrl}/api/v1/HotelGroup/List?request=${request}`, httpOptions)
159
+ .pipe(
160
+ map(x => this._handleResponse(x)),
161
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
162
+ );
163
+ }
164
+
165
+ public HotelGroup_Create(request: Models.HotelGroupCreateCommand): Observable<number> {
166
+ request = this._handleRequest(request);
167
+ return this._http.post<number>(`${this._baseUrl}/api/v1/HotelGroup/Create`, request, httpOptions)
168
+ .pipe(
169
+ map(x => this._handleResponse(x)),
170
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
171
+ );
172
+ }
173
+
174
+ public HotelGroup_Update(request: Models.HotelGroupUpdateCommand): Observable<Models.Result> {
175
+ request = this._handleRequest(request);
176
+ return this._http.post<Models.Result>(`${this._baseUrl}/api/v1/HotelGroup/Update`, request, httpOptions)
177
+ .pipe(
178
+ map(x => this._handleResponse(x)),
179
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
180
+ );
181
+ }
182
+
183
+ public HotelGroup_Delete(request: Models.HotelGroupDeleteCommand): Observable<Models.Result> {
184
+ request = this._handleRequest(request);
185
+ return this._http.post<Models.Result>(`${this._baseUrl}/api/v1/HotelGroup/Delete`, request, httpOptions)
151
186
  .pipe(
152
187
  map(x => this._handleResponse(x)),
153
188
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -288,6 +323,15 @@ export abstract class ApiAutogeneratedService {
288
323
  );
289
324
  }
290
325
 
326
+ public PassengerRegistration_Finalize(request: Models.PassengerRegistrationFinalizeCommand): Observable<number> {
327
+ request = this._handleRequest(request);
328
+ return this._http.post<number>(`${this._baseUrl}/api/v1/PassengerRegistration/Finalize`, request, httpOptions)
329
+ .pipe(
330
+ map(x => this._handleResponse(x)),
331
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
332
+ );
333
+ }
334
+
291
335
  public Reprotection_List(request: Models.ReprotectionListQuery): Observable<Models.ReprotectionListQueryResponse> {
292
336
  request = this._handleRequest(request);
293
337
  return this._http.post<Models.ReprotectionListQueryResponse>(`${this._baseUrl}/api/v1/Reprotection/List`, request, httpOptions)
@@ -522,8 +566,8 @@ export abstract class ApiAutogeneratedService {
522
566
  );
523
567
  }
524
568
 
525
- public ServiceRequestSnack_List(idTicket?: number): Observable<Models.ListServiceRequestSnackResponse> {
526
- return this._http.get<Models.ListServiceRequestSnackResponse>(`${this._baseUrl}/api/v1/ServiceRequestSnack/List?idTicket=${idTicket}`, httpOptions)
569
+ public ServiceRequestSnack_List(idTicket?: number): Observable<Models.ServiceRequestSnackListQueryResponse> {
570
+ return this._http.get<Models.ServiceRequestSnackListQueryResponse>(`${this._baseUrl}/api/v1/ServiceRequestSnack/List?idTicket=${idTicket}`, httpOptions)
527
571
  .pipe(
528
572
  map(x => this._handleResponse(x)),
529
573
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -615,8 +659,33 @@ export abstract class ApiAutogeneratedService {
615
659
  );
616
660
  }
617
661
 
618
- public Transport_List(): Observable<Models.Result> {
619
- return this._http.get<Models.Result>(`${this._baseUrl}/api/v1/Transport/List`, httpOptions)
662
+ public TicketFile_ListByIdTicket(idTicket?: number): Observable<Models.TicketFileListByIdTicketQueryResponse> {
663
+ return this._http.get<Models.TicketFileListByIdTicketQueryResponse>(`${this._baseUrl}/api/v1/TicketFile/ListByIdTicket?idTicket=${idTicket}`, httpOptions)
664
+ .pipe(
665
+ map(x => this._handleResponse(x)),
666
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
667
+ );
668
+ }
669
+
670
+ public TicketFile_Create(request: Models.FileUploadRequest): Observable<number> {
671
+ request = this._handleRequest(request);
672
+ return this._http.post<number>(`${this._baseUrl}/api/v1/TicketFile/Create`, request, httpOptions)
673
+ .pipe(
674
+ map(x => this._handleResponse(x)),
675
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
676
+ );
677
+ }
678
+
679
+ public TicketFile_Delete(idTicketFile?: number): Observable<Models.Result> {
680
+ return this._http.delete<Models.Result>(`${this._baseUrl}/api/v1/TicketFile/Delete?idTicketFile=${idTicketFile}`, httpOptions)
681
+ .pipe(
682
+ map(x => this._handleResponse(x)),
683
+ catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
684
+ );
685
+ }
686
+
687
+ public Transport_List(filter?: string): Observable<Models.TransportCompanyListQueryResponse> {
688
+ return this._http.get<Models.TransportCompanyListQueryResponse>(`${this._baseUrl}/api/v1/Transport/List?filter=${filter}`, httpOptions)
620
689
  .pipe(
621
690
  map(x => this._handleResponse(x)),
622
691
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -657,9 +726,8 @@ export abstract class ApiAutogeneratedService {
657
726
  );
658
727
  }
659
728
 
660
- public Transport_Delete(request: Models.TransportCompanyDeleteCommand): Observable<Models.Result> {
661
- request = this._handleRequest(request);
662
- return this._http.post<Models.Result>(`${this._baseUrl}/api/v1/Transport/Delete`, request, httpOptions)
729
+ public Transport_Delete(idTransportCompany?: number): Observable<Models.Result> {
730
+ return this._http.post<Models.Result>(`${this._baseUrl}/api/v1/Transport/Delete?idTransportCompany=${idTransportCompany}`, httpOptions)
663
731
  .pipe(
664
732
  map(x => this._handleResponse(x)),
665
733
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -674,8 +742,8 @@ export abstract class ApiAutogeneratedService {
674
742
  );
675
743
  }
676
744
 
677
- public TransportOrder_ListByServiceRequest(idServiceRequest?: number, serviceRequestType: Models.ServiceRequestTypeEnum): Observable<Models.TransportOrderListByServiceRequestQueryResponse> {
678
- return this._http.get<Models.TransportOrderListByServiceRequestQueryResponse>(`${this._baseUrl}/api/v1/TransportOrder/ListByServiceRequest?idServiceRequest=${idServiceRequest}`, httpOptions)
745
+ public TransportOrder_ListByServiceRequest(idServiceRequest: number, serviceRequestType: Models.ServiceRequestTypeEnum): Observable<Models.TransportOrderListByServiceRequestQueryResponse> {
746
+ return this._http.get<Models.TransportOrderListByServiceRequestQueryResponse>(`${this._baseUrl}/api/v1/TransportOrder/ListByServiceRequest?idServiceRequest=${idServiceRequest}&serviceRequestType=${serviceRequestType}`, httpOptions)
679
747
  .pipe(
680
748
  map(x => this._handleResponse(x)),
681
749
  catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
@@ -20,6 +20,8 @@ export class AirlineCompany {
20
20
  idPassengerRegistrationTypeDefault: PassengerRegistrationTypeEnum | undefined;
21
21
  name: string | undefined;
22
22
  iataCode: string | undefined;
23
+ prefix: string | undefined;
24
+ phoneNumber: string | undefined;
23
25
  notes: string | undefined;
24
26
  }
25
27
 
@@ -129,6 +131,11 @@ export class EnumListQueryResponse {
129
131
  userTypes: UserType[] | undefined;
130
132
  }
131
133
 
134
+ export class FileUploadRequest {
135
+ file: File | undefined;
136
+ id: number | undefined;
137
+ }
138
+
132
139
  export class HotelAvailabilityItem {
133
140
  idHotel: number | undefined;
134
141
  idHotelRoom: number | undefined;
@@ -199,6 +206,15 @@ export class HotelGroup {
199
206
  description: string | undefined;
200
207
  }
201
208
 
209
+ export class HotelGroupCreateCommand {
210
+ name: string | undefined;
211
+ description: string | undefined;
212
+ }
213
+
214
+ export class HotelGroupDeleteCommand {
215
+ idHotelGroup: number | undefined;
216
+ }
217
+
202
218
  export class HotelGroupListQuery {
203
219
  }
204
220
 
@@ -206,6 +222,12 @@ export class HotelGroupListQueryResponse {
206
222
  items: HotelGroup[] | undefined;
207
223
  }
208
224
 
225
+ export class HotelGroupUpdateCommand {
226
+ idHotelGroup: number | undefined;
227
+ name: string | undefined;
228
+ description: string | undefined;
229
+ }
230
+
209
231
  export class HotelListSummaryQuery {
210
232
  }
211
233
 
@@ -357,10 +379,6 @@ export class ListServiceRequestResponse {
357
379
  items: ServiceRequestResponse[] | undefined;
358
380
  }
359
381
 
360
- export class ListServiceRequestSnackResponse {
361
- items: ServiceRequestSnackResponse[] | undefined;
362
- }
363
-
364
382
  export class PassengerGroupListByIdServiceRequestAirportToAirportResponse {
365
383
  items: PassengerGroupResponse[] | undefined;
366
384
  }
@@ -377,6 +395,17 @@ export class PassengerGroupListResponse {
377
395
  items: PassengerGroupResponse[] | undefined;
378
396
  }
379
397
 
398
+ export class PassengerGroupNameFinalizeRequest {
399
+ idPassengerGroupName: number | undefined;
400
+ idPassengerGroup: number | undefined;
401
+ surname: string | undefined;
402
+ name: string | undefined;
403
+ idPassengerGroupRole: PassengerGroupRoleEnum | undefined;
404
+ email: string | undefined;
405
+ prefix: string | undefined;
406
+ phoneNumber: string | undefined;
407
+ }
408
+
380
409
  export class PassengerGroupNameResponse {
381
410
  idPassengerGroupName: number | undefined;
382
411
  idPassengerGroup: number | undefined;
@@ -404,6 +433,7 @@ export class PassengerGroupNameSaveRequest {
404
433
  export class PassengerGroupResponse {
405
434
  idPassengerGroup: number | undefined;
406
435
  idTicket: number | undefined;
436
+ idUser: number | undefined;
407
437
  email: string | undefined;
408
438
  needTransport: boolean | undefined;
409
439
  passengersCount: number | undefined;
@@ -448,6 +478,23 @@ export class PassengerRegistrationActivateCommand {
448
478
  activationCode: string | undefined;
449
479
  }
450
480
 
481
+ export class PassengerRegistrationFinalizeCommand {
482
+ idPassengerGroup: number | undefined;
483
+ idTicket: number | undefined;
484
+ idUser: number | undefined;
485
+ email: string | undefined;
486
+ name: string | undefined;
487
+ surname: string | undefined;
488
+ needTransport: boolean | undefined;
489
+ passengersCount: number | undefined;
490
+ singleRooms: number | undefined;
491
+ doubleRooms: number | undefined;
492
+ tripleRooms: number | undefined;
493
+ quadrupleRooms: number | undefined;
494
+ isRegistered: boolean | undefined;
495
+ passengersGroupNames: PassengerGroupNameFinalizeRequest[] | undefined;
496
+ }
497
+
451
498
  export class PassengerRegistrationGenerateCodeCommand {
452
499
  idPassengerGroup: number | undefined;
453
500
  idTicket: number | undefined;
@@ -683,6 +730,10 @@ export class ServiceRequestSnackCreateCommand {
683
730
  passengersCount: number | undefined;
684
731
  }
685
732
 
733
+ export class ServiceRequestSnackListQueryResponse {
734
+ items: ServiceRequestSnackResponse[] | undefined;
735
+ }
736
+
686
737
  export class ServiceRequestSnackListSnackTypesResponse {
687
738
  items: SnackTypesQueryResponse[] | undefined;
688
739
  }
@@ -694,6 +745,7 @@ export class ServiceRequestSnackResponse {
694
745
  passengersCount: number | undefined;
695
746
  numberOfVouchersEmitted: number | undefined;
696
747
  createdAt: moment.Moment | undefined;
748
+ canceledAt: moment.Moment | undefined;
697
749
  snackTypeName: string | undefined;
698
750
  idServiceRequestState: ServiceRequestStateEnum | undefined;
699
751
  errorMessage: string | undefined;
@@ -822,6 +874,18 @@ export class TicketCreateCommand {
822
874
  notes: string | undefined;
823
875
  }
824
876
 
877
+ export class TicketFile {
878
+ idTicketFile: number | undefined;
879
+ idTicket: number | undefined;
880
+ fileName: string | undefined;
881
+ contentType: string | undefined;
882
+ fileUrl: string | undefined;
883
+ }
884
+
885
+ export class TicketFileListByIdTicketQueryResponse {
886
+ items: TicketFile[] | undefined;
887
+ }
888
+
825
889
  export class TicketListQuery {
826
890
  flightNumber: string | undefined;
827
891
  idAirlineCompany: number | undefined;
@@ -873,8 +937,8 @@ export class TransportCompanyCreateCommand {
873
937
  notes: string | undefined;
874
938
  }
875
939
 
876
- export class TransportCompanyDeleteCommand {
877
- idTransportCompany: number | undefined;
940
+ export class TransportCompanyListQueryResponse {
941
+ items: TransportCompany[] | undefined;
878
942
  }
879
943
 
880
944
  export class TransportCompanyListUsersQueryResponse {
package/dist/generator.js CHANGED
@@ -18,6 +18,9 @@ export class Generator {
18
18
  const method = Object.getOwnPropertyNames(swaggerMethod)[0];
19
19
  const swaggerMethodInfo = swaggerMethod[method];
20
20
  console.debug(`\tAPI - ${apiName} - ${method}`);
21
+ if (apiName == '/api/v{version}/TransportOrder/ListByServiceRequest') {
22
+ console.debug('');
23
+ }
21
24
  let parametersString = this.retrieveParameters(swaggerMethodInfo);
22
25
  let queryParameters = this.retrieveQueryParameters(swaggerMethodInfo);
23
26
  let returnTypeString = this.retrieveReturnType(swaggerMethodInfo);
@@ -125,8 +128,13 @@ ${MODEL_POST}`, { flag: 'w' });
125
128
  let parameters = `?`;
126
129
  filteredParameters.forEach(parameter => {
127
130
  if (parameter.schema.$ref != null) {
128
- this.parametrizeObject(parameter.schema.$ref);
129
- //parameters += `${parameter.name}: ${parameter.schema.$ref.replace('#/components/schemas/', '')}&`;
131
+ if (this.isEnum(parameter.schema.$ref) != null) {
132
+ parameters += `${this.toFirstLetterLowercase(parameter.name)}=\${` + this.toFirstLetterLowercase(parameter.name) + `}&`;
133
+ ;
134
+ }
135
+ else {
136
+ throw new Error("retrieveQueryParameters unmanaged parameter.schema.$ref");
137
+ }
130
138
  }
131
139
  else {
132
140
  parameters += `${this.toFirstLetterLowercase(parameter.name)}=\${` + this.toFirstLetterLowercase(parameter.name) + `}&`;
@@ -139,8 +147,15 @@ ${MODEL_POST}`, { flag: 'w' });
139
147
  retrieveReturnType(swaggerMethodInfo) {
140
148
  if (swaggerMethodInfo.responses[200] == null)
141
149
  return 'void';
142
- if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null)
143
- return `Models.${swaggerMethodInfo.responses[200]?.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`;
150
+ try {
151
+ if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null)
152
+ return `Models.${this.getObjectName(swaggerMethodInfo.responses[200]?.content[contentType].schema.$ref)}`;
153
+ }
154
+ catch (error) {
155
+ const errorMessage = "\t\tAttenzione forse hai dimenticato IActionResult e non hai tipizzato il tipo restituito dal servizio";
156
+ console.error(`%c${errorMessage}`, 'color: red');
157
+ throw new Error(errorMessage);
158
+ }
144
159
  if (swaggerMethodInfo.responses[200]?.content[contentType].schema.type != null)
145
160
  return this.getNativeType(swaggerMethodInfo.responses[200]?.content[contentType].schema);
146
161
  console.error("unmanaged swaggerMethodInfo", swaggerMethodInfo);
@@ -151,7 +166,7 @@ ${MODEL_POST}`, { flag: 'w' });
151
166
  return swaggerComponentProperty.$ref.replace('#/components/schemas/', '');
152
167
  if (swaggerComponentProperty.type != null && swaggerComponentProperty.type == 'array')
153
168
  if (swaggerComponentProperty.items.$ref != null)
154
- return `${swaggerComponentProperty.items.$ref.replace('#/components/schemas/', '')}[]`;
169
+ return `${this.getObjectName(swaggerComponentProperty.items.$ref)}[]`;
155
170
  else
156
171
  return this.getNativeType(swaggerComponentProperty);
157
172
  if (swaggerComponentProperty.type != null)
@@ -162,12 +177,19 @@ ${MODEL_POST}`, { flag: 'w' });
162
177
  throw new Error("unmanaged swaggerMethodInfo");
163
178
  }
164
179
  parametrizeObject(objectName) {
165
- let component = this._swagger.components.schemas[objectName.replace('#/components/schemas/', '')];
180
+ let component = this._swagger.components.schemas[this.getObjectName(objectName)];
166
181
  if (component == null || component.properties == null)
167
182
  return ``;
168
183
  console.debug(component.properties);
169
184
  return ``;
170
185
  }
186
+ isEnum(objectName) {
187
+ let component = this._swagger.components.schemas[this.getObjectName(objectName)];
188
+ return component.enum != null;
189
+ }
190
+ getObjectName(ref) {
191
+ return ref.replace('#/components/schemas/', '');
192
+ }
171
193
  retrieveObjectContent(name, swaggerComponent) {
172
194
  if (swaggerComponent.type == 'object')
173
195
  return this.retrieveObjectProperties(swaggerComponent);
@@ -236,6 +258,8 @@ ${MODEL_POST}`, { flag: 'w' });
236
258
  return 'moment.Moment';
237
259
  if (schema.type == 'string' && schema.format == 'uuid')
238
260
  return 'string';
261
+ if (schema.type == 'string' && schema.format == 'binary')
262
+ return 'File';
239
263
  if (schema.type == 'number')
240
264
  return 'number';
241
265
  if (schema.type == 'array')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlearning/swagger-generator",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/generator.ts CHANGED
@@ -10,39 +10,43 @@ import { MODEL_POST, MODEL_PRE } from './model.constants.js';
10
10
  const contentType = 'application/json';
11
11
 
12
12
  export class Generator {
13
- private _swagger: Swagger;
14
- private _outputDirectory: string;
15
-
16
- constructor(swagger: Swagger, outputDirectory: string) {
17
- this._swagger = swagger;
18
- this._outputDirectory = outputDirectory;
19
- }
20
-
21
- generateApi() {
22
- console.debug(`Start autogeneration Apis`);
23
-
24
- let apiMethods = ``;
25
- for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
26
- const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
27
- const swaggerMethod = this._swagger.paths[apiName];
28
- const method = Object.getOwnPropertyNames(swaggerMethod)[0];
29
- const swaggerMethodInfo = swaggerMethod[method];
30
- console.debug(`\tAPI - ${apiName} - ${method}`);
31
-
32
- let parametersString = this.retrieveParameters(swaggerMethodInfo);
33
- let queryParameters = this.retrieveQueryParameters(swaggerMethodInfo);
34
- let returnTypeString = this.retrieveReturnType(swaggerMethodInfo);
35
- if (returnTypeString == null) returnTypeString = 'void';
36
- let prepareRequestString = ``; //request = this._handleRequest(request);
37
- let haveRequest = swaggerMethodInfo.requestBody != null;
38
-
39
- if (haveRequest) {
40
- prepareRequestString = `request = this._handleRequest(request);
13
+ private _swagger: Swagger;
14
+ private _outputDirectory: string;
15
+
16
+ constructor(swagger: Swagger, outputDirectory: string) {
17
+ this._swagger = swagger;
18
+ this._outputDirectory = outputDirectory;
19
+ }
20
+
21
+ generateApi() {
22
+ console.debug(`Start autogeneration Apis`);
23
+
24
+ let apiMethods = ``;
25
+ for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
26
+ const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
27
+ const swaggerMethod = this._swagger.paths[apiName];
28
+ const method = Object.getOwnPropertyNames(swaggerMethod)[0];
29
+ const swaggerMethodInfo = swaggerMethod[method];
30
+ console.debug(`\tAPI - ${apiName} - ${method}`);
31
+
32
+ if (apiName == '/api/v{version}/TransportOrder/ListByServiceRequest') {
33
+ console.debug('');
34
+ }
35
+
36
+ let parametersString = this.retrieveParameters(swaggerMethodInfo);
37
+ let queryParameters = this.retrieveQueryParameters(swaggerMethodInfo);
38
+ let returnTypeString = this.retrieveReturnType(swaggerMethodInfo);
39
+ if (returnTypeString == null) returnTypeString = 'void';
40
+ let prepareRequestString = ``; //request = this._handleRequest(request);
41
+ let haveRequest = swaggerMethodInfo.requestBody != null;
42
+
43
+ if (haveRequest) {
44
+ prepareRequestString = `request = this._handleRequest(request);
41
45
  `;
42
- }
46
+ }
43
47
 
44
- apiMethods +=
45
- `
48
+ apiMethods +=
49
+ `
46
50
  public ${apiName.replace('/api/v{version}/', '').replaceAll('/', '_')}(${parametersString}): Observable<${returnTypeString}> {
47
51
  ${prepareRequestString}return this._http.${method}<${returnTypeString}>(\`\${this._baseUrl}${apiName.replace('{version}', '1')}${queryParameters}\`${haveRequest ? ', request' : ''}, httpOptions)
48
52
  .pipe(
@@ -51,254 +55,274 @@ export class Generator {
51
55
  );
52
56
  }
53
57
  `;
54
- }
58
+ }
55
59
 
56
- fs.writeFileSync(this._outputDirectory + "/api.autogenerated.ts",
57
- `${API_PRE}
60
+ fs.writeFileSync(this._outputDirectory + "/api.autogenerated.ts",
61
+ `${API_PRE}
58
62
  ${apiMethods}
59
63
  ${API_POST}`,
60
- { flag: 'w' });
61
- }
64
+ { flag: 'w' });
65
+ }
62
66
 
63
- generateModel() {
64
- let usedTypes: string[] = [];
67
+ generateModel() {
68
+ let usedTypes: string[] = [];
65
69
 
66
- for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
67
- const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
68
- const swaggerMethod = this._swagger.paths[apiName];
69
- const method = Object.getOwnPropertyNames(swaggerMethod)[0];
70
- const swaggerMethodInfo = swaggerMethod[method];
70
+ for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.paths).length; index++) {
71
+ const apiName = Object.getOwnPropertyNames(this._swagger.paths)[index];
72
+ const swaggerMethod = this._swagger.paths[apiName];
73
+ const method = Object.getOwnPropertyNames(swaggerMethod)[0];
74
+ const swaggerMethodInfo = swaggerMethod[method];
71
75
 
72
- // if(apiName == "/api/v{version}/Ticket/Create"){
73
- // debugger
74
- // }
75
- let parametersRefType = swaggerMethodInfo.parameters.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''))
76
- usedTypes = usedTypes.concat(parametersRefType);
76
+ // if(apiName == "/api/v{version}/Ticket/Create"){
77
+ // debugger
78
+ // }
79
+ let parametersRefType = swaggerMethodInfo.parameters.filter(x => x.in == 'query' && x.schema?.$ref != null).map(x => x.schema.$ref.replace('#/components/schemas/', ''))
80
+ usedTypes = usedTypes.concat(parametersRefType);
77
81
 
78
- if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null) {
79
- usedTypes.push(swaggerMethodInfo.responses[200].content[contentType].schema.$ref.replace('#/components/schemas/', ''));
80
- }
82
+ if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null) {
83
+ usedTypes.push(swaggerMethodInfo.responses[200].content[contentType].schema.$ref.replace('#/components/schemas/', ''));
84
+ }
81
85
 
82
- if (swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref) {
83
- usedTypes.push(swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref.replace('#/components/schemas/', ''));
84
- }
85
- }
86
+ if (swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref) {
87
+ usedTypes.push(swaggerMethodInfo.requestBody?.content[contentType]?.schema?.$ref.replace('#/components/schemas/', ''));
88
+ }
89
+ }
86
90
 
87
- this.retrieveNestedObjects(usedTypes);
91
+ this.retrieveNestedObjects(usedTypes);
88
92
 
89
- usedTypes = [...new Set(usedTypes.map(item => item))]; // [ 'A', 'B']
93
+ usedTypes = [...new Set(usedTypes.map(item => item))]; // [ 'A', 'B']
90
94
 
91
- // usedTypes = usedTypes.filter((value, index, array) => {
92
- // array.indexOf(value) === index;
93
- // });
94
- // usedTypes.forEach(element => {
95
- // console.debug(element);
96
- // });
95
+ // usedTypes = usedTypes.filter((value, index, array) => {
96
+ // array.indexOf(value) === index;
97
+ // });
98
+ // usedTypes.forEach(element => {
99
+ // console.debug(element);
100
+ // });
97
101
 
98
- console.debug(`Start autogeneration Models`);
99
- let models = ``;
100
- for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
101
- const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
102
+ console.debug(`Start autogeneration Models`);
103
+ let models = ``;
104
+ for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
105
+ const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
102
106
 
103
- if (modelName == 'ActivatedVoucherSnackListResponse') {
104
- console.debug("ActivatedVoucherSnackListResponse");
105
- }
107
+ if (modelName == 'ActivatedVoucherSnackListResponse') {
108
+ console.debug("ActivatedVoucherSnackListResponse");
109
+ }
106
110
 
107
- if (usedTypes.indexOf(modelName) < 0) {
108
- console.debug(`\tModel SKIP - ${modelName}`);
109
- continue
110
- };
111
+ if (usedTypes.indexOf(modelName) < 0) {
112
+ console.debug(`\tModel SKIP - ${modelName}`);
113
+ continue
114
+ };
111
115
 
112
- const swaggerCopmponent = this._swagger.components.schemas[modelName];
116
+ const swaggerCopmponent = this._swagger.components.schemas[modelName];
113
117
 
114
- console.debug(`\tModel - ${modelName}`);
118
+ console.debug(`\tModel - ${modelName}`);
115
119
 
116
- let type = swaggerCopmponent.type == 'integer' ? 'enum' : 'class';
117
- let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
120
+ let type = swaggerCopmponent.type == 'integer' ? 'enum' : 'class';
121
+ let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
118
122
 
119
- models +=
120
- `
123
+ models +=
124
+ `
121
125
  export ${type} ${modelName} {${content}
122
126
  }
123
127
  `;
124
- }
128
+ }
125
129
 
126
- fs.writeFileSync(this._outputDirectory + "/model.autogenerated.ts",
127
- `${MODEL_PRE}
130
+ fs.writeFileSync(this._outputDirectory + "/model.autogenerated.ts",
131
+ `${MODEL_PRE}
128
132
  ${models}
129
133
  ${MODEL_POST}`,
130
- { flag: 'w' });
131
- }
132
-
133
- retrieveParameters(swaggerMethodInfo: SwaggerMethod) {
134
- if (swaggerMethodInfo.requestBody != null) {
135
- return `request: Models.${swaggerMethodInfo.requestBody.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`
136
- }
137
-
138
- let parameters = ``;
139
- swaggerMethodInfo.parameters.filter(x => x.in == 'query').forEach(parameter => {
140
- if (parameter.schema.$ref != null) {
141
- parameters += `${this.toFirstLetterLowercase(parameter.name)}: Models.${parameter.schema.$ref.replace('#/components/schemas/', '')}, `;
142
- } else {
134
+ { flag: 'w' });
135
+ }
136
+
137
+ retrieveParameters(swaggerMethodInfo: SwaggerMethod) {
138
+ if (swaggerMethodInfo.requestBody != null) {
139
+ return `request: Models.${swaggerMethodInfo.requestBody.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`
140
+ }
141
+
142
+ let parameters = ``;
143
+ swaggerMethodInfo.parameters.filter(x => x.in == 'query').forEach(parameter => {
144
+ if (parameter.schema.$ref != null) {
145
+ parameters += `${this.toFirstLetterLowercase(parameter.name)}: Models.${parameter.schema.$ref.replace('#/components/schemas/', '')}, `;
146
+ } else {
143
147
  const nativeType = this.getNativeType(parameter.schema);
144
148
  const nullable = !parameter.required ? '?' : '';
145
- parameters += `${this.toFirstLetterLowercase(parameter.name)}${nullable}: ${nativeType}, `;
146
- }
147
- });
149
+ parameters += `${this.toFirstLetterLowercase(parameter.name)}${nullable}: ${nativeType}, `;
150
+ }
151
+ });
148
152
 
149
- if (parameters.length > 2)
150
- parameters = parameters.substring(0, parameters.length - 2);
153
+ if (parameters.length > 2)
154
+ parameters = parameters.substring(0, parameters.length - 2);
151
155
 
152
- return parameters;
153
- }
154
-
155
- retrieveQueryParameters(swaggerMethodInfo: SwaggerMethod) {
156
- if (swaggerMethodInfo.requestBody != null) return ``;
156
+ return parameters;
157
+ }
157
158
 
158
- let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
159
- if (filteredParameters.length == 0) return ``;
159
+ retrieveQueryParameters(swaggerMethodInfo: SwaggerMethod) {
160
+ if (swaggerMethodInfo.requestBody != null) return ``;
161
+
162
+ let filteredParameters = swaggerMethodInfo.parameters.filter(x => x.in == 'query');
163
+ if (filteredParameters.length == 0) return ``;
164
+
165
+ let parameters = `?`;
166
+ filteredParameters.forEach(parameter => {
167
+ if (parameter.schema.$ref != null) {
168
+ if (this.isEnum(parameter.schema.$ref) != null) {
169
+ parameters += `${this.toFirstLetterLowercase(parameter.name)}=\${` + this.toFirstLetterLowercase(parameter.name) + `}&`;;
170
+ } else {
171
+ throw new Error("retrieveQueryParameters unmanaged parameter.schema.$ref");
172
+ }
173
+ } else {
174
+ parameters += `${this.toFirstLetterLowercase(parameter.name)}=\${` + this.toFirstLetterLowercase(parameter.name) + `}&`;
175
+ }
176
+ });
177
+
178
+ if (parameters.length > 1)
179
+ parameters = parameters.substring(0, parameters.length - 1);
180
+
181
+ return parameters;
182
+ }
160
183
 
161
- let parameters = `?`;
162
- filteredParameters.forEach(parameter => {
163
- if (parameter.schema.$ref != null) {
164
- this.parametrizeObject(parameter.schema.$ref)
165
- //parameters += `${parameter.name}: ${parameter.schema.$ref.replace('#/components/schemas/', '')}&`;
166
- } else {
167
- parameters += `${this.toFirstLetterLowercase(parameter.name)}=\${` + this.toFirstLetterLowercase(parameter.name) + `}&`;
168
- }
169
- });
184
+ retrieveReturnType(swaggerMethodInfo: SwaggerMethod) {
185
+ if (swaggerMethodInfo.responses[200] == null)
186
+ return 'void';
170
187
 
171
- if (parameters.length > 1)
172
- parameters = parameters.substring(0, parameters.length - 1);
188
+ try {
189
+ if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null)
190
+ return `Models.${this.getObjectName(swaggerMethodInfo.responses[200]?.content[contentType].schema.$ref)}`;
191
+ } catch (error) {
192
+ const errorMessage = "\t\tAttenzione forse hai dimenticato IActionResult e non hai tipizzato il tipo restituito dal servizio";
193
+ console.error(`%c${errorMessage}`, 'color: red');
194
+ throw new Error(errorMessage);
195
+ }
173
196
 
174
- return parameters;
175
- }
197
+ if (swaggerMethodInfo.responses[200]?.content[contentType].schema.type != null)
198
+ return this.getNativeType(swaggerMethodInfo.responses[200]?.content[contentType].schema);
176
199
 
177
- retrieveReturnType(swaggerMethodInfo: SwaggerMethod) {
178
- if (swaggerMethodInfo.responses[200] == null)
179
- return 'void';
200
+ console.error("unmanaged swaggerMethodInfo", swaggerMethodInfo);
201
+ throw new Error("unmanaged swaggerMethodInfo");
202
+ }
180
203
 
181
- if (swaggerMethodInfo.responses[200].content[contentType].schema.$ref != null)
182
- return `Models.${swaggerMethodInfo.responses[200]?.content[contentType].schema.$ref.replace('#/components/schemas/', '')}`;
204
+ retrieveType(swaggerComponentProperty: SwaggerComponentProperty) {
205
+ if (swaggerComponentProperty.$ref != null)
206
+ return swaggerComponentProperty.$ref.replace('#/components/schemas/', '');
183
207
 
184
- if (swaggerMethodInfo.responses[200]?.content[contentType].schema.type != null)
185
- return this.getNativeType(swaggerMethodInfo.responses[200]?.content[contentType].schema);
208
+ if (swaggerComponentProperty.type != null && swaggerComponentProperty.type == 'array')
209
+ if (swaggerComponentProperty.items.$ref != null)
210
+ return `${this.getObjectName(swaggerComponentProperty.items.$ref)}[]`;
211
+ else
212
+ return this.getNativeType(swaggerComponentProperty);
186
213
 
187
- console.error("unmanaged swaggerMethodInfo", swaggerMethodInfo);
188
- throw new Error("unmanaged swaggerMethodInfo");
189
- }
214
+ if (swaggerComponentProperty.type != null)
215
+ return this.getNativeType(swaggerComponentProperty);
190
216
 
191
- retrieveType(swaggerComponentProperty: SwaggerComponentProperty) {
192
- if (swaggerComponentProperty.$ref != null)
193
- return swaggerComponentProperty.$ref.replace('#/components/schemas/', '');
217
+ if (swaggerComponentProperty.type == null)
218
+ return '';
194
219
 
195
- if (swaggerComponentProperty.type != null && swaggerComponentProperty.type == 'array')
196
- if (swaggerComponentProperty.items.$ref != null)
197
- return `${swaggerComponentProperty.items.$ref.replace('#/components/schemas/', '')}[]`;
198
- else
199
- return this.getNativeType(swaggerComponentProperty);
220
+ console.error("unmanaged swaggerMethodInfo", swaggerComponentProperty);
221
+ throw new Error("unmanaged swaggerMethodInfo");
222
+ }
200
223
 
201
- if (swaggerComponentProperty.type != null)
202
- return this.getNativeType(swaggerComponentProperty);
224
+ parametrizeObject(objectName: string) {
225
+ let component = this._swagger.components.schemas[this.getObjectName(objectName)];
203
226
 
204
- if (swaggerComponentProperty.type == null)
205
- return '';
227
+ if (component == null || component.properties == null) return ``;
206
228
 
207
- console.error("unmanaged swaggerMethodInfo", swaggerComponentProperty);
208
- throw new Error("unmanaged swaggerMethodInfo");
209
- }
229
+ console.debug(component.properties);
210
230
 
211
- parametrizeObject(objectName: string) {
212
- let component = this._swagger.components.schemas[objectName.replace('#/components/schemas/', '')];
213
- if (component == null || component.properties == null) return ``;
231
+ return ``;
232
+ }
214
233
 
215
- console.debug(component.properties);
234
+ isEnum(objectName: string) {
235
+ let component = this._swagger.components.schemas[this.getObjectName(objectName)];
236
+ return component.enum != null;
237
+ }
216
238
 
217
- return ``;
218
- }
239
+ getObjectName(ref: string) {
240
+ return ref.replace('#/components/schemas/', '');
241
+ }
219
242
 
220
- retrieveObjectContent(name: string, swaggerComponent: SwaggerComponent) {
221
- if (swaggerComponent.type == 'object')
222
- return this.retrieveObjectProperties(swaggerComponent);
223
- else if (swaggerComponent.type == 'integer')
224
- return this.retrieveEnumValues(name, swaggerComponent);
225
- }
243
+ retrieveObjectContent(name: string, swaggerComponent: SwaggerComponent) {
244
+ if (swaggerComponent.type == 'object')
245
+ return this.retrieveObjectProperties(swaggerComponent);
246
+ else if (swaggerComponent.type == 'integer')
247
+ return this.retrieveEnumValues(name, swaggerComponent);
248
+ }
226
249
 
227
- retrieveObjectProperties(swaggerCopmponent: SwaggerComponent) {
228
- if (swaggerCopmponent.properties == null) return ``;
250
+ retrieveObjectProperties(swaggerCopmponent: SwaggerComponent) {
251
+ if (swaggerCopmponent.properties == null) return ``;
229
252
 
230
- // console.debug(`\t\t${Object.getOwnPropertyNames(swaggerCopmponent.properties).length}`);
253
+ // console.debug(`\t\t${Object.getOwnPropertyNames(swaggerCopmponent.properties).length}`);
231
254
 
232
- let properties = ``;
233
- for (let index = 0; index < Object.getOwnPropertyNames(swaggerCopmponent.properties).length; index++) {
234
- const propertyName = Object.getOwnPropertyNames(swaggerCopmponent.properties)[index];
235
- properties +=
236
- `
255
+ let properties = ``;
256
+ for (let index = 0; index < Object.getOwnPropertyNames(swaggerCopmponent.properties).length; index++) {
257
+ const propertyName = Object.getOwnPropertyNames(swaggerCopmponent.properties)[index];
258
+ properties +=
259
+ `
237
260
  ${propertyName}: ${this.retrieveType(swaggerCopmponent.properties[propertyName])} | undefined;`
238
- }
261
+ }
239
262
 
240
- return properties;
241
- }
263
+ return properties;
264
+ }
242
265
 
243
- retrieveEnumValues(name: string, swaggerCopmponent: SwaggerComponent) {
244
- if (swaggerCopmponent.enum == null) return ``;
266
+ retrieveEnumValues(name: string, swaggerCopmponent: SwaggerComponent) {
267
+ if (swaggerCopmponent.enum == null) return ``;
245
268
 
246
- let properties = ``;
247
- for (let index = 0; index < swaggerCopmponent.enum.length; index++) {
248
- const name = swaggerCopmponent.enum[index].split('-')[0].trim();
249
- const value = swaggerCopmponent.enum[index].split('-')[1].trim();
250
- properties +=
251
- `
269
+ let properties = ``;
270
+ for (let index = 0; index < swaggerCopmponent.enum.length; index++) {
271
+ const name = swaggerCopmponent.enum[index].split('-')[0].trim();
272
+ const value = swaggerCopmponent.enum[index].split('-')[1].trim();
273
+ properties +=
274
+ `
252
275
  ${name} = ${value},`;
253
- }
254
-
255
- return properties;
256
- }
257
-
258
- retrieveNestedObjects(usedTypes: string[]) {
259
- for (let i = 0; i < usedTypes.length; i++) {
260
- const swaggerCopmponent = this._swagger.components.schemas[usedTypes[i]];
261
- // const name = usedTypes[i]
262
- // const modelName = <string>Object.getOwnPropertyNames(this._swagger.components.schemas)[name];
263
- this.retrieveNestedObjects2(swaggerCopmponent, usedTypes);
264
- }
265
- }
266
-
267
- retrieveNestedObjects2(swaggerComponent: SwaggerComponent, usedTypes: string[]) {
268
- if (!swaggerComponent.properties) return;
269
-
270
- for (let j = 0; j < Object.getOwnPropertyNames(swaggerComponent.properties).length; j++) {
271
- const propertyName = Object.getOwnPropertyNames(swaggerComponent.properties)[j];
272
- let nestedUsedType = '';
273
- if (swaggerComponent.properties[propertyName].$ref != null) {
274
- nestedUsedType = swaggerComponent.properties[propertyName].$ref.replace('#/components/schemas/', '');
275
- } else if (swaggerComponent.properties[propertyName].type == 'array' && swaggerComponent.properties[propertyName].items.$ref != null) {
276
- nestedUsedType = swaggerComponent.properties[propertyName].items.$ref.replace('#/components/schemas/', '');
277
- }
278
-
279
- if (nestedUsedType != '' && usedTypes.findIndex(x => x == nestedUsedType) == -1) {
280
- usedTypes.push(nestedUsedType);
281
- let nested = this._swagger.components.schemas[nestedUsedType];
282
- this.retrieveNestedObjects2(nested, usedTypes);
283
- }
284
- }
285
- }
286
-
287
- getNativeType(schema: SwaggerSchema): string {
288
- if (schema.type == 'integer') return 'number';
289
- if (schema.type == 'string' && schema.format == null) return 'string';
290
- if (schema.type == 'string' && schema.format == 'date-time') return 'moment.Moment';
291
- if (schema.type == 'string' && schema.format == 'uuid') return 'string';
292
- if (schema.type == 'number') return 'number';
293
- if (schema.type == 'array') return '[]';
294
- if (schema.type == 'boolean') return 'boolean';
295
- if (schema.type == 'object') return 'any';
296
-
297
- console.error("unmanaged schema type", schema);
298
- throw new Error("unmanaged schema");
299
- }
300
-
301
- toFirstLetterLowercase(value: string) {
302
- return value.charAt(0).toLowerCase() + value.slice(1);
303
- }
276
+ }
277
+
278
+ return properties;
279
+ }
280
+
281
+ retrieveNestedObjects(usedTypes: string[]) {
282
+ for (let i = 0; i < usedTypes.length; i++) {
283
+ const swaggerCopmponent = this._swagger.components.schemas[usedTypes[i]];
284
+ // const name = usedTypes[i]
285
+ // const modelName = <string>Object.getOwnPropertyNames(this._swagger.components.schemas)[name];
286
+ this.retrieveNestedObjects2(swaggerCopmponent, usedTypes);
287
+ }
288
+ }
289
+
290
+ retrieveNestedObjects2(swaggerComponent: SwaggerComponent, usedTypes: string[]) {
291
+ if (!swaggerComponent.properties) return;
292
+
293
+ for (let j = 0; j < Object.getOwnPropertyNames(swaggerComponent.properties).length; j++) {
294
+ const propertyName = Object.getOwnPropertyNames(swaggerComponent.properties)[j];
295
+ let nestedUsedType = '';
296
+ if (swaggerComponent.properties[propertyName].$ref != null) {
297
+ nestedUsedType = swaggerComponent.properties[propertyName].$ref.replace('#/components/schemas/', '');
298
+ } else if (swaggerComponent.properties[propertyName].type == 'array' && swaggerComponent.properties[propertyName].items.$ref != null) {
299
+ nestedUsedType = swaggerComponent.properties[propertyName].items.$ref.replace('#/components/schemas/', '');
300
+ }
301
+
302
+ if (nestedUsedType != '' && usedTypes.findIndex(x => x == nestedUsedType) == -1) {
303
+ usedTypes.push(nestedUsedType);
304
+ let nested = this._swagger.components.schemas[nestedUsedType];
305
+ this.retrieveNestedObjects2(nested, usedTypes);
306
+ }
307
+ }
308
+ }
309
+
310
+ getNativeType(schema: SwaggerSchema): string {
311
+ if (schema.type == 'integer') return 'number';
312
+ if (schema.type == 'string' && schema.format == null) return 'string';
313
+ if (schema.type == 'string' && schema.format == 'date-time') return 'moment.Moment';
314
+ if (schema.type == 'string' && schema.format == 'uuid') return 'string';
315
+ if (schema.type == 'string' && schema.format == 'binary') return 'File';
316
+ if (schema.type == 'number') return 'number';
317
+ if (schema.type == 'array') return '[]';
318
+ if (schema.type == 'boolean') return 'boolean';
319
+ if (schema.type == 'object') return 'any';
320
+
321
+ console.error("unmanaged schema type", schema);
322
+ throw new Error("unmanaged schema");
323
+ }
324
+
325
+ toFirstLetterLowercase(value: string) {
326
+ return value.charAt(0).toLowerCase() + value.slice(1);
327
+ }
304
328
  }