Bumped package version to 1.1.9. Added documentation and cleaned up code. Going to merge into Master.

This commit is contained in:
2023-02-05 12:28:37 -08:00
parent 1475159f1c
commit 42c4682c89
5 changed files with 119 additions and 17 deletions

View File

@ -8,6 +8,7 @@ namespace MontoyaTech.Rest.Net.Example
{
using System;
using System.Net.Http;
using Newtonsoft.Json;
public class Client
{
@ -46,7 +47,7 @@ namespace MontoyaTech.Rest.Net.Example
var response = this.Client.HttpClient.Send(message);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return Newtonsoft.Json.JsonConvert.DeserializeObject<string>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
return JsonConvert.DeserializeObject<string>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
else
throw new Exception("Unexpected Http Response StatusCode:" + response.StatusCode);
}
@ -58,7 +59,7 @@ namespace MontoyaTech.Rest.Net.Example
var response = this.Client.HttpClient.Send(message);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return Newtonsoft.Json.JsonConvert.DeserializeObject<string>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
return JsonConvert.DeserializeObject<string>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
else
throw new Exception("Unexpected Http Response StatusCode:" + response.StatusCode);
}
@ -80,7 +81,7 @@ namespace MontoyaTech.Rest.Net.Example
var response = this.Client.HttpClient.Send(message);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return Newtonsoft.Json.JsonConvert.DeserializeObject<bool>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
return JsonConvert.DeserializeObject<bool>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
else
throw new Exception("Unexpected Http Response StatusCode:" + response.StatusCode);
}
@ -89,7 +90,7 @@ namespace MontoyaTech.Rest.Net.Example
{
var message = new HttpRequestMessage(HttpMethod.Post, $"{this.Client.BaseUrl}/auth/signup");
message.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(request));
message.Content = new StringContent(JsonConvert.SerializeObject(request));
var response = this.Client.HttpClient.Send(message);
@ -104,7 +105,7 @@ namespace MontoyaTech.Rest.Net.Example
var response = this.Client.HttpClient.Send(message);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return Newtonsoft.Json.JsonConvert.DeserializeObject<User>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
return JsonConvert.DeserializeObject<User>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
else
throw new Exception("Unexpected Http Response StatusCode:" + response.StatusCode);
}

View File

@ -37,7 +37,7 @@ namespace MontoyaTech.Rest.Net.Example
new Route(HttpRequestMethod.Get, "/auth/", Json)
);
string code = CodeGenerator.GenerateCSharpClient(listener.Routes);
string code = ClientCodeGenerator.GenerateCSharpClient(listener.Routes);
Console.WriteLine(code);