Skip to content

Commit 7604846

Browse files
committed
Stuff
1 parent b259414 commit 7604846

File tree

14 files changed

+5838
-81
lines changed

14 files changed

+5838
-81
lines changed

src/Examples/JsonApiDotNetCoreExample/GeneratedSwagger/JsonApiDotNetCoreExample.json

+180-72
Large diffs are not rendered by default.

src/Examples/JsonApiDotNetCoreExampleClient/JsonApiDotNetCoreExampleClient.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<ItemGroup>
2828
<OpenApiReference Include="..\JsonApiDotNetCoreExample\GeneratedSwagger\JsonApiDotNetCoreExample.json" CodeGenerator="NSwagCSharp" ClassName="ExampleApiClient">
29-
<Options>/GenerateExceptionClasses:false /WrapResponses:true /ResponseClass:JsonApiResponse /GenerateOptionalParameters:true /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.Exceptions</Options>
29+
<Options>/GenerateExceptionClasses:false /WrapResponses:true /ResponseClass:JsonApiResponse /GenerateOptionalParameters:true /GenerateNullableReferenceTypes:true /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.Exceptions</Options>
3030
</OpenApiReference>
3131
</ItemGroup>
3232
</Project>

src/Examples/JsonApiDotNetCoreExampleClient/Program.cs

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using JsonApiDotNetCore.OpenApi.Client;
2+
using JsonApiDotNetCore.OpenApi.Client.Exceptions;
23
using JsonApiDotNetCoreExampleClient;
4+
using Microsoft.AspNetCore.Http;
5+
using Microsoft.Net.Http.Headers;
36

47
#if DEBUG
58
using var httpClient = new HttpClient(new ColoredConsoleLogDelegatingHandler
@@ -12,13 +15,15 @@
1215

1316
var apiClient = new ExampleApiClient(httpClient);
1417

15-
JsonApiResponse<PersonCollectionResponseDocument> getResponse = await apiClient.GetPersonCollectionAsync(new Dictionary<string, string?>
18+
JsonApiResponse<PersonCollectionResponseDocument> getResponse = await GetPersonCollectionAsync(apiClient);
19+
20+
try
1621
{
17-
["filter"] = "has(assignedTodoItems)",
18-
["sort"] = "-lastName",
19-
["page[size]"] = "5",
20-
["include"] = "assignedTodoItems.tags"
21-
});
22+
getResponse = await GetPersonCollectionAsync(apiClient, getResponse.Headers[HeaderNames.ETag].First());
23+
}
24+
catch (ApiException exception) when (exception.StatusCode == StatusCodes.Status304NotModified)
25+
{
26+
}
2227

2328
foreach (PersonDataInResponse person in getResponse.Result.Data)
2429
{
@@ -47,6 +52,19 @@
4752
Console.WriteLine("Press any key to close.");
4853
Console.ReadKey();
4954

55+
#pragma warning disable AV1553
56+
static Task<JsonApiResponse<PersonCollectionResponseDocument>> GetPersonCollectionAsync(ExampleApiClient apiClient, string? ifNoneMatch = null)
57+
#pragma warning restore AV1553
58+
{
59+
return apiClient.GetPersonCollectionAsync(new Dictionary<string, string?>
60+
{
61+
["filter"] = "has(assignedTodoItems)",
62+
["sort"] = "-lastName",
63+
["page[size]"] = "5",
64+
["include"] = "assignedTodoItems.tags"
65+
}, ifNoneMatch);
66+
}
67+
5068
static void PrintPerson(PersonDataInResponse person, ICollection<DataInResponse> includes)
5169
{
5270
ToManyTodoItemInResponse assignedTodoItems = person.Relationships.AssignedTodoItems;

src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiOperationDocumentationFilter.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,11 @@ private static void AddHeaderParameterIfNoneMatch(OpenApiOperation operation)
545545
Required = false,
546546
Schema = new OpenApiSchema
547547
{
548-
Type = "string"
549-
}
548+
Type = "string",
549+
Default = new OpenApiString(null),
550+
Nullable = true,
551+
},
552+
Example = new OpenApiString("\"33a64df551425fcc55e4d42a148795d9f25f89d4\"")
550553
});
551554
}
552555
}

0 commit comments

Comments
 (0)