Skip to content

Commit ceb09ec

Browse files
committed
Finalizing. Fixing test app. Fix gitignore. Remove nuget definitions (were not working).
1 parent 8953293 commit ceb09ec

File tree

10 files changed

+187
-91
lines changed

10 files changed

+187
-91
lines changed

src/WebApiTestApplication/Controllers/TestController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ public string Post(string hole, DummyClass value)
118118

119119
[HttpPost]
120120
[Route("derived")]
121-
public string Post(DerivedClassWithShadowedProperty value)
121+
public string Post(string hole, DerivedClassWithShadowedProperty value)
122122
{
123123
var valueJson = JsonConvert.SerializeObject(value);
124-
return $"thanks for the {valueJson}";
124+
return $"thanks for the {valueJson} in the {hole}";
125125
}
126126

127127
[HttpPost]
128128
[Route("derivedAgain")]
129-
public string Post(DerivedClassWithAnotherShadowedProperty value)
129+
public string Post(string hole, DerivedClassWithAnotherShadowedProperty value)
130130
{
131131
var valueJson = JsonConvert.SerializeObject(value);
132-
return $"thanks for the {valueJson}";
132+
return $"thanks for the {valueJson} in the {hole}";
133133
}
134134

135135
[HttpPut]

src/WebApiTestApplication/Scripts/Angular.ts

+30-28
Original file line numberDiff line numberDiff line change
@@ -25,72 +25,74 @@ class TestController {
2525
megaClass.something = 7;
2626

2727
endpointsService.Test.Get({
28-
hole: "cap"
29-
})
28+
hole: "cap"
29+
})
3030
.call()
3131
.then(responsePrinter);
3232

3333
endpointsService.Test.Get1({
34-
hole: "cap",
35-
id: "777"
36-
})
34+
hole: "cap",
35+
id: "777"
36+
})
3737
.call()
3838
.then(responsePrinter);
3939

4040
endpointsService.Test.GetSomething({
41-
hole: "cap",
42-
id: 7,
43-
y: Enums.DummyEnum.Bye
44-
})
41+
hole: "cap",
42+
id: 7,
43+
y: Enums.DummyEnum.Bye
44+
})
4545
.call()
4646
.then(responsePrinter);
4747

4848
endpointsService.Test.GetSomethingElse({
49-
hole: "cap",
50-
id: 3,
51-
y: dummyClass
52-
})
49+
hole: "cap",
50+
id: 3,
51+
y: dummyClass
52+
})
5353
.call()
5454
.then(responsePrinter);
5555

5656
endpointsService.Test.Post({
57-
hole: "cap"
58-
})
57+
hole: "cap"
58+
})
5959
.call(null)
6060
.then(responsePrinter);
6161

6262
endpointsService.Test.Post({
63-
hole: "cap"
64-
})
63+
hole: "cap"
64+
})
6565
.call(dummyClass)
6666
.then(responsePrinter);
6767

6868
endpointsService.Test.Put({
69-
hole: "cap",
70-
id: 5
71-
})
69+
hole: "cap",
70+
id: 5
71+
})
7272
.call("b")
7373
.then(responsePrinter);
7474

7575
endpointsService.Test.Delete({
76-
hole: "cap",
77-
id: 2
78-
})
76+
hole: "cap",
77+
id: 2
78+
})
7979
.call()
8080
.then(responsePrinter);
8181

8282
endpointsService.Thingy.Get({
83-
id: 1,
84-
x: "blah",
85-
c: megaClass
86-
})
83+
id: 1,
84+
x: "blah",
85+
c: megaClass
86+
})
8787
.call()
8888
.then(responsePrinter);
8989

9090
endpointsService.Thingy.Post()
9191
.call({
9292
something: 7,
93-
number: 1
93+
number: 1,
94+
name: null,
95+
list: null
9496
})
9597
.then(responsePrinter);
9698
}

src/WebApiTestApplication/Scripts/Endpoints/Endpoints.ts

+44-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Endpoints {
1414
}
1515

1616
if (_.isArray(value)) {
17-
var encodedItems = _.map(value, (item) => encodeURIComponent(item.toString()));
18-
parameters.push(`${key}=${encodedItems.join(',')}`);
17+
var encodedItems = _.map(value, (item: any) => encodeURIComponent(item.toString()));
18+
_(encodedItems).each(item => parameters.push(`${key}=${item}`));
1919
}
2020
else {
2121
parameters.push(`${key}=${encodeURIComponent(value.toString())}`);
@@ -188,6 +188,48 @@ namespace Endpoints {
188188
}
189189
}
190190

191+
export interface IPost1 {
192+
hole: string;
193+
}
194+
195+
export interface IPost1WithCall extends IPost1, IEndpoint {
196+
call<TView>(value: Interfaces.IDerivedClassWithShadowedProperty): ng.IPromise<TView>;
197+
}
198+
199+
export class Post1 implements IPost1, IEndpoint {
200+
_verb = 'POST';
201+
hole: string;
202+
203+
constructor(args: IPost1) {
204+
this.hole = args != null ? args.hole : null;
205+
}
206+
207+
toString = (): string => {
208+
return `/api/Test/${this.hole}/actions/derived`;
209+
}
210+
}
211+
212+
export interface IPost2 {
213+
hole: string;
214+
}
215+
216+
export interface IPost2WithCall extends IPost2, IEndpoint {
217+
call<TView>(value: Interfaces.IDerivedClassWithAnotherShadowedProperty): ng.IPromise<TView>;
218+
}
219+
220+
export class Post2 implements IPost2, IEndpoint {
221+
_verb = 'POST';
222+
hole: string;
223+
224+
constructor(args: IPost2) {
225+
this.hole = args != null ? args.hole : null;
226+
}
227+
228+
toString = (): string => {
229+
return `/api/Test/${this.hole}/actions/derivedAgain`;
230+
}
231+
}
232+
191233
export interface IPut {
192234
id: number;
193235
hole: string;

src/WebApiTestApplication/Scripts/Endpoints/Service.ts

+18
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ namespace Endpoints {
6363
});
6464
},
6565

66+
Post1: (args: Endpoints.Test.IPost1): Endpoints.Test.IPost1WithCall => {
67+
var endpoint = new Endpoints.Test.Post1(args);
68+
return _.extendOwn(endpoint, {
69+
call<TView>(value: Interfaces.IDerivedClassWithShadowedProperty) {
70+
return AngularEndpointsService.call<TView>(this, value != null ? value : null);
71+
}
72+
});
73+
},
74+
75+
Post2: (args: Endpoints.Test.IPost2): Endpoints.Test.IPost2WithCall => {
76+
var endpoint = new Endpoints.Test.Post2(args);
77+
return _.extendOwn(endpoint, {
78+
call<TView>(value: Interfaces.IDerivedClassWithAnotherShadowedProperty) {
79+
return AngularEndpointsService.call<TView>(this, value != null ? value : null);
80+
}
81+
});
82+
},
83+
6684
Put: (args: Endpoints.Test.IPut): Endpoints.Test.IPutWithCall => {
6785
var endpoint = new Endpoints.Test.Put(args);
6886
return _.extendOwn(endpoint, {
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,139 @@
11
namespace Interfaces {
2+
export interface IDummyClass {
3+
name: string;
4+
date: string;
5+
c: Interfaces.IAnotherClass;
6+
}
7+
8+
export class DummyClass implements IDummyClass, Endpoints.IHaveQueryParams {
9+
name: string;
10+
date: string;
11+
c: Interfaces.AnotherClass;
12+
13+
getQueryParams() {
14+
return this;
15+
}
16+
}
17+
218
export interface IAnotherClass {
3-
number?: number;
4-
name?: string;
5-
list?: string[];
19+
number: string | number;
20+
name: string;
21+
list: string[];
622
}
723

824
export class AnotherClass implements IAnotherClass, Endpoints.IHaveQueryParams {
9-
number: number;
25+
number: string | number;
1026
name: string;
1127
list: string[];
12-
28+
1329
getQueryParams() {
1430
return this;
1531
}
1632
}
1733

18-
export interface IMegaClass extends IAnotherClass {
19-
something?: number;
34+
export interface IDerivedClassWithShadowedProperty extends IAnotherClass {
35+
number: number | string;
2036
}
2137

22-
export class MegaClass extends AnotherClass implements IMegaClass, Endpoints.IHaveQueryParams {
23-
something: number;
24-
38+
export class DerivedClassWithShadowedProperty extends AnotherClass implements IDerivedClassWithShadowedProperty, Endpoints.IHaveQueryParams {
39+
number: number | string;
40+
2541
constructor() {
2642
super();
2743
}
28-
44+
2945
getQueryParams() {
3046
return this;
3147
}
3248
}
3349

34-
export interface IDummyClass {
35-
name?: string;
36-
date?: string;
37-
c?: Interfaces.IAnotherClass;
50+
export interface IDerivedClassWithAnotherShadowedProperty extends IDerivedClassWithShadowedProperty {
51+
number: number;
3852
}
3953

40-
export class DummyClass implements IDummyClass, Endpoints.IHaveQueryParams {
41-
name: string;
42-
date: string;
43-
c: Interfaces.AnotherClass;
54+
export class DerivedClassWithAnotherShadowedProperty extends DerivedClassWithShadowedProperty implements IDerivedClassWithAnotherShadowedProperty, Endpoints.IHaveQueryParams {
55+
number: number;
56+
57+
constructor() {
58+
super();
59+
}
60+
61+
getQueryParams() {
62+
return this;
63+
}
64+
}
4465

66+
export interface IMegaClass extends IAnotherClass {
67+
something: number;
68+
}
69+
70+
export class MegaClass extends AnotherClass implements IMegaClass, Endpoints.IHaveQueryParams {
71+
something: number;
72+
73+
constructor() {
74+
super();
75+
}
76+
4577
getQueryParams() {
4678
return this;
4779
}
4880
}
4981

5082
export interface IChain1Generic1<T> {
51-
value?: T;
83+
value: T;
5284
}
5385

5486
export class Chain1Generic1<T> implements IChain1Generic1<T>, Endpoints.IHaveQueryParams {
5587
value: T;
56-
88+
5789
getQueryParams() {
5890
return this;
5991
}
6092
}
6193

6294
export interface IChain1Generic2<T1, T2> {
63-
value11?: T1;
64-
value12?: T2;
95+
value11: T1;
96+
value12: T2;
6597
}
6698

6799
export class Chain1Generic2<T1, T2> implements IChain1Generic2<T1, T2>, Endpoints.IHaveQueryParams {
68100
value11: T1;
69101
value12: T2;
70-
102+
71103
getQueryParams() {
72104
return this;
73105
}
74106
}
75107

76108
export interface IChain2Generic1<TValue> extends IChain1Generic2<TValue, number> {
77-
value2?: TValue;
109+
value2: TValue;
78110
}
79111

80112
export class Chain2Generic1<TValue> extends Chain1Generic2<TValue, number> implements IChain2Generic1<TValue>, Endpoints.IHaveQueryParams {
81113
value2: TValue;
82-
114+
83115
constructor() {
84116
super();
85117
}
86-
118+
87119
getQueryParams() {
88120
return this;
89121
}
90122
}
91123

92124
export interface IChain3 extends IChain2Generic1<Interfaces.MegaClass> {
93-
value3?: any;
125+
value3: any;
94126
}
95127

96128
export class Chain3 extends Chain2Generic1<Interfaces.MegaClass> implements IChain3, Endpoints.IHaveQueryParams {
97129
value3: any;
98-
130+
99131
constructor() {
100132
super();
101133
}
102-
134+
103135
getQueryParams() {
104136
return this;
105137
}
106138
}
107-
}
139+
}

0 commit comments

Comments
 (0)