Skip to content

Commit 33dda25

Browse files
authored
Merge pull request #6 from twcrews/dev
5.1.0
2 parents ea63eaa + 8e257bb commit 33dda25

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [5.1.0] - 2026-02-25
9+
10+
### Added
11+
12+
- Add extension method overloads for `HttpResponseMessage` extensions.
13+
- Add overload for `ReadJsonApiDocumentAsync` which does not accept a `JsonSerializerOptions` parameter.
14+
- Add overload for `ReadJsonApiDocumentAsync<T>` which does not accept a `JsonSerializerOptions` parameter.
15+
- Add overload for `ReadJsonApiCollectionDocumentAsync<T>` which does not accept a `JsonSerializerOptions` parameter.
16+
17+
### Remarks
18+
19+
This version just adds extension methods that mirror `ReadFromJsonAsync<T>(HttpContent, CancellationToken)`, not requiring the `JsonSerializerOptions` parameter. Basically a syntactic shortcut for QOL.
20+
821
## [5.0.0] - 2026-02-20
922

1023
### Changed
@@ -84,6 +97,7 @@ Additionally, this version aims to be more idiomatic by renaming class propertie
8497

8598
Initial release.
8699

100+
[5.1.0]: https://github.com/twcrews/jsonapi-client/compare/5.0.0...5.1.0
87101
[5.0.0]: https://github.com/twcrews/jsonapi-client/compare/4.0.0...5.0.0
88102
[4.0.0]: https://github.com/twcrews/jsonapi-client/compare/3.0.0...4.0.0
89103
[3.0.0]: https://github.com/twcrews/jsonapi-client/compare/2.0.0...3.0.0

Crews.Web.JsonApiClient/Crews.Web.JsonApiClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<PropertyGroup>
1111
<PackageId>Crews.Web.JsonApiClient</PackageId>
12-
<PackageVersion>5.0.0</PackageVersion>
12+
<PackageVersion>5.1.0</PackageVersion>
1313
<Authors>Tommy Crews</Authors>
1414
<Description>
1515
A library containing serialization models and methods for the JSON:API specification.

Crews.Web.JsonApiClient/HttpResponseMessageExtensions.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ public static class HttpResponseMessageExtensions
2424
CancellationToken cancellationToken = default)
2525
=> response.Content.ReadFromJsonAsync<JsonApiDocument>(options, cancellationToken);
2626

27+
/// <summary>
28+
/// Deserializes the HTTP response content as a weakly-typed JSON:API document.
29+
/// </summary>
30+
/// <param name="response">The HTTP response message.</param>
31+
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
32+
/// <returns>
33+
/// A task representing the asynchronous operation. The task result contains a <see cref="JsonApiDocument"/>
34+
/// instance, or <see langword="null"/> if the response content is empty or invalid.
35+
/// </returns>
36+
public static Task<JsonApiDocument?> ReadJsonApiDocumentAsync(
37+
this HttpResponseMessage response,
38+
CancellationToken cancellationToken = default)
39+
=> response.Content.ReadFromJsonAsync<JsonApiDocument>(cancellationToken);
40+
2741
/// <summary>
2842
/// Deserializes the HTTP response content as a strongly-typed JSON:API document with a single resource.
2943
/// </summary>
@@ -42,6 +56,22 @@ public static class HttpResponseMessageExtensions
4256
where T : JsonApiResource
4357
=> response.Content.ReadFromJsonAsync<JsonApiDocument<T>>(options, cancellationToken);
4458

59+
/// <summary>
60+
/// Deserializes the HTTP response content as a strongly-typed JSON:API document with a single resource.
61+
/// </summary>
62+
/// <typeparam name="T">The resource type, which must inherit from <see cref="JsonApiResource"/>.</typeparam>
63+
/// <param name="response">The HTTP response message.</param>
64+
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
65+
/// <returns>
66+
/// A task representing the asynchronous operation. The task result contains a <see cref="JsonApiDocument{T}"/>
67+
/// instance, or <see langword="null"/> if the response content is empty or invalid.
68+
/// </returns>
69+
public static Task<JsonApiDocument<T>?> ReadJsonApiDocumentAsync<T>(
70+
this HttpResponseMessage response,
71+
CancellationToken cancellationToken = default)
72+
where T : JsonApiResource
73+
=> response.Content.ReadFromJsonAsync<JsonApiDocument<T>>(cancellationToken);
74+
4575
/// <summary>
4676
/// Deserializes the HTTP response content as a strongly-typed JSON:API document with a resource collection.
4777
/// </summary>
@@ -59,4 +89,20 @@ public static class HttpResponseMessageExtensions
5989
CancellationToken cancellationToken = default)
6090
where T : JsonApiResource
6191
=> response.Content.ReadFromJsonAsync<JsonApiCollectionDocument<T>>(options, cancellationToken);
92+
93+
/// <summary>
94+
/// Deserializes the HTTP response content as a strongly-typed JSON:API document with a resource collection.
95+
/// </summary>
96+
/// <typeparam name="T">The resource type, which must inherit from <see cref="JsonApiResource"/>.</typeparam>
97+
/// <param name="response">The HTTP response message.</param>
98+
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
99+
/// <returns>
100+
/// A task representing the asynchronous operation. The task result contains a <see cref="JsonApiCollectionDocument{T}"/>
101+
/// instance, or <see langword="null"/> if the response content is empty or invalid.
102+
/// </returns>
103+
public static Task<JsonApiCollectionDocument<T>?> ReadJsonApiCollectionDocumentAsync<T>(
104+
this HttpResponseMessage response,
105+
CancellationToken cancellationToken = default)
106+
where T : JsonApiResource
107+
=> response.Content.ReadFromJsonAsync<JsonApiCollectionDocument<T>>(cancellationToken);
62108
}

0 commit comments

Comments
 (0)