Skip to content

Commit

Permalink
Moved System.Text.Json support to separate library
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Oct 3, 2023
1 parent aac8ae6 commit a76a2f9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ The main TypedRest library.
Adds support for streaming with [ReactiveX (Rx)](http://reactivex.io/).
Create endpoints using the types in the `TypedRest.Endpoints.Reactive` namespace.

[![TypedRest.SystemTextJson](https://img.shields.io/nuget/v/TypedRest.SystemTextJson.svg?label=TypedRest.SystemTextJson)](https://www.nuget.org/packages/TypedRest.Reactive/)
Adds support for serializing using [System.Text.Json](https://learn.microsoft.com/en-us/dotnet/api/system.text.json) instead of [Newtonsoft.Json](https://www.newtonsoft.com/json).
Pass `new SystemTextJsonSerializer()` to the `EntryEndpoint` constructor.

[![TypedRest.OAuth](https://img.shields.io/nuget/v/TypedRest.OAuth.svg?label=TypedRest.OAuth)](https://www.nuget.org/packages/TypedRest.OAuth/)
Adds support for [OAuth 2.0](https://oauth.net/2/) / [OpenID Connect](https://openid.net/connect/) authentication to [HttpClient](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient).
Call `.AddOAuthHandler()` after `.AddTypedRest()` (or `.AddHttpClient()` when not using main TypedRest package).
Expand Down
4 changes: 4 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ The main TypedRest library.
Adds support for streaming with [ReactiveX (Rx)](http://reactivex.io/).
Create endpoints using the types in the <xref:TypedRest.Endpoints.Reactive> namespace.

[TypedRest.SystemTextJson](https://www.nuget.org/packages/TypedRest.SystemTextJson/)
Adds support for serializing using [System.Text.Json](https://learn.microsoft.com/en-us/dotnet/api/system.text.json) instead of [Newtonsoft.Json](https://www.newtonsoft.com/json).
Pass a <xref:TypedRest.Serializers.SystemTextJsonSerializer> instance to the <xref:TypedRest.Endpoints.EntryEndpoint> constructor.

[TypedRest.OAuth](https://www.nuget.org/packages/TypedRest.OAuth/)
Adds support for [OAuth 2.0](https://oauth.net/2/) / [OpenID Connect](https://openid.net/connect/) authentication to <xref:System.Net.Http.HttpClient>.
Call `.AddOAuthHandler()` after `.AddTypedRest()` (or `.AddHttpClient()` when not using main TypedRest package).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Net.Http.Formatting;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand All @@ -6,6 +7,8 @@ namespace TypedRest.Serializers;
/// <summary>
/// Handles serializing/deserializing from/to JSON using <see cref="System.Text.Json"/>.
/// Uses camel-case naming and does not serialize <c>null</c> by default.
///
/// **NuGet:** [TypedRest.SystemTextJson](https://www.nuget.org/packages/TypedRest.SystemTextJson/)
/// </summary>
public class SystemTextJsonSerializer : MediaTypeFormatter
{
Expand Down
23 changes: 23 additions & 0 deletions src/TypedRest.SystemTextJson/TypedRest.SystemTextJson.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- Project properties -->
<PropertyGroup>
<RootNamespace>TypedRest</RootNamespace>
<Summary>System.Text.Json support for TypedRest</Summary>
<Description>Adds support for serializing using System.Text.Json to TypedRest. Pass new SystemTextJsonSerializer() to the EntryEndpoint constructor.</Description>
<PackageTags>REST;Client;Type-safe;JSON;Serializer;System.Text.JSON</PackageTags>
<OutputPath>..\..\artifacts\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework)!='netstandard2.0'">
<Nullable>enable</Nullable>
</PropertyGroup>

<!-- Dependencies -->
<ItemGroup>
<ProjectReference Include="..\TypedRest\TypedRest.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="6.0.8" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/TypedRest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypedRest", "TypedRest\Type
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypedRest.Reactive", "TypedRest.Reactive\TypedRest.Reactive.csproj", "{A9A75ECC-93CA-4055-AFD5-6E7BA5826939}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypedRest.SystemTextJson", "TypedRest.SystemTextJson\TypedRest.SystemTextJson.csproj", "{23D25AF5-4D22-4062-BCBE-3A87BF97BBA7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypedRest.OAuth", "TypedRest.OAuth\TypedRest.OAuth.csproj", "{178420C1-3E4F-4445-BE5F-F97B7ED30FB7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypedRest.CommandLine", "TypedRest.CommandLine\TypedRest.CommandLine.csproj", "{0EBBB26C-3F15-43A1-90AA-2A738CD1E299}"
Expand All @@ -32,6 +34,10 @@ Global
{A9A75ECC-93CA-4055-AFD5-6E7BA5826939}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9A75ECC-93CA-4055-AFD5-6E7BA5826939}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9A75ECC-93CA-4055-AFD5-6E7BA5826939}.Release|Any CPU.Build.0 = Release|Any CPU
{23D25AF5-4D22-4062-BCBE-3A87BF97BBA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23D25AF5-4D22-4062-BCBE-3A87BF97BBA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23D25AF5-4D22-4062-BCBE-3A87BF97BBA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23D25AF5-4D22-4062-BCBE-3A87BF97BBA7}.Release|Any CPU.Build.0 = Release|Any CPU
{178420C1-3E4F-4445-BE5F-F97B7ED30FB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{178420C1-3E4F-4445-BE5F-F97B7ED30FB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{178420C1-3E4F-4445-BE5F-F97B7ED30FB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
1 change: 0 additions & 1 deletion src/TypedRest/TypedRest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<PackageReference Include="Resta.UriTemplates" Version="1.4.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="7.0.2" />
<PackageReference Include="System.Text.Json" Version="6.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.22" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<!-- Dependencies -->
<ItemGroup>
<ProjectReference Include="..\TypedRest.CommandLine\TypedRest.CommandLine.csproj" />
<ProjectReference Include="..\TypedRest.SystemTextJson\TypedRest.SystemTextJson.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
Expand Down

0 comments on commit a76a2f9

Please sign in to comment.