Skip to content

Commit 686b613

Browse files
Eevert openapi changes
1 parent 1f1ef9e commit 686b613

2 files changed

Lines changed: 0 additions & 69 deletions

File tree

JsonApiToolkit/Extensions/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.AspNetCore.Mvc;
55
using Microsoft.AspNetCore.Mvc.Formatters;
66
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.OpenApi.Models;
87

98
namespace JsonApiToolkit.Extensions
109
{
@@ -64,73 +63,6 @@ public static IServiceCollection AddJsonApiToolkit(this IServiceCollection servi
6463
services.AddScoped<JsonApiExceptionFilter>();
6564
services.AddScoped<JsonApiContentTypeFilter>();
6665

67-
// Register OpenAPI document transformer for JSON:API content types
68-
services.AddOpenApi(o =>
69-
{
70-
// OpenAPI document transformer that rewrites request and response content types
71-
// to "application/vnd.api+json" for all endpoints tagged as "JsonApi".
72-
o.AddDocumentTransformer(
73-
(document, _, _) =>
74-
{
75-
foreach (var path in document.Paths.Values)
76-
{
77-
foreach (var operation in path.Operations.Values)
78-
{
79-
// Only apply to operations tagged as "JsonApi"
80-
if (operation.Tags.Any(t => t.Name == "JsonApi"))
81-
{
82-
// Rewrite request body content types
83-
if (operation.RequestBody != null)
84-
{
85-
if (
86-
operation.RequestBody.Content.TryGetValue(
87-
"application/json",
88-
out var jsonContent
89-
)
90-
)
91-
{
92-
operation.RequestBody.Content[
93-
"application/vnd.api+json"
94-
] = jsonContent;
95-
operation.RequestBody.Content.Remove(
96-
"application/json"
97-
);
98-
}
99-
else if (
100-
!operation.RequestBody.Content.ContainsKey(
101-
"application/vnd.api+json"
102-
)
103-
)
104-
{
105-
operation.RequestBody.Content[
106-
"application/vnd.api+json"
107-
] = new OpenApiMediaType();
108-
}
109-
}
110-
111-
// Rewrite response content types
112-
foreach (var response in operation.Responses.Values)
113-
{
114-
if (
115-
response.Content.TryGetValue(
116-
"application/json",
117-
out var jsonContent
118-
)
119-
)
120-
{
121-
response.Content["application/vnd.api+json"] =
122-
jsonContent;
123-
response.Content.Remove("application/json");
124-
}
125-
}
126-
}
127-
}
128-
}
129-
return Task.CompletedTask;
130-
}
131-
);
132-
});
133-
13466
return services;
13567
}
13668
}

JsonApiToolkit/JsonApiToolkit.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
2626
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
2727
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.2" />
28-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.4" />
2928
</ItemGroup>
3029
<ItemGroup>
3130
<None Include="README.md" Pack="true" PackagePath="\" />

0 commit comments

Comments
 (0)