Skip to content

Commit 5dc2762

Browse files
Merge pull request #31 from ProtocolNebula/feature/23-mocks-generator
Feature/23 mocks generator with some improvements
2 parents e55b0a4 + caf149f commit 5dc2762

File tree

94 files changed

+15358
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+15358
-149
lines changed

changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.5.0] - 2021-01-23 (MOCK GENERATOR BETA)
10+
> This change add some beta features (but are stable).
11+
12+
### Added
13+
- Engine to generate a `mock server` (the task is done after write all files).
14+
- `json-server` for the `mock engine` (beta).
15+
- Method to resolve "pluggable" elements (`resolvePluggablePath`).
16+
17+
### Changes
18+
- Core template paths (default templates) are moved inside `src` to be coherent with the `mock engine` and also add native support for TS (future versions).
19+
- The "pluggable" folders now are coppied to the `build` folder to be published within the package, otherwise the `templates` will be ignored from this version and also the `mock assets`.
20+
- Specify `template` (and `output-folder`) is now **optional**, so you can create `mocks` without generate all files.
21+
- Also you can simply launch this script to check if the `json/yaml` document is "well formed" (compatible with the script, there are some missing OpenAPI 3 features not added yet).
22+
- Now `build` folder is empty before each compilation.
23+
924
## [2.4.0] - 2021-01-18
1025
> This can break your `angular 2` app, now all APIs require a model instance.
1126
> Also returns an instance, this can be a big break change, please test your app after build (in another branch) and fix all manually.

examples/generated/angular2/apis/Auth.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { LoginRequest } from '../models/login-request';
@@ -31,8 +33,13 @@ export class AuthService {
3133
return this.apiService.doGet(
3234
'/auth/profile',
3335
null,
34-
null
35-
);
36+
null,
37+
null,
38+
// { },
39+
)
40+
.pipe(
41+
map(response => recursiveInstance(UserAuthResponse, response))
42+
);
3643
}
3744

3845
/**
@@ -44,8 +51,13 @@ export class AuthService {
4451
return this.apiService.doPost(
4552
'/auth/login',
4653
null,
47-
requestBody
48-
);
54+
recursiveStringfy(requestBody),
55+
null,
56+
// { headers: { 'Content-Type': 'application/json' } },
57+
)
58+
.pipe(
59+
map(response => recursiveInstance(UserAuthResponse, response))
60+
);
4961
}
5062

5163
/**
@@ -57,8 +69,13 @@ export class AuthService {
5769
return this.apiService.doPost(
5870
'/auth/social',
5971
null,
60-
requestBody
61-
);
72+
recursiveStringfy(requestBody),
73+
null,
74+
// { headers: { 'Content-Type': 'application/json' } },
75+
)
76+
.pipe(
77+
map(response => recursiveInstance(UserAuthResponse, response))
78+
);
6279
}
6380

6481
}

examples/generated/angular2/apis/BookingManage.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { BookBookingRequest } from '../models/book-booking-request';
@@ -34,8 +36,13 @@ export class BookingManageService {
3436
return this.apiService.doPost(
3537
'/private/booking/manage/book',
3638
null,
37-
requestBody
38-
);
39+
recursiveStringfy(requestBody),
40+
null,
41+
// { headers: { 'Content-Type': 'application/json' } },
42+
)
43+
.pipe(
44+
map(response => recursiveInstance(BookingRoomsDTO, response))
45+
);
3946
}
4047

4148
/**
@@ -47,8 +54,13 @@ export class BookingManageService {
4754
return this.apiService.doPost(
4855
'/private/booking/manage/cancel',
4956
null,
50-
requestBody
51-
);
57+
recursiveStringfy(requestBody),
58+
null,
59+
// { headers: { 'Content-Type': 'application/json' } },
60+
)
61+
.pipe(
62+
map(response => recursiveInstance(BookingRoomsDTO, response))
63+
);
5264
}
5365

5466
/**
@@ -60,8 +72,13 @@ export class BookingManageService {
6072
return this.apiService.doPost(
6173
'/private/booking/manage/list',
6274
null,
63-
requestBody
64-
);
75+
recursiveStringfy(requestBody),
76+
null,
77+
// { headers: { 'Content-Type': 'application/json' } },
78+
)
79+
.pipe(
80+
map(response => recursiveInstance(BookingRoomsDTO, response))
81+
);
6582
}
6683

6784
/**
@@ -73,8 +90,13 @@ export class BookingManageService {
7390
return this.apiService.doPost(
7491
'/private/booking/manage/status',
7592
null,
76-
requestBody
77-
);
93+
recursiveStringfy(requestBody),
94+
null,
95+
// { headers: { 'Content-Type': 'application/json' } },
96+
)
97+
.pipe(
98+
map(response => recursiveInstance(BookingRoomsDTO, response))
99+
);
78100
}
79101

80102
}

examples/generated/angular2/apis/BookingManageAvailability.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { ListDefaultBookingRequest } from '../models/list-default-booking-request';
@@ -32,7 +34,9 @@ export class BookingManageAvailabilityService {
3234
return this.apiService.doPost(
3335
'/private/booking/manage/availability/listDefault',
3436
null,
35-
requestBody
37+
recursiveStringfy(requestBody),
38+
null,
39+
// { headers: { 'Content-Type': 'application/json' } },
3640
);
3741
}
3842

@@ -45,8 +49,13 @@ export class BookingManageAvailabilityService {
4549
return this.apiService.doPost(
4650
'/private/booking/manage/availability/saveDefault',
4751
null,
48-
requestBody
49-
);
52+
recursiveStringfy(requestBody),
53+
null,
54+
// { headers: { 'Content-Type': 'application/json' } },
55+
)
56+
.pipe(
57+
map(response => recursiveInstance(RoomPriceSectionDTO, response))
58+
);
5059
}
5160

5261
}

examples/generated/angular2/apis/BookingManageDiscounts.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { BookingElementsWithDiscount } from '../models/booking-elements-with-discount';
@@ -33,7 +35,9 @@ export class BookingManageDiscountsService {
3335
return this.apiService.doPost(
3436
'/private/booking/manage/discounts/create',
3537
null,
36-
requestBody
38+
recursiveStringfy(requestBody),
39+
null,
40+
// { headers: { 'Content-Type': 'application/json' } },
3741
);
3842
}
3943

@@ -46,8 +50,13 @@ export class BookingManageDiscountsService {
4650
return this.apiService.doPost(
4751
'/private/booking/manage/discounts/',
4852
null,
49-
requestBody
50-
);
53+
recursiveStringfy(requestBody),
54+
null,
55+
// { headers: { 'Content-Type': 'application/json' } },
56+
)
57+
.pipe(
58+
map(response => recursiveInstance(BookingElementsWithDiscount, response))
59+
);
5160
}
5261

5362
/**
@@ -59,7 +68,9 @@ export class BookingManageDiscountsService {
5968
return this.apiService.doPost(
6069
'/private/booking/manage/discounts/remove',
6170
null,
62-
requestBody
71+
recursiveStringfy(requestBody),
72+
null,
73+
// { headers: { 'Content-Type': 'application/json' } },
6374
);
6475
}
6576

examples/generated/angular2/apis/BookingManageRoomPrices.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { CreateSectionsBookingRequest } from '../models/create-sections-booking-request';
@@ -36,8 +38,13 @@ export class BookingManageRoomPricesService {
3638
return this.apiService.doPost(
3739
'/private/booking/manage/roomPrices/create',
3840
null,
39-
requestBody
40-
);
41+
recursiveStringfy(requestBody),
42+
null,
43+
// { headers: { 'Content-Type': 'application/json' } },
44+
)
45+
.pipe(
46+
map(response => recursiveInstance(RoomPriceSectionDTO, response))
47+
);
4148
}
4249

4350
/**
@@ -49,7 +56,9 @@ export class BookingManageRoomPricesService {
4956
return this.apiService.doPost(
5057
'/private/booking/manage/roomPrices/delete',
5158
null,
52-
requestBody
59+
recursiveStringfy(requestBody),
60+
null,
61+
// { headers: { 'Content-Type': 'application/json' } },
5362
);
5463
}
5564

@@ -62,8 +71,13 @@ export class BookingManageRoomPricesService {
6271
return this.apiService.doPost(
6372
'/private/booking/manage/roomPrices/',
6473
null,
65-
requestBody
66-
);
74+
recursiveStringfy(requestBody),
75+
null,
76+
// { headers: { 'Content-Type': 'application/json' } },
77+
)
78+
.pipe(
79+
map(response => recursiveInstance(RoomPriceSectionDTO, response))
80+
);
6781
}
6882

6983
/**
@@ -75,8 +89,13 @@ export class BookingManageRoomPricesService {
7589
return this.apiService.doPost(
7690
'/private/booking/manage/roomPrices/listSection',
7791
null,
78-
requestBody
79-
);
92+
recursiveStringfy(requestBody),
93+
null,
94+
// { headers: { 'Content-Type': 'application/json' } },
95+
)
96+
.pipe(
97+
map(response => recursiveInstance(RoomsPricesDTO, response))
98+
);
8099
}
81100

82101
/**
@@ -88,7 +107,9 @@ export class BookingManageRoomPricesService {
88107
return this.apiService.doPost(
89108
'/private/booking/manage/roomPrices/update',
90109
null,
91-
requestBody
110+
recursiveStringfy(requestBody),
111+
null,
112+
// { headers: { 'Content-Type': 'application/json' } },
92113
);
93114
}
94115

examples/generated/angular2/apis/Direction.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { CountryDTO } from '../models/country-dto';
@@ -31,8 +33,13 @@ export class DirectionService {
3133
return this.apiService.doGet(
3234
'/private/direction/country_list',
3335
null,
34-
null
35-
);
36+
null,
37+
null,
38+
// { },
39+
)
40+
.pipe(
41+
map(response => recursiveInstance(CountryDTO, response))
42+
);
3643
}
3744

3845
/**
@@ -44,8 +51,13 @@ export class DirectionService {
4451
return this.apiService.doGet(
4552
'/private/direction/province_list',
4653
uriOptions,
47-
null
48-
);
54+
null,
55+
null,
56+
// { },
57+
)
58+
.pipe(
59+
map(response => recursiveInstance(ProvinceDTO, response))
60+
);
4961
}
5062

5163
}

examples/generated/angular2/apis/FillingManage.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
// Angular dependences
55
import { Injectable } from '@angular/core';
66
import { Observable } from 'rxjs/Observable';
7+
import { map } from 'rxjs/operators';
78

89
// Main dependences
910
import { ApiBaseService } from '../../ApiBase/api-base.service';
11+
import { recursiveInstance, recursiveStringfy } from '../../ApiBase/model-base.model';
1012

1113
// Models dependences
1214
import { FillRequest } from '../models/fill-request';
@@ -30,7 +32,9 @@ export class FillingManageService {
3032
return this.apiService.doPost(
3133
'/private/booking/manage/fill',
3234
null,
33-
requestBody
35+
recursiveStringfy(requestBody),
36+
null,
37+
// { headers: { 'Content-Type': 'application/json' } },
3438
);
3539
}
3640

0 commit comments

Comments
 (0)