Get rid of Newtonsoft.Json everywhere but the HTTP abstractions
This commit is contained in:
parent
7b06965f14
commit
cf0cd743b8
15 changed files with 105 additions and 48 deletions
|
@ -27,7 +27,6 @@
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.36" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.36" />
|
||||||
<PackageReference Include="JikanDotNet" Version="1.6.0" />
|
<PackageReference Include="JikanDotNet" Version="1.6.0" />
|
||||||
<PackageReference Include="MtgApiManager.Lib" Version="1.2.2" />
|
<PackageReference Include="MtgApiManager.Lib" Version="1.2.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
|
||||||
<PackageReference Include="PokeApi.NET" Version="1.1.2" />
|
<PackageReference Include="PokeApi.NET" Version="1.1.2" />
|
||||||
<PackageReference Include="Sentry" Version="3.9.2" />
|
<PackageReference Include="Sentry" Version="3.9.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
using Newtonsoft.Json;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Bot.Commands.Integrations.LolMmr
|
namespace Geekbot.Bot.Commands.Integrations.LolMmr
|
||||||
{
|
{
|
||||||
public class LolMrrInfoDto
|
public class LolMrrInfoDto
|
||||||
{
|
{
|
||||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
[JsonPropertyName("avg")]
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
public decimal Avg { get; set; } = 0;
|
public decimal Avg { get; set; } = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,19 +1,19 @@
|
||||||
using Newtonsoft.Json;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Bot.Commands.Utils.Corona
|
namespace Geekbot.Bot.Commands.Utils.Corona
|
||||||
{
|
{
|
||||||
public record CoronaApiCountryResponseDto
|
public record CoronaApiCountryResponseDto
|
||||||
{
|
{
|
||||||
[JsonProperty("country")]
|
[JsonPropertyName("country")]
|
||||||
public string Country { get; init; }
|
public string Country { get; init; }
|
||||||
|
|
||||||
[JsonProperty("cases")]
|
[JsonPropertyName("cases")]
|
||||||
public decimal Cases { get; init; }
|
public decimal Cases { get; init; }
|
||||||
|
|
||||||
[JsonProperty("deaths")]
|
[JsonPropertyName("deaths")]
|
||||||
public decimal Deaths { get; init; }
|
public decimal Deaths { get; init; }
|
||||||
|
|
||||||
[JsonProperty("recovered")]
|
[JsonPropertyName("recovered")]
|
||||||
public decimal Recovered { get; init; }
|
public decimal Recovered { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,26 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageApiUrls
|
public class PageApiUrls
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("summary")]
|
||||||
public Uri Summary { get; set; }
|
public Uri Summary { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("metadata")]
|
||||||
public Uri Metadata { get; set; }
|
public Uri Metadata { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("references")]
|
||||||
public Uri References { get; set; }
|
public Uri References { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("media")]
|
||||||
public Uri Media { get; set; }
|
public Uri Media { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("edit_html")]
|
||||||
public Uri EditHtml { get; set; }
|
public Uri EditHtml { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("talk_page_html")]
|
||||||
public Uri TalkPageHtml { get; set; }
|
public Uri TalkPageHtml { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageContentUrlCollection
|
public class PageContentUrlCollection
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("desktop")]
|
||||||
public PageContentUrls Desktop { get; set; }
|
public PageContentUrls Desktop { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("mobile")]
|
||||||
public PageContentUrls Mobile { get; set; }
|
public PageContentUrls Mobile { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,20 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageContentUrls
|
public class PageContentUrls
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("page")]
|
||||||
public Uri Page { get; set; }
|
public Uri Page { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("revisions")]
|
||||||
public Uri Revisions { get; set; }
|
public Uri Revisions { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("edit")]
|
||||||
public Uri Edit { get; set; }
|
public Uri Edit { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("talk")]
|
||||||
public Uri Talk { get; set; }
|
public Uri Talk { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageCoordinates
|
public class PageCoordinates
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("lat")]
|
||||||
public float Lat { get; set; }
|
public float Lat { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("lon")]
|
||||||
public float Lon { get; set; }
|
public float Lon { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageImage
|
public class PageImage
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("source")]
|
||||||
public Uri Source { get; set; }
|
public Uri Source { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("width")]
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("height")]
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageNamespace
|
public class PageNamespace
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
public ulong Id { get; set; }
|
public ulong Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("text")]
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,67 +1,65 @@
|
||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using System.Text.Json.Serialization;
|
||||||
using Newtonsoft.Json.Converters;
|
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PagePreview
|
public class PagePreview
|
||||||
{
|
{
|
||||||
[JsonProperty("type")]
|
[JsonPropertyName("type")]
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
|
||||||
public PageTypes Type { get; set; }
|
public PageTypes Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("title")]
|
[JsonPropertyName("title")]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
||||||
[JsonProperty("displaytitle")]
|
[JsonPropertyName("displaytitle")]
|
||||||
public string Displaytitle { get; set; }
|
public string Displaytitle { get; set; }
|
||||||
|
|
||||||
[JsonProperty("namespace")]
|
[JsonPropertyName("namespace")]
|
||||||
public PageNamespace Namespace { get; set; }
|
public PageNamespace Namespace { get; set; }
|
||||||
|
|
||||||
[JsonProperty("titles")]
|
[JsonPropertyName("titles")]
|
||||||
public PageTitles Titles { get; set; }
|
public PageTitles Titles { get; set; }
|
||||||
|
|
||||||
[JsonProperty("pageid")]
|
[JsonPropertyName("pageid")]
|
||||||
public ulong Pageid { get; set; }
|
public ulong Pageid { get; set; }
|
||||||
|
|
||||||
[JsonProperty("thumbnail")]
|
[JsonPropertyName("thumbnail")]
|
||||||
public PageImage Thumbnail { get; set; }
|
public PageImage Thumbnail { get; set; }
|
||||||
|
|
||||||
[JsonProperty("originalimage")]
|
[JsonPropertyName("originalimage")]
|
||||||
public PageImage Originalimage { get; set; }
|
public PageImage Originalimage { get; set; }
|
||||||
|
|
||||||
[JsonProperty("lang")]
|
[JsonPropertyName("lang")]
|
||||||
public string Lang { get; set; }
|
public string Lang { get; set; }
|
||||||
|
|
||||||
[JsonProperty("dir")]
|
[JsonPropertyName("dir")]
|
||||||
public string Dir { get; set; }
|
public string Dir { get; set; }
|
||||||
|
|
||||||
[JsonProperty("revision")]
|
[JsonPropertyName("revision")]
|
||||||
public ulong Revision { get; set; }
|
public string Revision { get; set; }
|
||||||
|
|
||||||
[JsonProperty("tid")]
|
[JsonPropertyName("tid")]
|
||||||
public string Tid { get; set; }
|
public string Tid { get; set; }
|
||||||
|
|
||||||
[JsonProperty("timestamp")]
|
[JsonPropertyName("timestamp")]
|
||||||
public DateTimeOffset Timestamp { get; set; }
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
|
|
||||||
[JsonProperty("description")]
|
[JsonPropertyName("description")]
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
[JsonProperty("coordinates")]
|
[JsonPropertyName("coordinates")]
|
||||||
public PageCoordinates Coordinates { get; set; }
|
public PageCoordinates Coordinates { get; set; }
|
||||||
|
|
||||||
[JsonProperty("content_urls")]
|
[JsonPropertyName("content_urls")]
|
||||||
public PageContentUrlCollection ContentUrls { get; set; }
|
public PageContentUrlCollection ContentUrls { get; set; }
|
||||||
|
|
||||||
[JsonProperty("api_urls")]
|
[JsonPropertyName("api_urls")]
|
||||||
public PageApiUrls ApiUrls { get; set; }
|
public PageApiUrls ApiUrls { get; set; }
|
||||||
|
|
||||||
[JsonProperty("extract")]
|
[JsonPropertyName("extract")]
|
||||||
public string Extract { get; set; }
|
public string Extract { get; set; }
|
||||||
|
|
||||||
[JsonProperty("extract_html")]
|
[JsonPropertyName("extract_html")]
|
||||||
public string ExtractHtml { get; set; }
|
public string ExtractHtml { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,16 @@
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
public class PageTitles
|
public class PageTitles
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("Canonical")]
|
||||||
public string Canonical { get; set; }
|
public string Canonical { get; set; }
|
||||||
public string Normalized { get; set; }
|
|
||||||
public string Display { get; set; }
|
|
||||||
|
|
||||||
|
[JsonPropertyName("Normalized")]
|
||||||
|
public string Normalized { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("Display")]
|
||||||
|
public string Display { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient.Page
|
namespace Geekbot.Core.WikipediaClient.Page
|
||||||
{
|
{
|
||||||
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||||
public enum PageTypes
|
public enum PageTypes
|
||||||
{
|
{
|
||||||
[EnumMember(Value = "standard")]
|
[EnumMember(Value = "standard")]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Geekbot.Core.WikipediaClient.Page;
|
using Geekbot.Core.WikipediaClient.Page;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Geekbot.Core.WikipediaClient
|
namespace Geekbot.Core.WikipediaClient
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace Geekbot.Core.WikipediaClient
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var stringResponse = await response.Content.ReadAsStringAsync();
|
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||||
return JsonConvert.DeserializeObject<PagePreview>(stringResponse);
|
return JsonSerializer.Deserialize<PagePreview>(stringResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,11 +2,10 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord.WebSocket;
|
|
||||||
using Geekbot.Core.GlobalSettings;
|
using Geekbot.Core.GlobalSettings;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Geekbot.Web.Controllers.Callback
|
namespace Geekbot.Web.Controllers.Callback
|
||||||
{
|
{
|
||||||
|
@ -45,8 +44,8 @@ namespace Geekbot.Web.Controllers.Callback
|
||||||
result.EnsureSuccessStatusCode();
|
result.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
var stringResponse = await result.Content.ReadAsStringAsync();
|
var stringResponse = await result.Content.ReadAsStringAsync();
|
||||||
var responseData = JsonConvert.DeserializeObject<CallbackTokenResponseDto>(stringResponse);
|
var responseData = JsonSerializer.Deserialize<CallbackTokenResponseDto>(stringResponse);
|
||||||
token = responseData.access_token;
|
token = responseData.AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RedirectResult($"https://geekbot.pizzaandcoffee.rocks/login?token={token}", false);
|
return new RedirectResult($"https://geekbot.pizzaandcoffee.rocks/login?token={token}", false);
|
||||||
|
|
|
@ -1,11 +1,22 @@
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Geekbot.Web.Controllers.Callback
|
namespace Geekbot.Web.Controllers.Callback
|
||||||
{
|
{
|
||||||
public class CallbackTokenResponseDto
|
public class CallbackTokenResponseDto
|
||||||
{
|
{
|
||||||
public string access_token { get; set; }
|
[JsonPropertyName("access_token")]
|
||||||
public string token_type { get; set; }
|
public string AccessToken { get; set; }
|
||||||
public int expires_in { get; set; }
|
|
||||||
public string refresh_token { get; set; }
|
[JsonPropertyName("token_type")]
|
||||||
public string scope { get; set; }
|
public string TokenType { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("expires_in")]
|
||||||
|
public int ExpiresIn { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("refresh_token")]
|
||||||
|
public string RefreshToken { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("scope")]
|
||||||
|
public string Scope { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue