Skip to content
Draft
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
18458de
Support .NET 10
martincostello Mar 30, 2025
26d6b70
Fix test
martincostello Mar 30, 2025
f2cf1e5
Remove obsolete method
martincostello Mar 30, 2025
7011bbc
Update to ASP.NET Core 10 preview 2
martincostello Apr 2, 2025
032b1cb
Merge branch 'master' into dotnet-vnext
martincostello Apr 2, 2025
6637563
Merge branch 'master' into dotnet-vnext
martincostello Apr 2, 2025
f3728d0
Add TODO
martincostello Apr 2, 2025
f515b0b
Partially fix security requirement issue
martincostello Apr 3, 2025
b33f174
Fix test
martincostello Apr 3, 2025
2744775
Fix test
martincostello Apr 3, 2025
833b8c5
Fix type tests
martincostello Apr 3, 2025
8ae0a45
Fix missing descriptions
martincostello Apr 3, 2025
f4eb187
Refactor fix
martincostello Apr 3, 2025
4b7dc56
Merge branch 'master' into dotnet-vnext
martincostello Apr 6, 2025
ae594aa
Merge branch 'master' into dotnet-vnext
martincostello Apr 7, 2025
5b363fd
Fix package reference
martincostello Apr 7, 2025
fefa371
Fix xUnit1051 warnings
martincostello Apr 7, 2025
1b9a9f2
Merge branch 'master' into dotnet-vnext
martincostello Apr 8, 2025
e5bbb15
Merge branch 'master' into dotnet-vnext
martincostello Apr 10, 2025
e854705
Merge branch 'master' into dotnet-vnext
martincostello Apr 10, 2025
12d5cc8
Update to ASP.NET Core 10 preview 3 (#3361)
martincostello Apr 10, 2025
16ff516
Update NuGet packages
martincostello Apr 10, 2025
e59480c
Link to issue
martincostello Apr 11, 2025
0219d47
Fix typo
martincostello Apr 11, 2025
a0bf6d1
Fix tag serialization
martincostello Apr 12, 2025
2ac06c1
Merge branch 'master' into dotnet-vnext
martincostello Apr 14, 2025
3d5a1ce
Fix merge
martincostello Apr 14, 2025
a4fd764
Add issue reference
martincostello Apr 14, 2025
e4d7a34
Remove TODO
martincostello Apr 14, 2025
bb986ca
Fix formatting
martincostello Apr 14, 2025
dd0e1f7
Merge branch 'master' into dotnet-vnext
martincostello Apr 14, 2025
b873904
Merge branch 'master' into dotnet-vnext
martincostello Apr 23, 2025
5cdb231
Merge branch 'master' into dotnet-vnext
martincostello Apr 25, 2025
21acf10
Prepare for .NET 10 preview 4 (#3388)
martincostello Apr 29, 2025
ae180ee
Fix nullability for null schema Type
martincostello Apr 29, 2025
0cc8097
Re-enable MyGet
martincostello May 1, 2025
a12688c
Merge branch 'master' into dotnet-vnext
martincostello May 1, 2025
18f1466
Fix rebase
martincostello May 1, 2025
5b00492
Skip failing tets
martincostello May 1, 2025
90b940b
Update MyGet publish URL
martincostello May 1, 2025
43f208a
Re-disable MyGet publishing
martincostello May 1, 2025
2057457
Merge branch 'master' into dotnet-vnext
martincostello May 1, 2025
cce51db
Merge branch 'master' into dotnet-vnext
martincostello May 9, 2025
4d7db8e
Update to Microsoft.OpenApi 2.0.0 preview 17
martincostello Apr 29, 2025
d02ee7d
Fix API baselines
martincostello Apr 29, 2025
6e096dc
Skip failing tests
martincostello Apr 29, 2025
c5285f2
Use SerializeAs
martincostello Apr 29, 2025
989863b
Fix build
martincostello Apr 29, 2025
7cf5e82
Apply suggestions from code review
martincostello May 13, 2025
876741f
Fix build
martincostello May 15, 2025
966cc92
Disable failing tests
martincostello May 15, 2025
139e858
Fix MergeWith
martincostello May 15, 2025
91b6649
Publish packages
martincostello May 15, 2025
2645264
Merge branch 'master' into dotnet-vnext
martincostello May 15, 2025
d16dbd7
Fix tests
martincostello May 16, 2025
9c3bb78
Remove workaround
martincostello May 16, 2025
d6100d5
Merge branch 'master' into dotnet-vnext
martincostello May 16, 2025
0406f22
Re-enable tests
martincostello May 16, 2025
83d3a2b
Merge branch 'master' into dotnet-vnext
martincostello May 20, 2025
bde75c6
Merge branch 'master' into dotnet-vnext
martincostello May 20, 2025
c1f0749
Re-enable MyGet publishing
martincostello May 23, 2025
116b045
Merge branch 'master' into dotnet-vnext
martincostello May 23, 2025
cb0fb56
Merge branch 'master' into dotnet-vnext
martincostello May 23, 2025
a32f475
Merge branch 'master' into dotnet-vnext
martincostello Jun 1, 2025
b979c15
Apply review suggestions
martincostello Jun 1, 2025
a2e4986
Workaround VS issue
martincostello Jun 1, 2025
5a0d266
Fix culture-insensitive handling of numbers with [Range] (#3426)
bkoelman Jun 1, 2025
9e17d0b
Merge branch 'master' into dotnet-vnext
martincostello Jun 1, 2025
ec4d970
Refactor method
martincostello Jun 1, 2025
9e6dedf
Fix range parsing
martincostello Jun 1, 2025
f5b2e11
Sort AnyOf and OneOf
martincostello Jun 1, 2025
22652de
Merge branch 'master' into dotnet-vnext
martincostello Jun 1, 2025
6c30f2c
Update issue number
martincostello Jun 1, 2025
62a266e
Merge branch 'master' into dotnet-vnext
martincostello Jun 3, 2025
3f8f0a7
Merge branch 'master' into dotnet-vnext
martincostello Jun 4, 2025
07f125a
Merge branch 'master' into dotnet-vnext
martincostello Jun 4, 2025
2a48fa2
Merge branch 'master' into dotnet-vnext
martincostello Jun 5, 2025
529a324
Refactor [Range] handling
martincostello Jun 5, 2025
6c17312
Add test cases for `[Range]`
martincostello Jun 6, 2025
dd8b516
Refactor method to avoid round-trip
martincostello Jun 6, 2025
24f5cd2
Tweak comment
martincostello Jun 6, 2025
619465e
Fix comment
martincostello Jun 6, 2025
6009837
Fix conversion
martincostello Jun 6, 2025
80a519b
Merge branch 'master' into dotnet-vnext
martincostello Jun 6, 2025
5015ee3
Merge branch 'master' into dotnet-vnext
martincostello Jun 6, 2025
98247b3
Merge branch 'master' into dotnet-vnext
martincostello Jun 7, 2025
3ecf154
Update snapshot
martincostello Jun 7, 2025
675a1c1
Update .NET SDK to 10.0.100-preview.5.25277.114 (#3451)
github-actions[bot] Jun 10, 2025
9564222
Bump Microsoft.OpenApi
martincostello Jun 10, 2025
28bca91
Fix build
martincostello Jun 10, 2025
3123fe1
Fix line endings
martincostello Jun 10, 2025
c3b594e
Merge branch 'master' into dotnet-vnext
martincostello Jun 11, 2025
ed9499c
Validate TypedResults is supported for ASP.NET Core 10 (#3455)
jgarciadelanoceda Jun 12, 2025
3c96b7d
Support [ProducesResponseType], [Produces], and [ProducesDefaultRespo…
jgarciadelanoceda Jun 13, 2025
df4712f
Merge branch 'master' into dotnet-vnext
martincostello Jun 13, 2025
c800e7c
Remove workarounds
martincostello Jun 13, 2025
da8103e
Apply suggestions from code review
martincostello Jun 13, 2025
4b1799a
Merge branch 'master' into dotnet-vnext
martincostello Jun 13, 2025
bba77f5
Fix build
martincostello Jun 13, 2025
57f9e26
Merge branch 'master' into dotnet-vnext
martincostello Jun 13, 2025
45fcad8
Fix package version
martincostello Jun 13, 2025
eb96005
Update PublicAPI baselines
martincostello Jun 13, 2025
08c3a6a
Merge branch 'master' into dotnet-vnext
martincostello Jun 14, 2025
12836cb
Merge branch 'master' into dotnet-vnext
martincostello Jul 7, 2025
fb14623
Update _SdkTasksTFM
martincostello Jul 7, 2025
3b15eda
Merge branch 'master' into dotnet-vnext
martincostello Jul 8, 2025
7cd4979
Merge branch 'master' into dotnet-vnext
martincostello Jul 8, 2025
807b811
Merge branch 'master' into dotnet-vnext
martincostello Jul 8, 2025
cdfe74a
Merge branch 'master' into dotnet-vnext
martincostello Jul 8, 2025
c8e5aef
Merge branch 'master' into dotnet-vnext
martincostello Jul 9, 2025
c2bb204
Update to ASP.NET Core 10 preview.6 (#3479)
martincostello Jul 15, 2025
dce8eef
Update Microsoft.OpenApi to 2.0.0
martincostello Jul 15, 2025
440bfbb
Merge branch 'master' into dotnet-vnext
martincostello Jul 18, 2025
32aa034
Remove WithOpenApi usage
martincostello Jul 18, 2025
30b1f06
Merge branch 'master' into dotnet-vnext
martincostello Jul 23, 2025
041171b
Merge branch 'master' into dotnet-vnext
martincostello Jul 24, 2025
c358213
Remove redundant references
martincostello Jul 24, 2025
96d68e9
Add UI tests for SwaggerUI and Redoc
martincostello Jul 29, 2025
a1aea94
Merge branch 'master' into dotnet-vnext
martincostello Jul 29, 2025
9eff208
Merge branch 'master' into dotnet-vnext
martincostello Aug 7, 2025
3d2aaec
Update allowed licenses
martincostello Aug 7, 2025
0e87c69
Update to ASP.NET Core 10 preview 7
martincostello Aug 11, 2025
9634463
Merge branch 'master' into dotnet-vnext
martincostello Aug 12, 2025
501daa5
Remove workaround
martincostello Aug 12, 2025
6af1545
Merge branch 'master' into dotnet-vnext
martincostello Aug 14, 2025
4f710e1
Merge branch 'master' into dotnet-vnext
martincostello Aug 20, 2025
deacb4b
Bump Microsoft.OpenApi to 2.1.0
martincostello Aug 20, 2025
3044e8e
Verify OpenAPI documents
martincostello Aug 20, 2025
b5e0bd4
Merge branch 'master' into dotnet-vnext
martincostello Aug 27, 2025
839d84a
Update snapshots
martincostello Aug 27, 2025
da3f3ae
Apply suggestions from code review
martincostello Aug 27, 2025
ac51a0a
Merge branch 'master' into dotnet-vnext
martincostello Aug 27, 2025
aecce0a
Merge branch 'master' into dotnet-vnext
martincostello Sep 4, 2025
20454c4
Update to .NET 10 RC1 (#3556)
martincostello Sep 9, 2025
bd37663
Merge branch 'master' into dotnet-vnext
martincostello Sep 10, 2025
0cc308b
Fix deprecation warnings
martincostello Sep 10, 2025
539bf47
Merge branch 'master' into dotnet-vnext
martincostello Sep 10, 2025
310e215
Fix whitespace
martincostello Sep 10, 2025
c49d9f6
Merge branch 'master' into dotnet-vnext
martincostello Sep 19, 2025
5634734
Resolve TODO
martincostello Sep 19, 2025
e130c3c
Bump Duende.IdentityServer
martincostello Sep 19, 2025
a5bf413
Simplify reference
martincostello Sep 19, 2025
5b65129
Merge branch 'master' into dotnet-vnext
martincostello Sep 29, 2025
6cad31d
Merge branch 'master' into dotnet-vnext
martincostello Sep 29, 2025
6ac8b2c
Update documentation for v10 and OpenAPI 3.1 (#3585)
martincostello Oct 1, 2025
e67c899
Merge branch 'master' into dotnet-vnext
martincostello Oct 1, 2025
de15009
Merge branch 'master' into dotnet-vnext
martincostello Oct 2, 2025
7c5f7dd
Fix build
martincostello Oct 2, 2025
fbedf49
Merge branch 'master' into dotnet-vnext
martincostello Oct 10, 2025
8f7085d
Update Microsoft.OpenApi
martincostello Oct 10, 2025
d54982d
Bump Microsoft.OpenApi
martincostello Oct 14, 2025
ec84e80
Update to .NET 10 RC2
martincostello Oct 14, 2025
ca66edd
Merge branch 'master' into dotnet-vnext
martincostello Oct 15, 2025
1be1a17
Bump Microsoft.OpenApi
martincostello Oct 21, 2025
a05b233
Update Microsoft.OpenApi
martincostello Oct 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ updates:
- dependency-name: "Microsoft.AspNetCore.Mvc.NewtonsoftJson"
- dependency-name: "Microsoft.AspNetCore.Mvc.Testing"
- dependency-name: "Microsoft.OpenApi"
- dependency-name: "Microsoft.OpenApi.Readers"
- dependency-name: "Microsoft.OpenApi.YamlReader"
- dependency-name: "xunit"
6 changes: 4 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Company>https://github.com/domaindrivendev/Swashbuckle.AspNetCore</Company>
<ContinuousIntegrationBuild Condition=" '$(CI)' != '' ">true</ContinuousIntegrationBuild>
<Copyright>Copyright (c) 2016-$([System.DateTime]::Now.ToString(yyyy)) Richard Morris</Copyright>
<DefaultTargetFrameworks>net9.0;net8.0</DefaultTargetFrameworks>
<DefaultTargetFrameworks>net10.0;net9.0;net8.0</DefaultTargetFrameworks>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnablePackageValidation>$(IsPackable)</EnablePackageValidation>
Expand All @@ -18,6 +18,8 @@
<LangVersion>latest</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<NeutralLanguage>en-US</NeutralLanguage>
<!-- TODO Remove once .NET 10 is stable -->
<NoWarn>$(NoWarn);NU5104</NoWarn>
<NuGetAuditMode>direct</NuGetAuditMode>
<!--
TODO Go through the code and add nullable annotations
Expand All @@ -37,7 +39,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseArtifactsOutput>true</UseArtifactsOutput>
<VersionPrefix>9.0.4</VersionPrefix>
<VersionPrefix>10.0.0</VersionPrefix>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(GITHUB_ACTIONS)' != '' AND '$(DEPENDABOT_JOB_ID)' == '' ">
Expand Down
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.17" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.17" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0-preview.5.25277.114" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.17" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" />
<PackageVersion Include="Microsoft.OpenApi" Version="1.6.23" />
<PackageVersion Include="Microsoft.OpenApi.Readers" Version="1.6.23" />
<PackageVersion Include="Microsoft.OpenApi" Version="2.0.0-preview.18" />
<PackageVersion Include="Microsoft.OpenApi.YamlReader" Version="2.0.0-preview.18" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ for more details.

| Swashbuckle Version | ASP.NET Core | Swagger/OpenAPI Spec. | swagger-ui | Redoc |
|----------|----------|----------|----------|----------|
| [CI](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/commits/master/) | >= 8.0.0 | 2.0, 3.0 | [5.x.x](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.SwaggerUI/package.json#L6) | [2.x.x](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.ReDoc/package.json#L6) |
| [CI](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/commits/master/) | >= 8.0.0 | 2.0, 3.0, 3.1 | [5.x.x](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.SwaggerUI/package.json#L6) | [2.x.x](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.ReDoc/package.json#L6) |
| [9.0.3](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/v9.0.3) | >= 8.0.0 | 2.0, 3.0 | [5.26.2](https://github.com/swagger-api/swagger-ui/releases/tag/v5.26.2) | [2.5.0](https://github.com/Redocly/redoc/releases/tag/v2.5.0) |
| [8.1.4](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/v8.1.4) | >= 8.0.0, 2.3.x | 2.0, 3.0 | [5.22.0](https://github.com/swagger-api/swagger-ui/releases/tag/v5.22.0) | [2.5.0](https://github.com/Redocly/redoc/releases/tag/v2.5.0) |
| [7.3.2](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/v7.3.2) | >= 8.0.0, 6.0.x, 2.1.x | 2.0, 3.0 | [5.20.1](https://github.com/swagger-api/swagger-ui/releases/tag/v5.20.1) | [2.4.0](https://github.com/Redocly/redoc/releases/tag/v2.4.0) |
Expand Down
2 changes: 1 addition & 1 deletion docs/configure-and-customize-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class Product
```csharp
public class ProductSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
{
schema.Example = new OpenApiObject
{
Expand Down
5 changes: 3 additions & 2 deletions docs/configure-and-customize-swaggergen.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,12 @@ to inform the AutoRest tool how enums should be modelled when it generates the A
```csharp
public class AutoRestSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
{
var type = context.Type;
if (type.IsEnum)
{
schema.Extensions ??= [];
schema.Extensions.Add(
"x-ms-enum",
new OpenApiObject
Expand Down Expand Up @@ -708,7 +709,7 @@ so you will need [a special JsonConverter, as shown in the .NET documentation](h
```csharp
public class DictionaryTKeyEnumTValueSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
public void Apply(IOpenApiSchema schema, SchemaFilterContext context)
{
// Only run for fields that are a Dictionary<Enum, TValue>
if (!context.Type.IsGenericType || !context.Type.GetGenericTypeDefinition().IsAssignableFrom(typeof(Dictionary<,>)))
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.302",
"version": "10.0.100-preview.5.25277.114",
"allowPrerelease": false,
"rollForward": "latestMajor",
"paths": [ ".dotnet", "$host$" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\..\src\Swashbuckle.AspNetCore.Swagger\Swashbuckle.AspNetCore.Swagger.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
Expand Down
21 changes: 12 additions & 9 deletions perf/Swashbuckle.AspNetCore.Benchmarks/XmlCommentsBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public void Setup()
using var xmlStream = new MemoryStream();
xmlDocument.Save(xmlStream);
xmlStream.Seek(0, SeekOrigin.Begin);

var xPathDocument = new XPathDocument(xmlStream);
var members = XmlCommentsDocumentHelper.CreateMemberDictionary(xPathDocument);

// Document
_document = new OpenApiDocument();
Expand All @@ -83,21 +85,21 @@ public void Setup()
null,
null);

_documentFilter = new XmlCommentsDocumentFilter(xPathDocument);
_documentFilter = new XmlCommentsDocumentFilter(members, new());

// Operation
_operation = new OpenApiOperation();
var methodInfo = typeof(FakeConstructedControllerWithXmlComments)
.GetMethod(nameof(FakeConstructedControllerWithXmlComments.ActionWithSummaryAndResponseTags));

var apiDescription = ApiDescriptionFactory.Create(methodInfo: methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource");
_operationFilterContext = new OperationFilterContext(apiDescription, null, null, methodInfo);
_operationFilter = new XmlCommentsOperationFilter(xPathDocument);
_operationFilterContext = new OperationFilterContext(apiDescription, null, null, null, methodInfo);
_operationFilter = new XmlCommentsOperationFilter(members, new());

// Parameter
_parameter = new()
{
Schema = new()
Schema = new OpenApiSchema()
{
Type = JsonSchemaTypes.String,
Description = "schema-level description",
Expand All @@ -106,8 +108,9 @@ public void Setup()

var propertyInfo = typeof(XmlAnnotatedType).GetProperty(nameof(XmlAnnotatedType.StringProperty));
var apiParameterDescription = new ApiParameterDescription();
_parameterFilterContext = new ParameterFilterContext(apiParameterDescription, null, null, propertyInfo: propertyInfo);
_parameterFilter = new XmlCommentsParameterFilter(xPathDocument);
var xmlDocMembers = XmlCommentsDocumentHelper.CreateMemberDictionary(xPathDocument);
_parameterFilterContext = new ParameterFilterContext(apiParameterDescription, null, null, null, propertyInfo: propertyInfo);
_parameterFilter = new XmlCommentsParameterFilter(xmlDocMembers, new());

// Request Body
_requestBody = new OpenApiRequestBody
Expand All @@ -116,7 +119,7 @@ public void Setup()
{
["application/json"] = new()
{
Schema = new()
Schema = new OpenApiSchema()
{
Type = JsonSchemaTypes.String,
},
Expand All @@ -131,8 +134,8 @@ public void Setup()
{
ParameterDescriptor = new ControllerParameterDescriptor { ParameterInfo = parameterInfo }
};
_requestBodyFilterContext = new RequestBodyFilterContext(bodyParameterDescription, null, null, null);
_requestBodyFilter = new XmlCommentsRequestBodyFilter(xPathDocument);
_requestBodyFilterContext = new RequestBodyFilterContext(bodyParameterDescription, null, null, null, null);
_requestBodyFilter = new XmlCommentsRequestBodyFilter(xmlDocMembers, new());
}

[Benchmark]
Expand Down
26 changes: 26 additions & 0 deletions src/Shared/JsonExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Text.Json;
using System.Text.Json.Nodes;

namespace Swashbuckle.AspNetCore;

internal static class JsonExtensions
{
private static readonly JsonSerializerOptions Options = new()
{
#if NET9_0_OR_GREATER
NewLine = "\n",
#endif
WriteIndented = true,
};

public static string ToJson(this JsonNode value)
{
var json = value.ToJsonString(Options);

#if !NET9_0_OR_GREATER
json = json.Replace("\r\n", "\n");
#endif

return json;
}
}
16 changes: 9 additions & 7 deletions src/Shared/JsonSchemaTypes.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.OpenApi.Models;

namespace Swashbuckle.AspNetCore;

internal static class JsonSchemaTypes
{
public const string Array = "array";
public const string Boolean = "boolean";
public const string Integer = "integer";
public const string Number = "number";
public const string Null = "null";
public const string Object = "object";
public const string String = "string";
public static readonly JsonSchemaType Array = JsonSchemaType.Array;
public static readonly JsonSchemaType Boolean = JsonSchemaType.Boolean;
public static readonly JsonSchemaType Integer = JsonSchemaType.Integer;
public static readonly JsonSchemaType Number = JsonSchemaType.Number;
public static readonly JsonSchemaType Null = JsonSchemaType.Null;
public static readonly JsonSchemaType Object = JsonSchemaType.Object;
public static readonly JsonSchemaType String = JsonSchemaType.String;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,32 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
}

private static void ApplySwaggerTagAttribute(
OpenApiDocument swaggerDoc,
OpenApiDocument document,
string controllerName,
IEnumerable<object> customAttributes)
{
var swaggerTagAttribute = customAttributes
.OfType<SwaggerTagAttribute>()
.FirstOrDefault();

if (swaggerTagAttribute == null)
if (swaggerTagAttribute is null)
{
return;
}

swaggerDoc.Tags.Add(new OpenApiTag
var tag = document.Tags.FirstOrDefault((p) => p?.Name == controllerName);

if (tag is null)
{
tag = new() { Name = controllerName };
document.Tags.Add(tag);
}

tag.Description ??= swaggerTagAttribute.Description;

if (swaggerTagAttribute.ExternalDocsUrl is { } url)
{
Name = controllerName,
Description = swaggerTagAttribute.Description,
ExternalDocs = (swaggerTagAttribute.ExternalDocsUrl != null)
? new OpenApiExternalDocs { Url = new Uri(swaggerTagAttribute.ExternalDocsUrl) }
: null
});
tag.ExternalDocs ??= new OpenApiExternalDocs { Url = new(url) };
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.References;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace Swashbuckle.AspNetCore.Annotations;
Expand Down Expand Up @@ -69,7 +70,7 @@ private static void ApplySwaggerOperationAttribute(

if (swaggerOperationAttribute.Tags is { } tags)
{
operation.Tags = [.. tags.Select(tagName => new OpenApiTag { Name = tagName })];
operation.Tags = [.. tags.Select(tagName => new OpenApiTagReference(tagName))];
}
}

Expand Down Expand Up @@ -113,17 +114,19 @@ private static void ApplySwaggerResponseAttributes(

operation.Responses[statusCode] = response;

if (swaggerResponseAttribute.ContentTypes is { } contentTypes)
if (response is OpenApiResponse concrete &&
swaggerResponseAttribute.ContentTypes is { } contentTypes)
{
response.Content.Clear();
concrete.Content?.Clear();
concrete.Content ??= [];

foreach (var contentType in contentTypes)
{
var schema = (swaggerResponseAttribute.Type != null && swaggerResponseAttribute.Type != typeof(void))
? context.SchemaGenerator.GenerateSchema(swaggerResponseAttribute.Type, context.SchemaRepository)
: null;

response.Content.Add(contentType, new OpenApiMediaType { Schema = schema });
concrete.Content.Add(contentType, new OpenApiMediaType { Schema = schema });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace Swashbuckle.AspNetCore.Annotations;

public class AnnotationsParameterFilter : IParameterFilter
{
public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
public void Apply(IOpenApiParameter parameter, ParameterFilterContext context)
{
if (context.PropertyInfo != null)
if (context.PropertyInfo is { } propertyInfo)
{
ApplyPropertyAnnotations(parameter, context.PropertyInfo);
ApplyPropertyAnnotations(parameter, propertyInfo);
}
else if (context.ParameterInfo != null)

if (context.ParameterInfo is { } parameterInfo)
{
ApplyParamAnnotations(parameter, context.ParameterInfo);
ApplyParamAnnotations(parameter, parameterInfo);
}
}

private static void ApplyPropertyAnnotations(OpenApiParameter parameter, PropertyInfo propertyInfo)
private static void ApplyPropertyAnnotations(IOpenApiParameter parameter, PropertyInfo propertyInfo)
{
var swaggerParameterAttribute = propertyInfo.GetCustomAttributes<SwaggerParameterAttribute>()
.FirstOrDefault();
Expand All @@ -29,7 +31,7 @@ private static void ApplyPropertyAnnotations(OpenApiParameter parameter, Propert
}
}

private static void ApplyParamAnnotations(OpenApiParameter parameter, ParameterInfo parameterInfo)
private static void ApplyParamAnnotations(IOpenApiParameter parameter, ParameterInfo parameterInfo)
{
var swaggerParameterAttribute = parameterInfo.GetCustomAttribute<SwaggerParameterAttribute>();

Expand All @@ -39,7 +41,7 @@ private static void ApplyParamAnnotations(OpenApiParameter parameter, ParameterI
}
}

private static void ApplySwaggerParameterAttribute(OpenApiParameter parameter, SwaggerParameterAttribute swaggerParameterAttribute)
private static void ApplySwaggerParameterAttribute(IOpenApiParameter parameter, SwaggerParameterAttribute swaggerParameterAttribute)
{
if (swaggerParameterAttribute.Description is { } description)
{
Expand Down
Loading
Loading