Skip to content

Add support for action return types resolution. #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ angular.module('framework').service('AngularEndpointsService', Framework.Endpoin
{
"WebApiModuleFileName": "string",

"GenerateEndpointsReturnTypes": "boolean",
"GenerateEndpoints": "boolean",
"EndpointsOutputDirectory": "string",
"EndpointsSupportCaching": "boolean",
Expand Down
16 changes: 16 additions & 0 deletions src/WebApiTestApplication/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Metadata;
using System.Web.Http.Results;
using Newtonsoft.Json;

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

[HttpGet]
[Route("GetEnumerableString")]
public IEnumerable<string> GetEnumerableString()
{
return new List<string>();
}

[HttpGet]
[Route("GetIHttpActionResult")]
public IHttpActionResult GetIHttpActionResult()
{
return new OkResult(new HttpRequestMessage());
}

[HttpPost]
[Route("")]
public string Post(string hole, DummyClass value)
Expand Down
80 changes: 60 additions & 20 deletions src/WebApiTestApplication/Scripts/Endpoints/Endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace Endpoints {
Get1: (args?: IGet1) => IGet1WithCall
GetSomething: (args?: IGetSomething) => IGetSomethingWithCall
GetSomethingElse: (args?: IGetSomethingElse) => IGetSomethingElseWithCall
GetEnumerableString: (args?: IGetEnumerableString) => IGetEnumerableStringWithCall
GetIHttpActionResult: (args?: IGetIHttpActionResult) => IGetIHttpActionResultWithCall
Post: (args?: IPost) => IPostWithCall
Post1: (args?: IPost1) => IPost1WithCall
Post2: (args?: IPost2) => IPost2WithCall
Expand All @@ -51,8 +53,8 @@ namespace Endpoints {
}

export interface IGetWithCall extends IGet, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string[]>;
callCached(): ng.IPromise<string[]>;
}

export class Get implements IGet, IEndpoint {
Expand All @@ -74,8 +76,8 @@ namespace Endpoints {
}

export interface IGet1WithCall extends IGet1, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class Get1 implements IGet1, IEndpoint {
Expand Down Expand Up @@ -111,8 +113,8 @@ namespace Endpoints {
}

export interface IGetSomethingWithCall extends IGetSomething, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class GetSomething implements IGetSomething, IEndpoint {
Expand Down Expand Up @@ -150,8 +152,8 @@ namespace Endpoints {
}

export interface IGetSomethingElseWithCall extends IGetSomethingElse, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class GetSomethingElse implements IGetSomethingElse, IEndpoint {
Expand Down Expand Up @@ -183,12 +185,50 @@ namespace Endpoints {
}
}

export interface IGetEnumerableString {
}

export interface IGetEnumerableStringWithCall extends IGetEnumerableString, IEndpoint {
call(): ng.IPromise<string[]>;
callCached(): ng.IPromise<string[]>;
}

export class GetEnumerableString implements IGetEnumerableString, IEndpoint {
_verb = 'GET';

constructor(args?: IGetEnumerableString) {
}

toString = (): string => {
return `/api/Test/${this.hole}/actions/GetEnumerableString`;
}
}

export interface IGetIHttpActionResult {
}

export interface IGetIHttpActionResultWithCall extends IGetIHttpActionResult, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
}

export class GetIHttpActionResult implements IGetIHttpActionResult, IEndpoint {
_verb = 'GET';

constructor(args?: IGetIHttpActionResult) {
}

toString = (): string => {
return `/api/Test/${this.hole}/actions/GetIHttpActionResult`;
}
}

export interface IPost {
hole: string;
}

export interface IPostWithCall extends IPost, IEndpoint {
call<TView>(value: Interfaces.IDummyClass): ng.IPromise<TView>;
call(value: Interfaces.IDummyClass): ng.IPromise<string>;
}

export class Post implements IPost, IEndpoint {
Expand All @@ -209,7 +249,7 @@ namespace Endpoints {
}

export interface IPost1WithCall extends IPost1, IEndpoint {
call<TView>(value: Interfaces.IDerivedClassWithShadowedProperty): ng.IPromise<TView>;
call(value: Interfaces.IDerivedClassWithShadowedProperty): ng.IPromise<string>;
}

export class Post1 implements IPost1, IEndpoint {
Expand All @@ -230,7 +270,7 @@ namespace Endpoints {
}

export interface IPost2WithCall extends IPost2, IEndpoint {
call<TView>(value: Interfaces.IDerivedClassWithAnotherShadowedProperty): ng.IPromise<TView>;
call(value: Interfaces.IDerivedClassWithAnotherShadowedProperty): ng.IPromise<string>;
}

export class Post2 implements IPost2, IEndpoint {
Expand All @@ -252,7 +292,7 @@ namespace Endpoints {
}

export interface IPutWithCall extends IPut, IEndpoint {
call<TView>(value: string): ng.IPromise<TView>;
call(value: string): ng.IPromise<string>;
}

export class Put implements IPut, IEndpoint {
Expand All @@ -276,7 +316,7 @@ namespace Endpoints {
}

export interface IDeleteWithCall extends IDelete, IEndpoint {
call<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
}

export class Delete implements IDelete, IEndpoint {
Expand Down Expand Up @@ -318,8 +358,8 @@ namespace Endpoints {
}

export interface IGetAllWithCall extends IGetAll, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class GetAll implements IGetAll, IEndpoint {
Expand All @@ -340,8 +380,8 @@ namespace Endpoints {
}

export interface IGetWithCall extends IGet, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class Get implements IGet, IEndpoint {
Expand Down Expand Up @@ -379,8 +419,8 @@ namespace Endpoints {
}

export interface IGettyWithCall extends IGetty, IEndpoint {
call<TView>(): ng.IPromise<TView>;
callCached<TView>(): ng.IPromise<TView>;
call(): ng.IPromise<string>;
callCached(): ng.IPromise<string>;
}

export class Getty implements IGetty, IEndpoint {
Expand Down Expand Up @@ -414,7 +454,7 @@ namespace Endpoints {
}

export interface IPostWithCall extends IPost, IEndpoint {
call<TView>(value: Interfaces.IMegaClass): ng.IPromise<TView>;
call(value: Interfaces.IMegaClass): ng.IPromise<string>;
}

export class Post implements IPost, IEndpoint {
Expand Down
Loading