Skip to content

Commit 792e9e4

Browse files
committed
Add support for action return types resolution.
Fixes #14
1 parent 63bba47 commit 792e9e4

File tree

10 files changed

+212
-155
lines changed

10 files changed

+212
-155
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ angular.module('framework').service('AngularEndpointsService', Framework.Endpoin
6363
{
6464
"WebApiModuleFileName": "string",
6565
66+
"GenerateEndpointsReturnTypes": "boolean",
6667
"GenerateEndpoints": "boolean",
6768
"EndpointsOutputDirectory": "string",
6869
"EndpointsSupportCaching": "boolean",

src/WebApiTestApplication/Controllers/TestController.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using System.Collections.Generic;
33
using System.ComponentModel;
44
using System.Linq;
5+
using System.Net.Http;
56
using System.Threading;
67
using System.Threading.Tasks;
78
using System.Web;
89
using System.Web.Http;
910
using System.Web.Http.Controllers;
1011
using System.Web.Http.Metadata;
12+
using System.Web.Http.Results;
1113
using Newtonsoft.Json;
1214

1315
namespace WebApiTestApplication.Controllers
@@ -111,6 +113,20 @@ public string GetSomethingElse(int id, [FromUri]DummyClass y, string hole)
111113
return $"{nameof(GetSomethingElse)}: {id} {y.Name} {y.Date.ToShortDateString()} {hole}";
112114
}
113115

116+
[HttpGet]
117+
[Route("GetEnumerableString")]
118+
public IEnumerable<string> GetEnumerableString()
119+
{
120+
return new List<string>();
121+
}
122+
123+
[HttpGet]
124+
[Route("GetIHttpActionResult")]
125+
public IHttpActionResult GetIHttpActionResult()
126+
{
127+
return new OkResult(new HttpRequestMessage());
128+
}
129+
114130
[HttpPost]
115131
[Route("")]
116132
public string Post(string hole, DummyClass value)

src/WebApiTestApplication/Scripts/Endpoints/Endpoints.ts

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ namespace Endpoints {
3939
Get1: (args?: IGet1) => IGet1WithCall
4040
GetSomething: (args?: IGetSomething) => IGetSomethingWithCall
4141
GetSomethingElse: (args?: IGetSomethingElse) => IGetSomethingElseWithCall
42+
GetEnumerableString: (args?: IGetEnumerableString) => IGetEnumerableStringWithCall
43+
GetIHttpActionResult: (args?: IGetIHttpActionResult) => IGetIHttpActionResultWithCall
4244
Post: (args?: IPost) => IPostWithCall
4345
Post1: (args?: IPost1) => IPost1WithCall
4446
Post2: (args?: IPost2) => IPost2WithCall
@@ -51,8 +53,8 @@ namespace Endpoints {
5153
}
5254

5355
export interface IGetWithCall extends IGet, IEndpoint {
54-
call<TView>(): ng.IPromise<TView>;
55-
callCached<TView>(): ng.IPromise<TView>;
56+
call(): ng.IPromise<string[]>;
57+
callCached(): ng.IPromise<string[]>;
5658
}
5759

5860
export class Get implements IGet, IEndpoint {
@@ -74,8 +76,8 @@ namespace Endpoints {
7476
}
7577

7678
export interface IGet1WithCall extends IGet1, IEndpoint {
77-
call<TView>(): ng.IPromise<TView>;
78-
callCached<TView>(): ng.IPromise<TView>;
79+
call(): ng.IPromise<string>;
80+
callCached(): ng.IPromise<string>;
7981
}
8082

8183
export class Get1 implements IGet1, IEndpoint {
@@ -111,8 +113,8 @@ namespace Endpoints {
111113
}
112114

113115
export interface IGetSomethingWithCall extends IGetSomething, IEndpoint {
114-
call<TView>(): ng.IPromise<TView>;
115-
callCached<TView>(): ng.IPromise<TView>;
116+
call(): ng.IPromise<string>;
117+
callCached(): ng.IPromise<string>;
116118
}
117119

118120
export class GetSomething implements IGetSomething, IEndpoint {
@@ -150,8 +152,8 @@ namespace Endpoints {
150152
}
151153

152154
export interface IGetSomethingElseWithCall extends IGetSomethingElse, IEndpoint {
153-
call<TView>(): ng.IPromise<TView>;
154-
callCached<TView>(): ng.IPromise<TView>;
155+
call(): ng.IPromise<string>;
156+
callCached(): ng.IPromise<string>;
155157
}
156158

157159
export class GetSomethingElse implements IGetSomethingElse, IEndpoint {
@@ -183,12 +185,50 @@ namespace Endpoints {
183185
}
184186
}
185187

188+
export interface IGetEnumerableString {
189+
}
190+
191+
export interface IGetEnumerableStringWithCall extends IGetEnumerableString, IEndpoint {
192+
call(): ng.IPromise<string[]>;
193+
callCached(): ng.IPromise<string[]>;
194+
}
195+
196+
export class GetEnumerableString implements IGetEnumerableString, IEndpoint {
197+
_verb = 'GET';
198+
199+
constructor(args?: IGetEnumerableString) {
200+
}
201+
202+
toString = (): string => {
203+
return `/api/Test/${this.hole}/actions/GetEnumerableString`;
204+
}
205+
}
206+
207+
export interface IGetIHttpActionResult {
208+
}
209+
210+
export interface IGetIHttpActionResultWithCall extends IGetIHttpActionResult, IEndpoint {
211+
call<TView>(): ng.IPromise<TView>;
212+
callCached<TView>(): ng.IPromise<TView>;
213+
}
214+
215+
export class GetIHttpActionResult implements IGetIHttpActionResult, IEndpoint {
216+
_verb = 'GET';
217+
218+
constructor(args?: IGetIHttpActionResult) {
219+
}
220+
221+
toString = (): string => {
222+
return `/api/Test/${this.hole}/actions/GetIHttpActionResult`;
223+
}
224+
}
225+
186226
export interface IPost {
187227
hole: string;
188228
}
189229

190230
export interface IPostWithCall extends IPost, IEndpoint {
191-
call<TView>(value: Interfaces.IDummyClass): ng.IPromise<TView>;
231+
call(value: Interfaces.IDummyClass): ng.IPromise<string>;
192232
}
193233

194234
export class Post implements IPost, IEndpoint {
@@ -209,7 +249,7 @@ namespace Endpoints {
209249
}
210250

211251
export interface IPost1WithCall extends IPost1, IEndpoint {
212-
call<TView>(value: Interfaces.IDerivedClassWithShadowedProperty): ng.IPromise<TView>;
252+
call(value: Interfaces.IDerivedClassWithShadowedProperty): ng.IPromise<string>;
213253
}
214254

215255
export class Post1 implements IPost1, IEndpoint {
@@ -230,7 +270,7 @@ namespace Endpoints {
230270
}
231271

232272
export interface IPost2WithCall extends IPost2, IEndpoint {
233-
call<TView>(value: Interfaces.IDerivedClassWithAnotherShadowedProperty): ng.IPromise<TView>;
273+
call(value: Interfaces.IDerivedClassWithAnotherShadowedProperty): ng.IPromise<string>;
234274
}
235275

236276
export class Post2 implements IPost2, IEndpoint {
@@ -252,7 +292,7 @@ namespace Endpoints {
252292
}
253293

254294
export interface IPutWithCall extends IPut, IEndpoint {
255-
call<TView>(value: string): ng.IPromise<TView>;
295+
call(value: string): ng.IPromise<string>;
256296
}
257297

258298
export class Put implements IPut, IEndpoint {
@@ -276,7 +316,7 @@ namespace Endpoints {
276316
}
277317

278318
export interface IDeleteWithCall extends IDelete, IEndpoint {
279-
call<TView>(): ng.IPromise<TView>;
319+
call(): ng.IPromise<string>;
280320
}
281321

282322
export class Delete implements IDelete, IEndpoint {
@@ -318,8 +358,8 @@ namespace Endpoints {
318358
}
319359

320360
export interface IGetAllWithCall extends IGetAll, IEndpoint {
321-
call<TView>(): ng.IPromise<TView>;
322-
callCached<TView>(): ng.IPromise<TView>;
361+
call(): ng.IPromise<string>;
362+
callCached(): ng.IPromise<string>;
323363
}
324364

325365
export class GetAll implements IGetAll, IEndpoint {
@@ -340,8 +380,8 @@ namespace Endpoints {
340380
}
341381

342382
export interface IGetWithCall extends IGet, IEndpoint {
343-
call<TView>(): ng.IPromise<TView>;
344-
callCached<TView>(): ng.IPromise<TView>;
383+
call(): ng.IPromise<string>;
384+
callCached(): ng.IPromise<string>;
345385
}
346386

347387
export class Get implements IGet, IEndpoint {
@@ -379,8 +419,8 @@ namespace Endpoints {
379419
}
380420

381421
export interface IGettyWithCall extends IGetty, IEndpoint {
382-
call<TView>(): ng.IPromise<TView>;
383-
callCached<TView>(): ng.IPromise<TView>;
422+
call(): ng.IPromise<string>;
423+
callCached(): ng.IPromise<string>;
384424
}
385425

386426
export class Getty implements IGetty, IEndpoint {
@@ -414,7 +454,7 @@ namespace Endpoints {
414454
}
415455

416456
export interface IPostWithCall extends IPost, IEndpoint {
417-
call<TView>(value: Interfaces.IMegaClass): ng.IPromise<TView>;
457+
call(value: Interfaces.IMegaClass): ng.IPromise<string>;
418458
}
419459

420460
export class Post implements IPost, IEndpoint {

0 commit comments

Comments
 (0)