Skip to content

Commit 2cd05ca

Browse files
committed
Merge branch 'v8' into master
2 parents 2c91062 + dce6ce2 commit 2cd05ca

File tree

23 files changed

+245
-14
lines changed

23 files changed

+245
-14
lines changed

Angular/Writers/AngularServiceWriter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public virtual void Write(AngularWriteConfiguration configuration)
8181
.WithAttribute("Injectable", Code.AnonymousObject().WithProperty("providedIn", Code.String("root")));
8282
FieldTemplate httpField = classTemplate.AddField("http", Code.Type(httpClient)).Readonly().FormatName(controllerOptions);
8383
FieldTemplate serviceUrlField = classTemplate.AddField("serviceUrlValue", Code.Type("string")).FormatName(controllerOptions).Default(Code.String(string.Empty));
84+
FieldTemplate httpOptionsField = classTemplate.AddField("httpOptions", Code.Type("{}")).Public().FormatName(controllerOptions).Default(Code.Local("{}"));
8485
PropertyTemplate serviceUrlProperty = classTemplate.AddProperty("serviceUrl", Code.Type("string"))
8586
.WithGetter(Code.Return(Code.This().Field(serviceUrlField)))
8687
.WithSetter(Code.This().Field(serviceUrlField).Assign(Code.Local("value").Method("replace", Code.TypeScript(@"/\/+$/"), Code.String(""))).Close());
@@ -144,7 +145,11 @@ public virtual void Write(AngularWriteConfiguration configuration)
144145
methodTemplate.AddParameter(Code.Type("{}"), "httpOptions").Optional();
145146
if (isStringReturnType)
146147
{
147-
methodTemplate.WithCode(Code.TypeScript("httpOptions = { responseType: 'text', ...httpOptions}").Close());
148+
methodTemplate.WithCode(Code.TypeScript("httpOptions = { responseType: 'text', ...this.httpOptions, ...httpOptions}").Close());
149+
}
150+
else
151+
{
152+
methodTemplate.WithCode(Code.TypeScript("httpOptions = { ...this.httpOptions, ...httpOptions}").Close());
148153
}
149154
}
150155
if (isDateReturnType && isDateArrayReturnType)

Tests/UrlVersionedWebApiController/ClientApp/src/app/services/weather-forecast.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Subject } from "rxjs";
1313
export class WeatherForecastService {
1414
private readonly http: HttpClient;
1515
private serviceUrlValue: string = "";
16+
public httpOptions: {} = {};
1617

1718
public get serviceUrl(): string {
1819
return this.serviceUrlValue;
@@ -28,6 +29,7 @@ export class WeatherForecastService {
2829

2930
public get(httpOptions?: {}): Observable<WeatherForecast[]> {
3031
let subject = new Subject<WeatherForecast[]>();
32+
httpOptions = { ...this.httpOptions, ...httpOptions};
3133
let url: string = this.serviceUrl + "/api/v1.0/weatherforecast";
3234
this.http.get<WeatherForecast[]>(url, httpOptions).subscribe((result) => {
3335
if (result) {

Tests/WebApiController/ClientApp/src/app/convert-to-interface/services/convert-to-interface-optional.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Subject } from "rxjs";
1313
export class ConvertToInterfaceOptionalService {
1414
private readonly http: HttpClient;
1515
private serviceUrlValue: string = "";
16+
public httpOptions: {} = {};
1617

1718
public get serviceUrl(): string {
1819
return this.serviceUrlValue;
@@ -28,6 +29,7 @@ export class ConvertToInterfaceOptionalService {
2829

2930
public get(subject: string, httpOptions?: {}): Observable<ConvertMeOptional> {
3031
let rxjsSubject = new Subject<ConvertMeOptional>();
32+
httpOptions = { ...this.httpOptions, ...httpOptions};
3133
let url: string = this.serviceUrl + "/converttointerfaceoptional/get";
3234
url = this.append(url, subject, "subject");
3335
this.http.get<ConvertMeOptional>(url, httpOptions).subscribe((result) => {

Tests/WebApiController/ClientApp/src/app/convert-to-interface/services/convert-to-interface.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Subject } from "rxjs";
1313
export class ConvertToInterfaceService {
1414
private readonly http: HttpClient;
1515
private serviceUrlValue: string = "";
16+
public httpOptions: {} = {};
1617

1718
public get serviceUrl(): string {
1819
return this.serviceUrlValue;
@@ -28,6 +29,7 @@ export class ConvertToInterfaceService {
2829

2930
public get(subject: string, httpOptions?: {}): Observable<ConvertMe> {
3031
let rxjsSubject = new Subject<ConvertMe>();
32+
httpOptions = { ...this.httpOptions, ...httpOptions};
3133
let url: string = this.serviceUrl + "/converttointerface/get";
3234
url = this.append(url, subject, "subject");
3335
this.http.get<ConvertMe>(url, httpOptions).subscribe((result) => {

Tests/WebApiController/ClientApp/src/app/date/services/date.service.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Subject } from "rxjs";
1919
export class DateService {
2020
private readonly http: HttpClient;
2121
private serviceUrlValue: string = "";
22+
public httpOptions: {} = {};
2223

2324
public get serviceUrl(): string {
2425
return this.serviceUrlValue;
@@ -34,6 +35,7 @@ export class DateService {
3435

3536
public get(httpOptions?: {}): Observable<Date> {
3637
let subject = new Subject<Date>();
38+
httpOptions = { ...this.httpOptions, ...httpOptions};
3739
let url: string = this.serviceUrl + "/api/date/get";
3840
this.http.get<Date>(url, httpOptions).subscribe((result) => {
3941
subject.next(this.fixUndefined(this.convertToDate(result)));
@@ -44,6 +46,7 @@ export class DateService {
4446

4547
public getArray(httpOptions?: {}): Observable<Date[]> {
4648
let subject = new Subject<Date[]>();
49+
httpOptions = { ...this.httpOptions, ...httpOptions};
4750
let url: string = this.serviceUrl + "/api/date/getarray";
4851
this.http.get<Date[]>(url, httpOptions).subscribe((result) => {
4952
subject.next(this.fixUndefined(result.map((entry) => this.convertToDate(entry))));
@@ -54,6 +57,7 @@ export class DateService {
5457

5558
public getList(httpOptions?: {}): Observable<Date[]> {
5659
let subject = new Subject<Date[]>();
60+
httpOptions = { ...this.httpOptions, ...httpOptions};
5761
let url: string = this.serviceUrl + "/api/date/getlist";
5862
this.http.get<Date[]>(url, httpOptions).subscribe((result) => {
5963
subject.next(this.fixUndefined(result.map((entry) => this.convertToDate(entry))));
@@ -64,6 +68,7 @@ export class DateService {
6468

6569
public getEnumerable(httpOptions?: {}): Observable<Date[]> {
6670
let subject = new Subject<Date[]>();
71+
httpOptions = { ...this.httpOptions, ...httpOptions};
6772
let url: string = this.serviceUrl + "/api/date/getenumerable";
6873
this.http.get<Date[]>(url, httpOptions).subscribe((result) => {
6974
subject.next(this.fixUndefined(result.map((entry) => this.convertToDate(entry))));
@@ -74,6 +79,7 @@ export class DateService {
7479

7580
public getComplex(httpOptions?: {}): Observable<DateModel> {
7681
let subject = new Subject<DateModel>();
82+
httpOptions = { ...this.httpOptions, ...httpOptions};
7783
let url: string = this.serviceUrl + "/api/date/getcomplex";
7884
this.http.get<DateModel>(url, httpOptions).subscribe((result) => {
7985
if (result) {
@@ -87,6 +93,7 @@ export class DateService {
8793

8894
public getComplexArray(httpOptions?: {}): Observable<DateModel[]> {
8995
let subject = new Subject<DateModel[]>();
96+
httpOptions = { ...this.httpOptions, ...httpOptions};
9097
let url: string = this.serviceUrl + "/api/date/getcomplexarray";
9198
this.http.get<DateModel[]>(url, httpOptions).subscribe((result) => {
9299
if (result) {
@@ -102,6 +109,7 @@ export class DateService {
102109

103110
public getComplexList(httpOptions?: {}): Observable<DateModel[]> {
104111
let subject = new Subject<DateModel[]>();
112+
httpOptions = { ...this.httpOptions, ...httpOptions};
105113
let url: string = this.serviceUrl + "/api/date/getcomplexlist";
106114
this.http.get<DateModel[]>(url, httpOptions).subscribe((result) => {
107115
if (result) {
@@ -117,6 +125,7 @@ export class DateService {
117125

118126
public getComplexEnumerable(httpOptions?: {}): Observable<DateModel[]> {
119127
let subject = new Subject<DateModel[]>();
128+
httpOptions = { ...this.httpOptions, ...httpOptions};
120129
let url: string = this.serviceUrl + "/api/date/getcomplexenumerable";
121130
this.http.get<DateModel[]>(url, httpOptions).subscribe((result) => {
122131
if (result) {
@@ -132,6 +141,7 @@ export class DateService {
132141

133142
public getWrappedArray(httpOptions?: {}): Observable<DateArrayWrapper> {
134143
let subject = new Subject<DateArrayWrapper>();
144+
httpOptions = { ...this.httpOptions, ...httpOptions};
135145
let url: string = this.serviceUrl + "/api/date/getwrappedarray";
136146
this.http.get<DateArrayWrapper>(url, httpOptions).subscribe((result) => {
137147
subject.next(this.fixUndefined(result));
@@ -142,6 +152,7 @@ export class DateService {
142152

143153
public getWrappedModel(httpOptions?: {}): Observable<DateModelWrapper> {
144154
let subject = new Subject<DateModelWrapper>();
155+
httpOptions = { ...this.httpOptions, ...httpOptions};
145156
let url: string = this.serviceUrl + "/api/date/getwrappedmodel";
146157
this.http.get<DateModelWrapper>(url, httpOptions).subscribe((result) => {
147158
if (result) {
@@ -157,6 +168,7 @@ export class DateService {
157168

158169
public getWrappedModelList(httpOptions?: {}): Observable<DateModelWrapper[]> {
159170
let subject = new Subject<DateModelWrapper[]>();
171+
httpOptions = { ...this.httpOptions, ...httpOptions};
160172
let url: string = this.serviceUrl + "/api/date/getwrappedmodellist";
161173
this.http.get<DateModelWrapper[]>(url, httpOptions).subscribe((result) => {
162174
if (result) {
@@ -174,6 +186,7 @@ export class DateService {
174186

175187
public getWrappedModelListWrapper(httpOptions?: {}): Observable<DateModelWrapperListWrapper> {
176188
let subject = new Subject<DateModelWrapperListWrapper>();
189+
httpOptions = { ...this.httpOptions, ...httpOptions};
177190
let url: string = this.serviceUrl + "/api/date/getwrappedmodellistwrapper";
178191
this.http.get<DateModelWrapperListWrapper>(url, httpOptions).subscribe((result) => {
179192
if (result) {
@@ -193,6 +206,7 @@ export class DateService {
193206

194207
public getWrappedModelListWrapperList(httpOptions?: {}): Observable<DateModelWrapperListWrapper[]> {
195208
let subject = new Subject<DateModelWrapperListWrapper[]>();
209+
httpOptions = { ...this.httpOptions, ...httpOptions};
196210
let url: string = this.serviceUrl + "/api/date/getwrappedmodellistwrapperlist";
197211
this.http.get<DateModelWrapperListWrapper[]>(url, httpOptions).subscribe((result) => {
198212
if (result) {
@@ -214,6 +228,7 @@ export class DateService {
214228

215229
public getWrappedModelWithDate(httpOptions?: {}): Observable<DateModelWrapperWithDate> {
216230
let subject = new Subject<DateModelWrapperWithDate>();
231+
httpOptions = { ...this.httpOptions, ...httpOptions};
217232
let url: string = this.serviceUrl + "/api/date/getwrappedmodelwithdate";
218233
this.http.get<DateModelWrapperWithDate>(url, httpOptions).subscribe((result) => {
219234
if (result) {
@@ -230,6 +245,7 @@ export class DateService {
230245

231246
public getWrappedModelArray(httpOptions?: {}): Observable<DateModelArrayWrapper> {
232247
let subject = new Subject<DateModelArrayWrapper>();
248+
httpOptions = { ...this.httpOptions, ...httpOptions};
233249
let url: string = this.serviceUrl + "/api/date/getwrappedmodelarray";
234250
this.http.get<DateModelArrayWrapper>(url, httpOptions).subscribe((result) => {
235251
if (result) {
@@ -247,6 +263,7 @@ export class DateService {
247263

248264
public getGenericWithModel(httpOptions?: {}): Observable<GenericResult<DateModel>> {
249265
let subject = new Subject<GenericResult<DateModel>>();
266+
httpOptions = { ...this.httpOptions, ...httpOptions};
250267
let url: string = this.serviceUrl + "/api/date/getgenericwithmodel";
251268
this.http.get<GenericResult<DateModel>>(url, httpOptions).subscribe((result) => {
252269
if (result) {
@@ -264,6 +281,7 @@ export class DateService {
264281

265282
public post(date: Date, httpOptions?: {}): Observable<void> {
266283
let subject = new Subject<void>();
284+
httpOptions = { ...this.httpOptions, ...httpOptions};
267285
let url: string = this.serviceUrl + "/api/date/post";
268286
url = this.appendDate(url, date, "date");
269287
this.http.post<void>(url, undefined, httpOptions).subscribe(() => {

Tests/WebApiController/ClientApp/src/app/derived/services/derived.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Subject } from "rxjs";
1212
export class DerivedService {
1313
private readonly http: HttpClient;
1414
private serviceUrlValue: string = "";
15+
public httpOptions: {} = {};
1516

1617
public get serviceUrl(): string {
1718
return this.serviceUrlValue;
@@ -27,6 +28,7 @@ export class DerivedService {
2728

2829
public get(httpOptions?: {}): Observable<void> {
2930
let subject = new Subject<void>();
31+
httpOptions = { ...this.httpOptions, ...httpOptions};
3032
let url: string = this.serviceUrl + "/derived/get";
3133
this.http.get<void>(url, httpOptions).subscribe(() => {
3234
subject.next();
@@ -37,6 +39,7 @@ export class DerivedService {
3739

3840
public overwritten(httpOptions?: {}): Observable<void> {
3941
let subject = new Subject<void>();
42+
httpOptions = { ...this.httpOptions, ...httpOptions};
4043
let url: string = this.serviceUrl + "/derived/overwritten";
4144
this.http.get<void>(url, httpOptions).subscribe(() => {
4245
subject.next();
@@ -47,6 +50,7 @@ export class DerivedService {
4750

4851
public getBase(httpOptions?: {}): Observable<void> {
4952
let subject = new Subject<void>();
53+
httpOptions = { ...this.httpOptions, ...httpOptions};
5054
let url: string = this.serviceUrl + "/derived/getbase";
5155
this.http.get<void>(url, httpOptions).subscribe(() => {
5256
subject.next();
@@ -57,6 +61,7 @@ export class DerivedService {
5761

5862
public notOverwritten(httpOptions?: {}): Observable<void> {
5963
let subject = new Subject<void>();
64+
httpOptions = { ...this.httpOptions, ...httpOptions};
6065
let url: string = this.serviceUrl + "/derived/notoverwritten";
6166
this.http.get<void>(url, httpOptions).subscribe(() => {
6267
subject.next();

Tests/WebApiController/ClientApp/src/app/duplicate-name/services/duplicate-name.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Subject } from "rxjs";
1212
export class DuplicateNameService {
1313
private readonly http: HttpClient;
1414
private serviceUrlValue: string = "";
15+
public httpOptions: {} = {};
1516

1617
public get serviceUrl(): string {
1718
return this.serviceUrlValue;
@@ -27,6 +28,7 @@ export class DuplicateNameService {
2728

2829
public testA(id: number, httpOptions?: {}): Observable<void> {
2930
let subject = new Subject<void>();
31+
httpOptions = { ...this.httpOptions, ...httpOptions};
3032
let url: string = this.serviceUrl + "/duplicatename";
3133
url = this.append(url, id, undefined, "/");
3234
this.http.get<void>(url, httpOptions).subscribe(() => {
@@ -38,6 +40,7 @@ export class DuplicateNameService {
3840

3941
public testAById(id: number, variantA: string, httpOptions?: {}): Observable<void> {
4042
let subject = new Subject<void>();
43+
httpOptions = { ...this.httpOptions, ...httpOptions};
4144
let url: string = this.serviceUrl + "/duplicatename";
4245
url = this.append(url, id, undefined, "/");
4346
url = this.append(url, variantA, undefined, "/");
@@ -50,6 +53,7 @@ export class DuplicateNameService {
5053

5154
public testAByIdAndVariantA(id: number, variantA: string, variantB: string, httpOptions?: {}): Observable<void> {
5255
let subject = new Subject<void>();
56+
httpOptions = { ...this.httpOptions, ...httpOptions};
5357
let url: string = this.serviceUrl + "/duplicatename";
5458
url = this.append(url, id, undefined, "/");
5559
url = this.append(url, variantA, undefined, "/");
@@ -63,7 +67,7 @@ export class DuplicateNameService {
6367

6468
public testB(id: number, httpOptions?: {}): Observable<string> {
6569
let subject = new Subject<string>();
66-
httpOptions = { responseType: 'text', ...httpOptions};
70+
httpOptions = { responseType: 'text', ...this.httpOptions, ...httpOptions};
6771
let url: string = this.serviceUrl + "/duplicatename/testb";
6872
url = this.append(url, id, "id");
6973
this.http.get<string>(url, httpOptions).subscribe((result) => {
@@ -75,7 +79,7 @@ export class DuplicateNameService {
7579

7680
public testBById(id: string, httpOptions?: {}): Observable<string> {
7781
let subject = new Subject<string>();
78-
httpOptions = { responseType: 'text', ...httpOptions};
82+
httpOptions = { responseType: 'text', ...this.httpOptions, ...httpOptions};
7983
let url: string = this.serviceUrl + "/duplicatename";
8084
url = this.append(url, id, "id");
8185
this.http.get<string>(url, httpOptions).subscribe((result) => {

Tests/WebApiController/ClientApp/src/app/edge-cases/components/edge-cases.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { EdgeCasesService } from '../services/edge-cases.service';
3+
import { HttpHeaders } from '@angular/common/http';
34

45
@Component({
56
selector: 'app-edge-cases',
@@ -19,7 +20,9 @@ export class EdgeCasesComponent implements OnInit {
1920
) { }
2021

2122
ngOnInit() {
22-
23+
this.service.httpOptions = {
24+
headers: new HttpHeaders({'X-Test': 'Test'})
25+
}
2326
}
2427

2528
public withDi(): void {

0 commit comments

Comments
 (0)