diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 5fedf881c6..b6153137c7 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -1,37 +1,37 @@
-name: codeql-analysis
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
- schedule:
- - cron: '0 8 * * MON'
- workflow_dispatch:
-
-permissions:
- actions: read
- contents: read
-
-jobs:
- code-ql:
-
- runs-on: ubuntu-latest
-
- permissions:
- security-events: write
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-
- - name: Initialize CodeQL
+name: codeql-analysis
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+ schedule:
+ - cron: '0 8 * * MON'
+ workflow_dispatch:
+
+permissions:
+ actions: read
+ contents: read
+
+jobs:
+ code-ql:
+
+ runs-on: ubuntu-latest
+
+ permissions:
+ security-events: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ - name: Initialize CodeQL
uses: github/codeql-action/init@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
- with:
- languages: csharp
- build-mode: none
-
- - name: Perform CodeQL Analysis
+ with:
+ languages: csharp
+ build-mode: none
+
+ - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
- with:
- category: '/language:csharp'
+ with:
+ category: '/language:csharp'
diff --git a/.github/workflows/ossf-scorecard.yml b/.github/workflows/ossf-scorecard.yml
index 323c1c9dce..832c23102c 100644
--- a/.github/workflows/ossf-scorecard.yml
+++ b/.github/workflows/ossf-scorecard.yml
@@ -1,44 +1,44 @@
-name: ossf-scorecard
-
-on:
- push:
- branches: [ master ]
- schedule:
- - cron: '0 8 * * MON'
- workflow_dispatch:
-
-permissions: read-all
-
-jobs:
- analysis:
- name: analysis
- runs-on: ubuntu-latest
-
- permissions:
- id-token: write
- security-events: write
-
- steps:
- - name: Checkout code
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- with:
- persist-credentials: false
-
- - name: Run analysis
+name: ossf-scorecard
+
+on:
+ push:
+ branches: [ master ]
+ schedule:
+ - cron: '0 8 * * MON'
+ workflow_dispatch:
+
+permissions: read-all
+
+jobs:
+ analysis:
+ name: analysis
+ runs-on: ubuntu-latest
+
+ permissions:
+ id-token: write
+ security-events: write
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ with:
+ persist-credentials: false
+
+ - name: Run analysis
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
- with:
- publish_results: true
- results_file: results.sarif
- results_format: sarif
-
- - name: Upload artifact
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
- with:
- name: SARIF
- path: results.sarif
- retention-days: 5
-
- - name: Upload to code-scanning
+ with:
+ publish_results: true
+ results_file: results.sarif
+ results_format: sarif
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: SARIF
+ path: results.sarif
+ retention-days: 5
+
+ - name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
- with:
- sarif_file: results.sarif
+ with:
+ sarif_file: results.sarif
diff --git a/Directory.Build.props b/Directory.Build.props
index ded3e65342..1ccd33fa0f 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -8,6 +8,7 @@
https://github.com/domaindrivendev/Swashbuckle.AspNetCore
true
Copyright (c) 2016-$([System.DateTime]::Now.ToString(yyyy)) Richard Morris
+ net9.0;net8.0
true
true
$(IsPackable)
@@ -40,7 +41,7 @@
snupkg
true
true
- 8.1.5
+ 9.0.0
false
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 9bacda285d..a0338f1464 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,40 +1,32 @@
-
+
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
-
+
-
-
+
-
-
-
+
+
+
diff --git a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs
index faf7aafa7e..e19c077520 100644
--- a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs
+++ b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsOperationFilter.cs
@@ -17,12 +17,10 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
actionAttributes = methodInfo.GetCustomAttributes(true);
}
-#if NET
if (context.ApiDescription?.ActionDescriptor?.EndpointMetadata is { } metadata)
{
metadataAttributes = metadata;
}
-#endif
// NOTE: When controller and action attributes are applicable, action attributes should take priority.
// Hence, why they're at the end of the list (i.e. last one wins).
diff --git a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsSwaggerGenOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsSwaggerGenOptionsExtensions.cs
index 04fe995eda..d27a562e7c 100644
--- a/src/Swashbuckle.AspNetCore.Annotations/AnnotationsSwaggerGenOptionsExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.Annotations/AnnotationsSwaggerGenOptionsExtensions.cs
@@ -62,18 +62,6 @@ private static IEnumerable AnnotationsSubTypesSelector(Type type)
return subTypeAttributes.Select(attr => attr.SubType);
}
-#pragma warning disable CS0618 // Type or member is obsolete
- var obsoleteAttribute = type.GetCustomAttributes(false)
- .OfType()
- .FirstOrDefault();
-#pragma warning restore CS0618 // Type or member is obsolete
-
- if (obsoleteAttribute != null)
- {
- return obsoleteAttribute.SubTypes;
- }
-
-#if NET
var jsonDerivedTypeAttributes = type.GetCustomAttributes(false)
.OfType()
.ToList();
@@ -82,7 +70,6 @@ private static IEnumerable AnnotationsSubTypesSelector(Type type)
{
return jsonDerivedTypeAttributes.Select(attr => attr.DerivedType);
}
-#endif
return [];
}
@@ -98,18 +85,6 @@ private static string AnnotationsDiscriminatorNameSelector(Type baseType)
return discriminatorAttribute.PropertyName;
}
-#pragma warning disable CS0618 // Type or member is obsolete
- var obsoleteAttribute = baseType.GetCustomAttributes(false)
- .OfType()
- .FirstOrDefault();
-#pragma warning restore CS0618 // Type or member is obsolete
-
- if (obsoleteAttribute != null)
- {
- return obsoleteAttribute.Discriminator;
- }
-
-#if NET
var jsonPolymorphicAttributes = baseType.GetCustomAttributes(false)
.OfType()
.FirstOrDefault();
@@ -118,7 +93,6 @@ private static string AnnotationsDiscriminatorNameSelector(Type baseType)
{
return jsonPolymorphicAttributes.TypeDiscriminatorPropertyName;
}
-#endif
return null;
}
@@ -137,7 +111,6 @@ private static string AnnotationsDiscriminatorValueSelector(Type subType)
return subTypeAttribute.DiscriminatorValue;
}
-#if NET
var jsonDerivedTypeAttributes = baseType.GetCustomAttributes(false)
.OfType()
.FirstOrDefault(attr => attr.DerivedType == subType);
@@ -146,7 +119,6 @@ private static string AnnotationsDiscriminatorValueSelector(Type subType)
{
return discriminator;
}
-#endif
baseType = baseType.BaseType;
}
diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt
index 516872bbe4..1988ce538e 100644
--- a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt
+++ b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/PublicAPI.Shipped.txt
@@ -78,11 +78,6 @@ Swashbuckle.AspNetCore.Annotations.SwaggerSubTypeAttribute.DiscriminatorValue.se
Swashbuckle.AspNetCore.Annotations.SwaggerSubTypeAttribute.SubType.get -> System.Type
Swashbuckle.AspNetCore.Annotations.SwaggerSubTypeAttribute.SubType.set -> void
Swashbuckle.AspNetCore.Annotations.SwaggerSubTypeAttribute.SwaggerSubTypeAttribute(System.Type subType) -> void
-Swashbuckle.AspNetCore.Annotations.SwaggerSubTypesAttribute
-Swashbuckle.AspNetCore.Annotations.SwaggerSubTypesAttribute.Discriminator.get -> string
-Swashbuckle.AspNetCore.Annotations.SwaggerSubTypesAttribute.Discriminator.set -> void
-Swashbuckle.AspNetCore.Annotations.SwaggerSubTypesAttribute.SubTypes.get -> System.Collections.Generic.IEnumerable
-Swashbuckle.AspNetCore.Annotations.SwaggerSubTypesAttribute.SwaggerSubTypesAttribute(params System.Type[] subTypes) -> void
Swashbuckle.AspNetCore.Annotations.SwaggerTagAttribute
Swashbuckle.AspNetCore.Annotations.SwaggerTagAttribute.Description.get -> string
Swashbuckle.AspNetCore.Annotations.SwaggerTagAttribute.ExternalDocsUrl.get -> string
diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
deleted file mode 100644
index 3b123b7bc6..0000000000
--- a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.get -> string
-Swashbuckle.AspNetCore.Annotations.SwaggerResponseAttribute.Description.set -> void
diff --git a/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Annotations/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/Swashbuckle.AspNetCore.Annotations/SwaggerSubTypesAttribute.cs b/src/Swashbuckle.AspNetCore.Annotations/SwaggerSubTypesAttribute.cs
deleted file mode 100644
index aa2ab979fd..0000000000
--- a/src/Swashbuckle.AspNetCore.Annotations/SwaggerSubTypesAttribute.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Swashbuckle.AspNetCore.Annotations;
-
-[Obsolete("Use multiple SwaggerSubType attributes instead")]
-[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)]
-public class SwaggerSubTypesAttribute(params Type[] subTypes) : Attribute
-{
- public IEnumerable SubTypes { get; } = subTypes;
-
- public string Discriminator { get; set; }
-}
diff --git a/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj b/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj
index a90380a544..41512118f4 100644
--- a/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj
+++ b/src/Swashbuckle.AspNetCore.Annotations/Swashbuckle.AspNetCore.Annotations.csproj
@@ -8,7 +8,7 @@
$(NoWarn);1591
swagger;documentation;discovery;help;webapi;aspnet;aspnetcore;annotations
true
- net9.0;net8.0;netstandard2.0
+ $(DefaultTargetFrameworks)
diff --git a/src/Swashbuckle.AspNetCore.ApiTesting.Xunit/Swashbuckle.AspNetCore.ApiTesting.Xunit.csproj b/src/Swashbuckle.AspNetCore.ApiTesting.Xunit/Swashbuckle.AspNetCore.ApiTesting.Xunit.csproj
index 83bb4190c0..b877560fdc 100644
--- a/src/Swashbuckle.AspNetCore.ApiTesting.Xunit/Swashbuckle.AspNetCore.ApiTesting.Xunit.csproj
+++ b/src/Swashbuckle.AspNetCore.ApiTesting.Xunit/Swashbuckle.AspNetCore.ApiTesting.Xunit.csproj
@@ -7,7 +7,7 @@
false
$(NoWarn);1591
swagger;openapi;test-first;spec-first;testing;aspnetcore;xunit
- net9.0;net8.0;netstandard2.0
+ $(DefaultTargetFrameworks)
diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs b/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs
index 35722c4aec..1ded5c79de 100644
--- a/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs
+++ b/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs
@@ -57,11 +57,7 @@ public async Task TestAsync(
throw new InvalidOperationException($"Operation with id '{operationId}' not found in OpenAPI document '{documentName}'");
}
-#if NET
if (expectedStatusCode.StartsWith('2'))
-#else
- if (expectedStatusCode.StartsWith("2"))
-#endif
{
_requestValidator.Validate(request, openApiDocument, pathTemplate, operationType);
}
diff --git a/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj b/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj
index 9d184763ec..18a4419b10 100644
--- a/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj
+++ b/src/Swashbuckle.AspNetCore.ApiTesting/Swashbuckle.AspNetCore.ApiTesting.csproj
@@ -6,7 +6,7 @@
true
$(NoWarn);1591
swagger;openapi;test-first;spec-first;testing;aspnetcore
- net9.0;net8.0;netstandard2.0
+ $(DefaultTargetFrameworks)
@@ -15,10 +15,6 @@
-
-
-
-
diff --git a/src/Swashbuckle.AspNetCore.Cli/Program.cs b/src/Swashbuckle.AspNetCore.Cli/Program.cs
index 6b26b0e772..4d27e935f6 100644
--- a/src/Swashbuckle.AspNetCore.Cli/Program.cs
+++ b/src/Swashbuckle.AspNetCore.Cli/Program.cs
@@ -17,7 +17,6 @@ namespace Swashbuckle.AspNetCore.Cli;
internal class Program
{
private const string OpenApiVersionOption = "--openapiversion";
- private const string SerializeAsV2Flag = "--serializeasv2";
public static int Main(string[] args)
{
@@ -41,9 +40,6 @@ public static int Main(string[] args)
c.Option(OpenApiVersionOption, "output Swagger in the specified version, defaults to 3.0");
c.Option("--yaml", "exports swagger in a yaml format", true);
- // TODO Remove this option in the major version that adds support for OpenAPI 3.1
- c.Option(SerializeAsV2Flag, "output Swagger in the V2 format rather than V3 [deprecated]", true);
-
c.OnRun((namedArgs) =>
{
string subProcessCommandLine = PrepareCommandLine(args, namedArgs);
@@ -66,9 +62,6 @@ public static int Main(string[] args)
c.Option(OpenApiVersionOption, "");
c.Option("--yaml", "", true);
- // TODO Remove this option in the major version that adds support for OpenAPI 3.1
- c.Option(SerializeAsV2Flag, "", true);
-
c.OnRun((namedArgs) =>
{
SetupAndRetrieveSwaggerProviderAndOptions(namedArgs, out var swaggerProvider, out var swaggerOptions);
@@ -116,11 +109,6 @@ public static int Main(string[] args)
_ => throw new NotSupportedException($"The specified OpenAPI version \"{versionArg}\" is not supported."),
};
}
- else if (namedArgs.ContainsKey(SerializeAsV2Flag))
- {
- specVersion = OpenApiSpecVersion.OpenApi2_0;
- WriteSerializeAsV2DeprecationWarning();
- }
if (swaggerDocumentSerializer != null)
{
@@ -328,20 +316,4 @@ private static bool TryGetCustomHost(
host = (THost)factoryMethod.Invoke(null, null);
return true;
}
-
- private static void WriteSerializeAsV2DeprecationWarning()
- {
- const string AppName = "Swashbuckle.AspNetCore.Cli";
-
- string message = $"The {SerializeAsV2Flag} flag will be removed in a future version of {AppName}. Use the {OpenApiVersionOption} option instead.";
-
- Console.WriteLine(message);
-
- // See https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
- // and https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
- if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS") is "true")
- {
- Console.WriteLine($"::warning title={AppName}::{message}");
- }
- }
}
diff --git a/src/Swashbuckle.AspNetCore.Cli/Swashbuckle.AspNetCore.Cli.csproj b/src/Swashbuckle.AspNetCore.Cli/Swashbuckle.AspNetCore.Cli.csproj
index 94e7fc8c13..cae9f0c1e9 100644
--- a/src/Swashbuckle.AspNetCore.Cli/Swashbuckle.AspNetCore.Cli.csproj
+++ b/src/Swashbuckle.AspNetCore.Cli/Swashbuckle.AspNetCore.Cli.csproj
@@ -7,7 +7,7 @@
Exe
true
Swashbuckle.AspNetCore.Cli
- net9.0;net8.0
+ $(DefaultTargetFrameworks)
swagger
diff --git a/src/Swashbuckle.AspNetCore.Newtonsoft/DependencyInjection/NewtonsoftServiceCollectionExtensions.cs b/src/Swashbuckle.AspNetCore.Newtonsoft/DependencyInjection/NewtonsoftServiceCollectionExtensions.cs
index 8add7590f2..2007887728 100644
--- a/src/Swashbuckle.AspNetCore.Newtonsoft/DependencyInjection/NewtonsoftServiceCollectionExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.Newtonsoft/DependencyInjection/NewtonsoftServiceCollectionExtensions.cs
@@ -4,10 +4,6 @@
using Swashbuckle.AspNetCore.Newtonsoft;
using Swashbuckle.AspNetCore.SwaggerGen;
-#if !NET
-using MvcNewtonsoftJsonOptions = Microsoft.AspNetCore.Mvc.MvcJsonOptions;
-#endif
-
namespace Microsoft.Extensions.DependencyInjection;
public static class NewtonsoftServiceCollectionExtensions
diff --git a/src/Swashbuckle.AspNetCore.Newtonsoft/SchemaGenerator/NewtonsoftDataContractResolver.cs b/src/Swashbuckle.AspNetCore.Newtonsoft/SchemaGenerator/NewtonsoftDataContractResolver.cs
index 88e62d5913..6132126b1c 100644
--- a/src/Swashbuckle.AspNetCore.Newtonsoft/SchemaGenerator/NewtonsoftDataContractResolver.cs
+++ b/src/Swashbuckle.AspNetCore.Newtonsoft/SchemaGenerator/NewtonsoftDataContractResolver.cs
@@ -43,12 +43,7 @@ public DataContract GetDataContractForType(Type type)
var enumValues = jsonContract.UnderlyingType.GetEnumValues();
// Test to determine if the serializer will treat as string
- var serializeAsString = (enumValues.Length > 0) &&
-#if NET
- JsonConverterFunc(enumValues.GetValue(0)).StartsWith('\"');
-#else
- JsonConverterFunc(enumValues.GetValue(0)).StartsWith("\"");
-#endif
+ var serializeAsString = (enumValues.Length > 0) && JsonConverterFunc(enumValues.GetValue(0)).StartsWith('\"');
var primitiveTypeAndFormat = serializeAsString
? PrimitiveTypesAndFormats[typeof(string)]
@@ -84,11 +79,7 @@ public DataContract GetDataContractForType(Type type)
.Select(JsonConverterFunc);
keys =
-#if NET
enumValuesAsJson.Any(json => json.StartsWith('\"'))
-#else
- enumValuesAsJson.Any(json => json.StartsWith("\""))
-#endif
? enumValuesAsJson.Select(json => json.Replace("\"", string.Empty))
: keyType.GetEnumNames();
}
@@ -181,7 +172,6 @@ private List GetDataPropertiesFor(JsonObjectContract jsonObjectCon
extensionDataType = jsonObjectContract.ExtensionDataValueType;
-#if NET
// If applicable, honor ProblemDetailsConverter
if (jsonObjectContract.UnderlyingType.IsAssignableTo(typeof(Microsoft.AspNetCore.Mvc.ProblemDetails))
&& _serializerSettings.Converters.OfType().Any())
@@ -193,7 +183,6 @@ private List GetDataPropertiesFor(JsonObjectContract jsonObjectCon
extensionDataType = typeof(object);
}
}
-#endif
return dataProperties;
}
@@ -220,11 +209,9 @@ private List GetDataPropertiesFor(JsonObjectContract jsonObjectCon
[typeof(Guid)] = Tuple.Create(DataType.String, "uuid"),
[typeof(Uri)] = Tuple.Create(DataType.String, "uri"),
[typeof(TimeSpan)] = Tuple.Create(DataType.String, "date-span"),
-#if NET
[typeof(DateOnly)] = Tuple.Create(DataType.String, "date"),
[typeof(TimeOnly)] = Tuple.Create(DataType.String, "time"),
[typeof(Int128)] = Tuple.Create(DataType.Integer, "int128"),
[typeof(UInt128)] = Tuple.Create(DataType.Integer, "int128"),
-#endif
};
}
diff --git a/src/Swashbuckle.AspNetCore.Newtonsoft/Swashbuckle.AspNetCore.Newtonsoft.csproj b/src/Swashbuckle.AspNetCore.Newtonsoft/Swashbuckle.AspNetCore.Newtonsoft.csproj
index 50cdf8d789..d1e4860dd0 100644
--- a/src/Swashbuckle.AspNetCore.Newtonsoft/Swashbuckle.AspNetCore.Newtonsoft.csproj
+++ b/src/Swashbuckle.AspNetCore.Newtonsoft/Swashbuckle.AspNetCore.Newtonsoft.csproj
@@ -6,17 +6,13 @@
true
swagger;documentation;discovery;help;webapi;aspnet;aspnetcore;newtonsoft
true
- net9.0;net8.0;netstandard2.0
+ $(DefaultTargetFrameworks)
-
-
-
-
diff --git a/src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs b/src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs
index 012a8ad0a3..a632815d71 100644
--- a/src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs
+++ b/src/Swashbuckle.AspNetCore.ReDoc/ReDocMiddleware.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
@@ -6,18 +7,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileProviders;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Security.Cryptography;
-#if NET
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNetCore.Hosting;
-#else
-using System.Text.Json.Serialization;
-using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
-#endif
-
namespace Swashbuckle.AspNetCore.ReDoc;
internal sealed class ReDocMiddleware
@@ -44,17 +38,6 @@ public ReDocMiddleware(
{
_jsonSerializerOptions = options.JsonSerializerOptions;
}
-#if !NET
- else
- {
- _jsonSerializerOptions = new JsonSerializerOptions()
- {
- IgnoreNullValues = true,
- PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
- Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false) }
- };
- }
-#endif
}
public async Task Invoke(HttpContext httpContext)
@@ -70,11 +53,7 @@ public async Task Invoke(HttpContext httpContext)
{
// Use relative redirect to support proxy environments
var relativeIndexUrl =
-#if NET
string.IsNullOrEmpty(path) || path.EndsWith('/')
-#else
- string.IsNullOrEmpty(path) || path.EndsWith("/")
-#endif
? "index.html"
: $"{path.Split('/').Last()}/index.html";
@@ -147,11 +126,7 @@ private static void SetCacheHeaders(HttpResponse response, ReDocOptions options,
private static void RespondWithRedirect(HttpResponse response, string location)
{
response.StatusCode = StatusCodes.Status301MovedPermanently;
-#if NET
response.Headers.Location = location;
-#else
- response.Headers["Location"] = location;
-#endif
}
private async Task RespondWithFile(HttpResponse response, string fileName)
@@ -197,18 +172,11 @@ private async Task RespondWithFile(HttpResponse response, string fileName)
private static string HashText(string text)
{
var buffer = Encoding.UTF8.GetBytes(text);
-
-#if NET
var hash = SHA1.HashData(buffer);
-#else
- using var sha = SHA1.Create();
- var hash = sha.ComputeHash(buffer);
-#endif
return Convert.ToBase64String(hash);
}
-#if NET
[UnconditionalSuppressMessage(
"AOT",
"IL2026:RequiresUnreferencedCode",
@@ -217,17 +185,14 @@ private static string HashText(string text)
"AOT",
"IL3050:RequiresDynamicCode",
Justification = "Method is only called if the user provides their own custom JsonSerializerOptions.")]
-#endif
private Dictionary GetIndexArguments()
{
string configObject = null;
-#if NET
if (_jsonSerializerOptions is null)
{
configObject = JsonSerializer.Serialize(_options.ConfigObject, ReDocOptionsJsonContext.Default.ConfigObject);
}
-#endif
configObject ??= JsonSerializer.Serialize(_options.ConfigObject, _jsonSerializerOptions);
diff --git a/src/Swashbuckle.AspNetCore.ReDoc/ReDocOptionsJsonContext.cs b/src/Swashbuckle.AspNetCore.ReDoc/ReDocOptionsJsonContext.cs
index 1ce1726d1e..b1595bcaab 100644
--- a/src/Swashbuckle.AspNetCore.ReDoc/ReDocOptionsJsonContext.cs
+++ b/src/Swashbuckle.AspNetCore.ReDoc/ReDocOptionsJsonContext.cs
@@ -1,5 +1,4 @@
-#if NET
-using System.Text.Json;
+using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
@@ -37,4 +36,3 @@ namespace Swashbuckle.AspNetCore.ReDoc;
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
internal sealed partial class ReDocOptionsJsonContext : JsonSerializerContext;
-#endif
diff --git a/src/Swashbuckle.AspNetCore.ReDoc/Swashbuckle.AspNetCore.ReDoc.csproj b/src/Swashbuckle.AspNetCore.ReDoc/Swashbuckle.AspNetCore.ReDoc.csproj
index 953668a98b..345c45ab8f 100644
--- a/src/Swashbuckle.AspNetCore.ReDoc/Swashbuckle.AspNetCore.ReDoc.csproj
+++ b/src/Swashbuckle.AspNetCore.ReDoc/Swashbuckle.AspNetCore.ReDoc.csproj
@@ -3,16 +3,14 @@
Swashbuckle.AspNetCore.ReDoc.snk
Middleware to expose an embedded version of Redoc from an ASP.NET Core application
+ true
true
+ true
true
$(NoWarn);1591
swagger;documentation;discovery;help;webapi;aspnet;aspnetcore;redoc
true
- net9.0;net8.0;netstandard2.0
-
-
- true
- true
+ $(DefaultTargetFrameworks)
@@ -27,14 +25,7 @@
-
-
-
-
-
-
-
-
+
diff --git a/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerBuilderExtensions.cs b/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerBuilderExtensions.cs
index 3e542e390b..8bb984af0a 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerBuilderExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerBuilderExtensions.cs
@@ -1,9 +1,6 @@
-#if NET
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Patterns;
using Microsoft.AspNetCore.Routing.Template;
-#endif
-
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
@@ -16,13 +13,7 @@ public static class SwaggerBuilderExtensions
/// Register the Swagger middleware with provided options
///
public static IApplicationBuilder UseSwagger(this IApplicationBuilder app, SwaggerOptions options)
- {
-#if NET
- return app.UseMiddleware(options, app.ApplicationServices.GetRequiredService());
-#else
- return app.UseMiddleware(options);
-#endif
- }
+ => app.UseMiddleware(options, app.ApplicationServices.GetRequiredService());
///
/// Register the Swagger middleware with optional setup action for DI-injected options
@@ -41,7 +32,6 @@ public static IApplicationBuilder UseSwagger(
return app.UseSwagger(options);
}
-#if NET
public static IEndpointConventionBuilder MapSwagger(
this IEndpointRouteBuilder endpoints,
string pattern = SwaggerOptions.DefaultRouteTemplate,
@@ -69,5 +59,4 @@ void Configure(SwaggerOptions options)
options.PreSerializeFilters.AddRange(endpointOptions.PreSerializeFilters);
}
}
-#endif
}
diff --git a/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerOptionsExtensions.cs
index 563b21f76a..5728d720f6 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerOptionsExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.Swagger/DependencyInjection/SwaggerOptionsExtensions.cs
@@ -19,14 +19,7 @@ public static void SetCustomDocumentSerializer(
params object[] constructorParameters)
where TDocumentSerializer : ISwaggerDocumentSerializer
{
-#if NET
ArgumentNullException.ThrowIfNull(swaggerOptions);
-#else
- if (swaggerOptions == null)
- {
- throw new ArgumentNullException(nameof(swaggerOptions));
- }
-#endif
swaggerOptions.CustomDocumentSerializer = (TDocumentSerializer)Activator.CreateInstance(typeof(TDocumentSerializer), constructorParameters);
}
}
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/.NETCoreApp/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/.NETCoreApp/PublicAPI.Shipped.txt
deleted file mode 100644
index 7904c68055..0000000000
--- a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/.NETCoreApp/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1 +0,0 @@
-static Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.MapSwagger(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern = "/swagger/{documentName}/swagger.{extension:regex(^(json|ya?ml)$)}", System.Action setupAction = null) -> Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/.NETCoreApp/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/.NETCoreApp/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/PublicAPI.Shipped.txt
index 3058f01886..2ea801b6d3 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/PublicAPI.Shipped.txt
+++ b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/PublicAPI.Shipped.txt
@@ -1,6 +1,7 @@
Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions
Microsoft.Extensions.DependencyInjection.SwaggerOptionsExtensions
Microsoft.Extensions.DependencyInjection.SwaggerServiceCollectionExtensions
+static Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.MapSwagger(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern = "/swagger/{documentName}/swagger.{extension:regex(^(json|ya?ml)$)}", System.Action setupAction = null) -> Microsoft.AspNetCore.Builder.IEndpointConventionBuilder
static Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.UseSwagger(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Swashbuckle.AspNetCore.Swagger.SwaggerOptions options) -> Microsoft.AspNetCore.Builder.IApplicationBuilder
static Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.UseSwagger(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action setupAction = null) -> Microsoft.AspNetCore.Builder.IApplicationBuilder
static Microsoft.Extensions.DependencyInjection.SwaggerOptionsExtensions.SetCustomDocumentSerializer(this Swashbuckle.AspNetCore.Swagger.SwaggerOptions swaggerOptions, params object[] constructorParameters) -> void
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net8.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net8.0/PublicAPI.Shipped.txt
deleted file mode 100644
index 262c06994a..0000000000
--- a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net8.0/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.set -> void
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.set -> void
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net8.0/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net9.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net9.0/PublicAPI.Shipped.txt
deleted file mode 100644
index 262c06994a..0000000000
--- a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net9.0/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.set -> void
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.set -> void
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net9.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/net9.0/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
deleted file mode 100644
index 262c06994a..0000000000
--- a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerEndpointOptions.SerializeAsV2.set -> void
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.get -> bool
-Swashbuckle.AspNetCore.Swagger.SwaggerOptions.SerializeAsV2.set -> void
diff --git a/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.Swagger/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/Swashbuckle.AspNetCore.Swagger/SwaggerEndpointOptions.cs b/src/Swashbuckle.AspNetCore.Swagger/SwaggerEndpointOptions.cs
index 4c860de387..a45d792d3c 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/SwaggerEndpointOptions.cs
+++ b/src/Swashbuckle.AspNetCore.Swagger/SwaggerEndpointOptions.cs
@@ -12,16 +12,6 @@ public SwaggerEndpointOptions()
OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
}
- ///
- /// Return Swagger JSON/YAML in the V2.0 format rather than V3.0.
- ///
- [Obsolete($"This property will be removed in a future version of Swashbuckle.AspNetCore. Use the {nameof(OpenApiVersion)} property instead.")]
- public bool SerializeAsV2
- {
- get => OpenApiVersion == OpenApiSpecVersion.OpenApi2_0;
- set => OpenApiVersion = value ? OpenApiSpecVersion.OpenApi2_0 : OpenApiSpecVersion.OpenApi3_0;
- }
-
///
/// Gets or sets the OpenAPI (Swagger) document version to use.
///
diff --git a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs
index 88c3413409..944dcac9f8 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs
+++ b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs
@@ -2,9 +2,7 @@
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
-#if NET
using Microsoft.AspNetCore.Routing.Patterns;
-#endif
using Microsoft.AspNetCore.Routing.Template;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
@@ -19,9 +17,7 @@ internal sealed class SwaggerMiddleware
private readonly RequestDelegate _next;
private readonly SwaggerOptions _options;
private readonly TemplateMatcher _requestMatcher;
-#if NET
private readonly TemplateBinder _templateBinder;
-#endif
public SwaggerMiddleware(
RequestDelegate next,
@@ -32,7 +28,6 @@ public SwaggerMiddleware(
_requestMatcher = new TemplateMatcher(TemplateParser.Parse(_options.RouteTemplate), []);
}
-#if NET
[ActivatorUtilitiesConstructor]
public SwaggerMiddleware(
RequestDelegate next,
@@ -41,7 +36,6 @@ public SwaggerMiddleware(
{
_templateBinder = templateBinderFactory.Create(RoutePatternFactory.Parse(_options.RouteTemplate));
}
-#endif
public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
{
@@ -109,12 +103,11 @@ private bool RequestingSwaggerDocument(HttpRequest request, out string documentN
var routeValues = new RouteValueDictionary();
if (_requestMatcher.TryMatch(request.Path, routeValues))
{
-#if NET
if (_templateBinder != null && !_templateBinder.TryProcessConstraints(request.HttpContext, routeValues, out _, out _))
{
return false;
}
-#endif
+
if (routeValues.TryGetValue("documentName", out var documentNameObject) && documentNameObject is string documentNameString)
{
documentName = documentNameString;
diff --git a/src/Swashbuckle.AspNetCore.Swagger/SwaggerOptions.cs b/src/Swashbuckle.AspNetCore.Swagger/SwaggerOptions.cs
index a3bde0b634..4ee7f48ed2 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/SwaggerOptions.cs
+++ b/src/Swashbuckle.AspNetCore.Swagger/SwaggerOptions.cs
@@ -19,16 +19,6 @@ public SwaggerOptions()
///
public string RouteTemplate { get; set; } = DefaultRouteTemplate;
- ///
- /// Return Swagger JSON/YAML in the V2.0 format rather than V3.0.
- ///
- [Obsolete($"This property will be removed in a future version of Swashbuckle.AspNetCore. Use the {nameof(OpenApiVersion)} property instead.")]
- public bool SerializeAsV2
- {
- get => OpenApiVersion == OpenApiSpecVersion.OpenApi2_0;
- set => OpenApiVersion = value ? OpenApiSpecVersion.OpenApi2_0 : OpenApiSpecVersion.OpenApi3_0;
- }
-
///
/// Gets or sets the OpenAPI (Swagger) document version to use.
///
diff --git a/src/Swashbuckle.AspNetCore.Swagger/Swashbuckle.AspNetCore.Swagger.csproj b/src/Swashbuckle.AspNetCore.Swagger/Swashbuckle.AspNetCore.Swagger.csproj
index 4a69b96afd..e391e5959d 100644
--- a/src/Swashbuckle.AspNetCore.Swagger/Swashbuckle.AspNetCore.Swagger.csproj
+++ b/src/Swashbuckle.AspNetCore.Swagger/Swashbuckle.AspNetCore.Swagger.csproj
@@ -3,22 +3,16 @@
Swashbuckle.AspNetCore.Swagger.snk
Middleware to expose Swagger JSON endpoints from APIs built on ASP.NET Core
+ true
true
true
$(NoWarn);1591
swagger;documentation;discovery;help;webapi;aspnet;aspnetcore
true
- net9.0;net8.0;netstandard2.0
-
-
- true
+ $(DefaultTargetFrameworks)
-
-
-
-
-
+
diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
index c2fdf8f759..bf9bea3344 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSwaggerGeneratorOptions.cs
@@ -1,13 +1,8 @@
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
-#if NET
-using Microsoft.AspNetCore.Hosting;
-#else
-using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
-#endif
-
namespace Swashbuckle.AspNetCore.SwaggerGen;
internal class ConfigureSwaggerGeneratorOptions(
diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs
index cbcdccf3c2..a3d9e60ec8 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs
@@ -67,20 +67,6 @@ public static void CustomOperationIds(
swaggerGenOptions.SwaggerGeneratorOptions.OperationIdSelector = operationIdSelector;
}
-
- ///
- /// Provide a custom strategy for assigning a default "tag" to operations
- ///
- ///
- ///
- [Obsolete("Deprecated: Use the overload that accepts a Func that returns a list of tags")]
- public static void TagActionsBy(
- this SwaggerGenOptions swaggerGenOptions,
- Func tagSelector)
- {
- swaggerGenOptions.SwaggerGeneratorOptions.TagsSelector = (apiDesc) => [tagSelector(apiDesc)];
- }
-
///
/// Provide a custom strategy for assigning "tags" to actions
///
@@ -860,31 +846,4 @@ public static void IncludeXmlComments(
Path.Combine(AppContext.BaseDirectory, $"{assembly.GetName().Name}.xml"),
includeControllerXmlComments);
}
-
- ///
- /// Generate polymorphic schemas (i.e. "oneOf") based on discovered subtypes.
- /// Deprecated: Use the \"UseOneOfForPolymorphism\" and \"UseAllOfForInheritance\" settings instead
- ///
- ///
- ///
- ///
- [Obsolete("You can use \"UseOneOfForPolymorphism\", \"UseAllOfForInheritance\" and \"SelectSubTypesUsing\" to configure equivalent behavior")]
- public static void GeneratePolymorphicSchemas(
- this SwaggerGenOptions swaggerGenOptions,
- Func> subTypesResolver = null,
- Func discriminatorSelector = null)
- {
- swaggerGenOptions.UseOneOfForPolymorphism();
- swaggerGenOptions.UseAllOfForInheritance();
-
- if (subTypesResolver != null)
- {
- swaggerGenOptions.SelectSubTypesUsing(subTypesResolver);
- }
-
- if (discriminatorSelector != null)
- {
- swaggerGenOptions.SelectDiscriminatorNameUsing(discriminatorSelector);
- }
- }
}
diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenServiceCollectionExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenServiceCollectionExtensions.cs
index 9b42e60713..bcbfc82a7e 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenServiceCollectionExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenServiceCollectionExtensions.cs
@@ -54,14 +54,12 @@ public static void ConfigureSwaggerGen(
private sealed class JsonSerializerOptionsProvider
{
private JsonSerializerOptions _options;
-#if NET
private readonly IServiceProvider _serviceProvider;
public JsonSerializerOptionsProvider(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
-#endif
public JsonSerializerOptions Options => _options ??= ResolveOptions();
@@ -75,14 +73,10 @@ private JsonSerializerOptions ResolveOptions()
* then try the default JsonSerializerOptions if available,
* otherwise create a new instance as a last resort as this is an expensive operation.
*/
-#if NET
serializerOptions =
_serviceProvider.GetService>()?.Value?.JsonSerializerOptions
?? _serviceProvider.GetService>()?.Value?.SerializerOptions
?? JsonSerializerOptions.Default;
-#else
- serializerOptions = new JsonSerializerOptions();
-#endif
return serializerOptions;
}
diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt
index ef78297dde..da26904fbb 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt
+++ b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/PublicAPI.Shipped.txt
@@ -18,7 +18,6 @@ static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.Desc
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.DocumentAsyncFilter(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, params object[] arguments) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.DocInclusionPredicate(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, System.Func predicate) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.DocumentFilter(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, params object[] arguments) -> void
-static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.GeneratePolymorphicSchemas(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, System.Func> subTypesResolver = null, System.Func discriminatorSelector = null) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.IgnoreObsoleteActions(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.IgnoreObsoleteProperties(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.IncludeXmlComments(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, string filePath, bool includeControllerXmlComments = false) -> void
@@ -43,7 +42,6 @@ static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.Sele
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.SortSchemasWith(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, System.Collections.Generic.IComparer schemaComparer) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.SupportNonNullableReferenceTypes(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.SwaggerDoc(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, string name, Microsoft.OpenApi.Models.OpenApiInfo info) -> void
-static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.TagActionsBy(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, System.Func tagSelector) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.TagActionsBy(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions, System.Func> tagsSelector) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.UseAllOfForInheritance(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions) -> void
static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.UseAllOfToExtendReferenceSchemas(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions swaggerGenOptions) -> void
@@ -52,7 +50,6 @@ static Microsoft.Extensions.DependencyInjection.SwaggerGenOptionsExtensions.UseO
static Microsoft.Extensions.DependencyInjection.SwaggerGenServiceCollectionExtensions.AddSwaggerGen(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction = null) -> Microsoft.Extensions.DependencyInjection.IServiceCollection
static Microsoft.Extensions.DependencyInjection.SwaggerGenServiceCollectionExtensions.ConfigureSwaggerGen(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action setupAction) -> void
static Swashbuckle.AspNetCore.SwaggerGen.ApiDescriptionExtensions.CustomAttributes(this Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescription apiDescription) -> System.Collections.Generic.IEnumerable