Bumped package version to 1.3.9 added support for Enum code generation and support for inherited types.
This commit is contained in:
@ -12,7 +12,14 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public class User
|
||||
public class BaseUser
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public UserRole Role { get; set; }
|
||||
}
|
||||
|
||||
public class User : BaseUser
|
||||
{
|
||||
public string Name = null;
|
||||
|
||||
@ -28,6 +35,13 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
}
|
||||
}
|
||||
|
||||
public enum UserRole : byte
|
||||
{
|
||||
Unknown = 0,
|
||||
Admin = 2,
|
||||
User = 1
|
||||
}
|
||||
|
||||
public static RouteFileCache FileCache = new RouteFileCache(100 * 1024 * 1024);
|
||||
|
||||
public static void Main(string[] args)
|
||||
@ -41,7 +55,8 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
new Route(HttpRequestMethod.Get, "/file/compress", CompressFile),
|
||||
new Route<string>(HttpRequestMethod.Get, "/auth/{username}", Exists),
|
||||
new Route(HttpRequestMethod.Post, "/auth/signup", Signup),
|
||||
new Route(HttpRequestMethod.Get, "/auth/", Json)
|
||||
new Route(HttpRequestMethod.Get, "/auth/", Json),
|
||||
new Route(HttpRequestMethod.Get, "/auth/role", GetRole)
|
||||
);
|
||||
|
||||
string code = listener.GenerateCSharpClient();
|
||||
@ -129,6 +144,13 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
return context.Response.WithStatus(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[RouteGroup("Auth")]
|
||||
[RouteResponse(typeof(UserRole))]
|
||||
public static HttpListenerResponse GetRole(HttpListenerContext context)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(UserRole.Admin);
|
||||
}
|
||||
|
||||
[RouteGroup("Auth")]
|
||||
[RouteName("Get")]
|
||||
[RouteResponse(typeof(User))]
|
||||
|
Reference in New Issue
Block a user