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 -static Swashbuckle.AspNetCore.SwaggerGen.ApiDescriptionExtensions.GetAdditionalMetadata(this Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescription apiDescription, out System.Reflection.MethodInfo methodInfo, out System.Collections.Generic.IEnumerable customAttributes) -> void static Swashbuckle.AspNetCore.SwaggerGen.ApiDescriptionExtensions.TryGetMethodInfo(this Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescription apiDescription, out System.Reflection.MethodInfo methodInfo) -> bool static Swashbuckle.AspNetCore.SwaggerGen.ApiParameterDescriptionExtensions.CustomAttributes(this Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterDescription apiParameter) -> System.Collections.Generic.IEnumerable static Swashbuckle.AspNetCore.SwaggerGen.ApiParameterDescriptionExtensions.IsRequiredParameter(this Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterDescription apiParameter) -> bool @@ -62,7 +59,6 @@ static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForArray(System.Type under static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForDictionary(System.Type underlyingType, System.Type valueType, System.Collections.Generic.IEnumerable keys = null, System.Func jsonConverter = null) -> Swashbuckle.AspNetCore.SwaggerGen.DataContract static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForDynamic(System.Type underlyingType, System.Func jsonConverter = null) -> Swashbuckle.AspNetCore.SwaggerGen.DataContract static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForObject(System.Type underlyingType, System.Collections.Generic.IEnumerable properties, System.Type extensionDataType = null, string typeNameProperty = null, string typeNameValue = null, System.Func jsonConverter = null) -> Swashbuckle.AspNetCore.SwaggerGen.DataContract -static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForPrimitive(System.Type underlyingType, Swashbuckle.AspNetCore.SwaggerGen.DataType dataType, string dataFormat, System.Collections.Generic.IEnumerable enumValues) -> Swashbuckle.AspNetCore.SwaggerGen.DataContract static Swashbuckle.AspNetCore.SwaggerGen.DataContract.ForPrimitive(System.Type underlyingType, Swashbuckle.AspNetCore.SwaggerGen.DataType dataType, string dataFormat, System.Func jsonConverter = null) -> Swashbuckle.AspNetCore.SwaggerGen.DataContract static Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions.GetInlineAndMetadataAttributes(this System.Reflection.MemberInfo memberInfo) -> System.Collections.Generic.IEnumerable static Swashbuckle.AspNetCore.SwaggerGen.MemberInfoExtensions.IsDictionaryValueNonNullable(this System.Reflection.MemberInfo memberInfo) -> bool @@ -96,7 +92,6 @@ Swashbuckle.AspNetCore.SwaggerGen.DataContract.DataFormat.get -> string Swashbuckle.AspNetCore.SwaggerGen.DataContract.DataType.get -> Swashbuckle.AspNetCore.SwaggerGen.DataType Swashbuckle.AspNetCore.SwaggerGen.DataContract.DictionaryKeys.get -> System.Collections.Generic.IEnumerable Swashbuckle.AspNetCore.SwaggerGen.DataContract.DictionaryValueType.get -> System.Type -Swashbuckle.AspNetCore.SwaggerGen.DataContract.EnumValues.get -> System.Collections.Generic.IEnumerable Swashbuckle.AspNetCore.SwaggerGen.DataContract.JsonConverter.get -> System.Func Swashbuckle.AspNetCore.SwaggerGen.DataContract.ObjectExtensionDataType.get -> System.Type Swashbuckle.AspNetCore.SwaggerGen.DataContract.ObjectProperties.get -> System.Collections.Generic.IEnumerable @@ -200,7 +195,6 @@ Swashbuckle.AspNetCore.SwaggerGen.SchemaFilterContext.Type.get -> System.Type Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.GenerateSchema(System.Type modelType, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository, System.Reflection.MemberInfo memberInfo = null, System.Reflection.ParameterInfo parameterInfo = null, Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterRouteInfo routeInfo = null) -> Microsoft.OpenApi.Models.OpenApiSchema Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.SchemaGenerator(Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions generatorOptions, Swashbuckle.AspNetCore.SwaggerGen.ISerializerDataContractResolver serializerDataContractResolver) -> void -Swashbuckle.AspNetCore.SwaggerGen.SchemaGenerator.SchemaGenerator(Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions generatorOptions, Swashbuckle.AspNetCore.SwaggerGen.ISerializerDataContractResolver serializerDataContractResolver, Microsoft.Extensions.Options.IOptions mvcOptions) -> void Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions.CustomTypeMappings.get -> System.Collections.Generic.IDictionary> Swashbuckle.AspNetCore.SwaggerGen.SchemaGeneratorOptions.CustomTypeMappings.set -> void diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt deleted file mode 100644 index 02932c3763..0000000000 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ /dev/null @@ -1,4 +0,0 @@ -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json) -> Microsoft.OpenApi.Any.IOpenApiAny -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory.CreateFromJson(string json, System.Text.Json.JsonSerializerOptions options) -> Microsoft.OpenApi.Any.IOpenApiAny -static Swashbuckle.AspNetCore.SwaggerGen.OpenApiSchemaExtensions.ResolveType(this Microsoft.OpenApi.Models.OpenApiSchema schema, Swashbuckle.AspNetCore.SwaggerGen.SchemaRepository schemaRepository) -> string -Swashbuckle.AspNetCore.SwaggerGen.OpenApiAnyFactory diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 5f282702bb..0000000000 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/DataContract.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/DataContract.cs index 48b487a679..6910d86b22 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/DataContract.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/DataContract.cs @@ -69,20 +69,6 @@ public static DataContract ForDynamic( jsonConverter: jsonConverter); } - [Obsolete("Provide jsonConverter function instead of enumValues")] - public static DataContract ForPrimitive( - Type underlyingType, - DataType dataType, - string dataFormat, - IEnumerable enumValues) - { - return new DataContract( - underlyingType: underlyingType, - dataType: dataType, - dataFormat: dataFormat, - enumValues: enumValues); - } - private DataContract( Type underlyingType, DataType dataType, @@ -100,9 +86,6 @@ private DataContract( UnderlyingType = underlyingType; DataType = dataType; DataFormat = dataFormat; -#pragma warning disable CS0618 // Type or member is obsolete - EnumValues = enumValues; -#pragma warning restore CS0618 // Type or member is obsolete ArrayItemType = arrayItemType; DictionaryValueType = dictionaryValueType; DictionaryKeys = dictionaryKeys; @@ -124,7 +107,4 @@ private DataContract( public string ObjectTypeNameProperty { get; } public string ObjectTypeNameValue { get; } public Func JsonConverter { get; } - - [Obsolete("Use JsonConverter")] - public IEnumerable EnumValues { get; } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/JsonSerializerDataContractResolver.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/JsonSerializerDataContractResolver.cs index 2cfb2140c0..021a95c0eb 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/JsonSerializerDataContractResolver.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/JsonSerializerDataContractResolver.cs @@ -36,11 +36,7 @@ public DataContract GetDataContractForType(Type type) // Test to determine if the serializer will treat as string var serializeAsString = enumValues.Length > 0 && -#if NET JsonConverterFunc(enumValues.GetValue(0), type).StartsWith('\"'); -#else - JsonConverterFunc(enumValues.GetValue(0), type).StartsWith("\""); -#endif var exampleType = serializeAsString ? typeof(string) : @@ -67,11 +63,7 @@ public DataContract GetDataContractForType(Type type) .Select(value => JsonConverterFunc(value, keyType)); keys = -#if NET enumValuesAsJson.Any(json => json.StartsWith('\"')) -#else - enumValuesAsJson.Any(json => json.StartsWith("\"")) -#endif ? enumValuesAsJson.Select(json => json.Replace("\"", string.Empty)) : keyType.GetEnumNames(); } @@ -131,13 +123,11 @@ public bool IsSupportedCollection(Type type, out Type itemType) return true; } -#if NET if (type.IsConstructedFrom(typeof(IAsyncEnumerable<>), out constructedType)) { itemType = constructedType.GenericTypeArguments[0]; return true; } -#endif if (type.IsArray) { @@ -171,7 +161,6 @@ private List GetDataPropertiesFor(Type objectType, out Type extens // .NET 5 introduces JsonIgnoreAttribute.Condition which should be honored bool isIgnoredViaNet5Attribute = true; -#if NET JsonIgnoreAttribute jsonIgnoreAttribute = property.GetCustomAttribute(); if (jsonIgnoreAttribute != null) { @@ -184,7 +173,6 @@ private List GetDataPropertiesFor(Type objectType, out Type extens _ => true }; } -#endif return (property.IsPubliclyReadable() || property.IsPubliclyWritable()) && @@ -215,7 +203,6 @@ private List GetDataPropertiesFor(Type objectType, out Type extens var isRequired = false; -#if NET var deserializationConstructor = propertyInfo.DeclaringType?.GetConstructors() .OrderBy(c => { @@ -241,7 +228,6 @@ private List GetDataPropertiesFor(Type objectType, out Type extens }); isRequired = propertyInfo.GetCustomAttribute() != null; -#endif dataProperties.Add( new DataProperty( @@ -280,11 +266,9 @@ private List GetDataPropertiesFor(Type objectType, out Type extens [typeof(Guid)] = Tuple.Create(DataType.String, "uuid"), [typeof(Uri)] = Tuple.Create(DataType.String, "uri"), [typeof(Version)] = Tuple.Create(DataType.String, (string)null), -#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.SwaggerGen/SchemaGenerator/MemberInfoExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/MemberInfoExtensions.cs index 4a5021eea1..53465982e0 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/MemberInfoExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/MemberInfoExtensions.cs @@ -5,14 +5,6 @@ namespace Swashbuckle.AspNetCore.SwaggerGen; public static class MemberInfoExtensions { -#if !NET - private const string NullableAttributeFullTypeName = "System.Runtime.CompilerServices.NullableAttribute"; - private const string NullableFlagsFieldName = "NullableFlags"; - private const string NullableContextAttributeFullTypeName = "System.Runtime.CompilerServices.NullableContextAttribute"; - private const string FlagFieldName = "Flag"; - private const int NotAnnotated = 1; // See https://github.com/dotnet/roslyn/blob/af7b0ebe2b0ed5c335a928626c25620566372dd1/docs/features/nullable-metadata.md?plain=1#L40 -#endif - public static IEnumerable GetInlineAndMetadataAttributes(this MemberInfo memberInfo) { var attributes = memberInfo.GetCustomAttributes(true) @@ -33,7 +25,6 @@ public static IEnumerable GetInlineAndMetadataAttributes(this MemberInfo return attributes; } -#if NET private static NullabilityInfo GetNullabilityInfo(this MemberInfo memberInfo) { var context = new NullabilityInfoContext(); @@ -46,41 +37,15 @@ private static NullabilityInfo GetNullabilityInfo(this MemberInfo memberInfo) _ => throw new InvalidOperationException($"MemberInfo type {memberInfo.MemberType} is not supported.") }; } -#endif public static bool IsNonNullableReferenceType(this MemberInfo memberInfo) { -#if NET var nullableInfo = GetNullabilityInfo(memberInfo); return nullableInfo.ReadState == NullabilityState.NotNull; -#else - var memberType = memberInfo.MemberType == MemberTypes.Field - ? ((FieldInfo)memberInfo).FieldType - : ((PropertyInfo)memberInfo).PropertyType; - - if (memberType.IsValueType) return false; - - var nullableAttribute = memberInfo.GetNullableAttribute(); - - if (nullableAttribute == null) - { - return memberInfo.GetNullableFallbackValue(); - } - - if (nullableAttribute.GetType().GetField(NullableFlagsFieldName) is FieldInfo field && - field.GetValue(nullableAttribute) is byte[] flags && - flags.Length >= 1 && flags[0] == NotAnnotated) - { - return true; - } - - return false; -#endif } public static bool IsDictionaryValueNonNullable(this MemberInfo memberInfo) { -#if NET var nullableInfo = GetNullabilityInfo(memberInfo); // Assume one generic argument means TKey and TValue are the same type. @@ -95,105 +60,5 @@ public static bool IsDictionaryValueNonNullable(this MemberInfo memberInfo) 2 => nullableInfo.GenericTypeArguments[1].ReadState == NullabilityState.NotNull, _ => false, }; -#else - var memberType = memberInfo.MemberType == MemberTypes.Field - ? ((FieldInfo)memberInfo).FieldType - : ((PropertyInfo)memberInfo).PropertyType; - - if (memberType.IsValueType) return false; - - var nullableAttribute = memberInfo.GetNullableAttribute(); - var genericArguments = memberType.GetGenericArguments(); - - if (genericArguments.Length != 2) - { - return false; - } - - var valueArgument = genericArguments[1]; - var valueArgumentIsNullable = valueArgument.IsGenericType && valueArgument.GetGenericTypeDefinition() == typeof(Nullable<>); - - if (nullableAttribute == null) - { - return !valueArgumentIsNullable && memberInfo.GetNullableFallbackValue(); - } - - if (nullableAttribute.GetType().GetField(NullableFlagsFieldName) is FieldInfo field) - { - if (field.GetValue(nullableAttribute) is byte[] flags) - { - // See https://github.com/dotnet/roslyn/blob/af7b0ebe2b0ed5c335a928626c25620566372dd1/docs/features/nullable-metadata.md - // Observations in the debugger show that the arity of the flags array is 3 only if all 3 items are reference types, i.e. - // Dictionary would have arity 3 (one for the Dictionary, one for the string key, one for the object value), - // however Dictionary would have arity 2 (one for the Dictionary, one for the string key), the value is skipped - // due it being a value type. - if (flags.Length == 2) // Value in the dictionary is a value type. - { - return !valueArgumentIsNullable; - } - else if (flags.Length == 3) // Value in the dictionary is a reference type. - { - return flags[2] == NotAnnotated; - } - } - } - - return false; -#endif - } - -#if !NET - private static object GetNullableAttribute(this MemberInfo memberInfo) - { - var nullableAttribute = memberInfo - .GetCustomAttributes() - .FirstOrDefault(attr => string.Equals(attr.GetType().FullName, NullableAttributeFullTypeName)); - - return nullableAttribute; - } - - private static bool GetNullableFallbackValue(this MemberInfo memberInfo) - { - var declaringTypes = memberInfo.DeclaringType.IsNested - ? GetDeclaringTypeChain(memberInfo) - : [memberInfo.DeclaringType]; - - foreach (var declaringType in declaringTypes) - { - IEnumerable attributes = declaringType.GetCustomAttributes(false); - - var nullableContext = attributes - .FirstOrDefault(attr => string.Equals(attr.GetType().FullName, NullableContextAttributeFullTypeName)); - - if (nullableContext != null) - { - if (nullableContext.GetType().GetField(FlagFieldName) is FieldInfo field && - field.GetValue(nullableContext) is byte flag && flag == NotAnnotated) - { - return true; - } - else - { - return false; - } - } - } - - return false; - } - - private static List GetDeclaringTypeChain(MemberInfo memberInfo) - { - var chain = new List(); - var currentType = memberInfo.DeclaringType; - - while (currentType != null) - { - chain.Add(currentType); - currentType = currentType.DeclaringType; - } - - return chain; } -#endif } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs index 4c0c0d6cf3..68071983f4 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/OpenApiSchemaExtensions.cs @@ -46,7 +46,6 @@ public static void ApplyValidationAttributes(this OpenApiSchema schema, IEnumera { ApplyMaxLengthAttribute(schema, maxLengthAttribute); } -#if NET else if (attribute is LengthAttribute lengthAttribute) { ApplyLengthAttribute(schema, lengthAttribute); @@ -55,7 +54,6 @@ public static void ApplyValidationAttributes(this OpenApiSchema schema, IEnumera { ApplyBase64Attribute(schema); } -#endif else if (attribute is RangeAttribute rangeAttribute) { ApplyRangeAttribute(schema, rangeAttribute); @@ -205,8 +203,6 @@ private static void ApplyMaxLengthRouteConstraint(OpenApiSchema schema, MaxLengt } } -#if NET - private static void ApplyLengthAttribute(OpenApiSchema schema, LengthAttribute lengthAttribute) { if (schema.Type == JsonSchemaTypes.Array) @@ -226,8 +222,6 @@ private static void ApplyBase64Attribute(OpenApiSchema schema) schema.Format = "byte"; } -#endif - private static void ApplyRangeAttribute(OpenApiSchema schema, RangeAttribute rangeAttribute) { if (rangeAttribute.Maximum is int maximumInteger) @@ -260,7 +254,6 @@ private static void ApplyRangeAttribute(OpenApiSchema schema, RangeAttribute ran } } -#if NET if (rangeAttribute.MinimumIsExclusive) { schema.ExclusiveMinimum = true; @@ -270,7 +263,6 @@ private static void ApplyRangeAttribute(OpenApiSchema schema, RangeAttribute ran { schema.ExclusiveMaximum = true; } -#endif } private static void ApplyRangeRouteConstraint(OpenApiSchema schema, RangeRouteConstraint rangeRouteConstraint) diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs index b7f8809a3f..f483d9134e 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; -using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; namespace Swashbuckle.AspNetCore.SwaggerGen; @@ -18,15 +17,6 @@ public class SchemaGenerator( private readonly SchemaGeneratorOptions _generatorOptions = generatorOptions; private readonly ISerializerDataContractResolver _serializerDataContractResolver = serializerDataContractResolver; - [Obsolete($"{nameof(IOptions)} is no longer used. This constructor will be removed in a future major release.")] - public SchemaGenerator( - SchemaGeneratorOptions generatorOptions, - ISerializerDataContractResolver serializerDataContractResolver, - IOptions mvcOptions) - : this(generatorOptions, serializerDataContractResolver) - { - } - public OpenApiSchema GenerateSchema( Type modelType, SchemaRepository schemaRepository, @@ -99,11 +89,7 @@ private OpenApiSchema GenerateSchemaForMember( { var genericTypes = modelType .GetInterfaces() -#if !NET .Concat([modelType]) -#else - .Append(modelType) -#endif .Where(t => t.IsGenericType) .ToArray(); @@ -244,9 +230,7 @@ private OpenApiSchema GeneratePolymorphicSchema( typeof(IFormFile), typeof(FileResult), typeof(Stream), -#if NET typeof(System.IO.Pipelines.PipeReader), -#endif ]; private OpenApiSchema GenerateConcreteSchema(DataContract dataContract, SchemaRepository schemaRepository) @@ -325,19 +309,6 @@ private static OpenApiSchema CreatePrimitiveSchema(DataContract dataContract) Format = dataContract.DataFormat }; -#pragma warning disable CS0618 // Type or member is obsolete - // For backwards compatibility only - EnumValues is obsolete - if (dataContract.EnumValues != null) - { - schema.Enum = [.. dataContract.EnumValues - .Select(value => JsonSerializer.Serialize(value)) - .Distinct() - .Select(JsonModelFactory.CreateFromJson)]; - - return schema; - } -#pragma warning restore CS0618 // Type or member is obsolete - var underlyingType = dataContract.UnderlyingType; if (underlyingType.IsEnum) @@ -465,9 +436,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi dataProperty.IsRequired || markNonNullableTypeAsRequired || customAttributes.OfType().Any() -#if NET || customAttributes.OfType().Any() -#endif ) && !schema.Required.Contains(dataProperty.Name)) { diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiDescriptionExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiDescriptionExtensions.cs index 00dcf23542..cb6bbbe9cd 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiDescriptionExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiDescriptionExtensions.cs @@ -15,7 +15,6 @@ public static bool TryGetMethodInfo(this ApiDescription apiDescription, out Meth return true; } -#if NET if (apiDescription.ActionDescriptor?.EndpointMetadata != null) { methodInfo = apiDescription.ActionDescriptor.EndpointMetadata @@ -24,7 +23,6 @@ public static bool TryGetMethodInfo(this ApiDescription apiDescription, out Meth return methodInfo != null; } -#endif methodInfo = null; return false; @@ -41,22 +39,6 @@ public static IEnumerable CustomAttributes(this ApiDescription apiDescri return []; } - [Obsolete("Use TryGetMethodInfo() and CustomAttributes() instead")] - public static void GetAdditionalMetadata(this ApiDescription apiDescription, - out MethodInfo methodInfo, - out IEnumerable customAttributes) - { - if (apiDescription.TryGetMethodInfo(out methodInfo)) - { - customAttributes = methodInfo.GetCustomAttributes(true) - .Union(methodInfo.DeclaringType.GetCustomAttributes(true)); - } - else - { - customAttributes = []; - } - } - internal static string RelativePathSansParameterConstraints(this ApiDescription apiDescription) { var routeTemplate = TemplateParser.Parse(apiDescription.RelativePath); @@ -64,10 +46,6 @@ internal static string RelativePathSansParameterConstraints(this ApiDescription .Segments .Select(s => string.Concat(s.Parts.Select(p => p.Name != null ? $"{{{p.Name}}}" : p.Text))); -#if NET return string.Join('/', sanitizedSegments); -#else - return string.Join("/", sanitizedSegments); -#endif } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiParameterDescriptionExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiParameterDescriptionExtensions.cs index c52b77ecfc..60b66ef39c 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiParameterDescriptionExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/ApiParameterDescriptionExtensions.cs @@ -14,9 +14,7 @@ public static class ApiParameterDescriptionExtensions [ typeof(BindRequiredAttribute), typeof(RequiredAttribute), -#if NET typeof(System.Runtime.CompilerServices.RequiredMemberAttribute) -#endif ]; private static readonly HashSet IllegalHeaderParameters = new(StringComparer.OrdinalIgnoreCase) @@ -45,23 +43,12 @@ public static bool IsRequiredParameter(this ApiParameterDescription apiParameter } // For non-controllers, prefer the IsRequired flag if we're not on netstandard 2.0, otherwise fallback to the default logic. - return -#if NET - apiParameter.IsRequired; -#else - IsRequired(); -#endif + return apiParameter.IsRequired; } public static ParameterInfo ParameterInfo(this ApiParameterDescription apiParameter) { - var parameterDescriptor = apiParameter.ParameterDescriptor as -#if NET - Microsoft.AspNetCore.Mvc.Infrastructure.IParameterInfoParameterDescriptor; -#else - ControllerParameterDescriptor; -#endif - + var parameterDescriptor = apiParameter.ParameterDescriptor as Microsoft.AspNetCore.Mvc.Infrastructure.IParameterInfoParameterDescriptor; return parameterDescriptor?.ParameterInfo; } @@ -89,19 +76,6 @@ public static IEnumerable CustomAttributes(this ApiParameterDescription return []; } - [Obsolete("Use ParameterInfo(), PropertyInfo() and CustomAttributes() extension methods instead")] - internal static void GetAdditionalMetadata( - this ApiParameterDescription apiParameter, - ApiDescription apiDescription, - out ParameterInfo parameterInfo, - out PropertyInfo propertyInfo, - out IEnumerable parameterOrPropertyAttributes) - { - parameterInfo = apiParameter.ParameterInfo(); - propertyInfo = apiParameter.PropertyInfo(); - parameterOrPropertyAttributes = apiParameter.CustomAttributes(); - } - internal static bool IsFromPath(this ApiParameterDescription apiParameter) { return apiParameter.Source == BindingSource.Path; diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/StringExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/StringExtensions.cs index d2aa7a4b62..192781eec5 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/StringExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/StringExtensions.cs @@ -9,18 +9,10 @@ internal static string ToCamelCase(this string value) return value; } -#if NET - var cameCasedParts = value + var camelCasedParts = value .Split('.') .Select(part => char.ToLowerInvariant(part[0]) + part[1..]); - return string.Join('.', cameCasedParts); -#else - var cameCasedParts = value - .Split('.') - .Select(part => char.ToLowerInvariant(part[0]) + part.Substring(1)); - - return string.Join(".", cameCasedParts); -#endif + return string.Join('.', camelCasedParts); } } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs index b8bb4bc4ba..55c44f9c3d 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGenerator.cs @@ -2,6 +2,7 @@ using System.Text.RegularExpressions; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Metadata; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.ModelBinding; @@ -9,10 +10,6 @@ using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Swagger; -#if NET -using Microsoft.AspNetCore.Http.Metadata; -#endif - namespace Swashbuckle.AspNetCore.SwaggerGen; public class SwaggerGenerator( @@ -326,12 +323,7 @@ private async Task GenerateOperationAsync( Func> bodyGenerator, Func applyFilters) { - OpenApiOperation operation = -#if NET - await GenerateOpenApiOperationFromMetadataAsync(apiDescription, schemaRepository); -#else - null; -#endif + var operation = await GenerateOpenApiOperationFromMetadataAsync(apiDescription, schemaRepository); try { @@ -343,10 +335,8 @@ private async Task GenerateOperationAsync( RequestBody = await bodyGenerator(apiDescription, schemaRepository), Responses = GenerateResponses(apiDescription, schemaRepository), Deprecated = apiDescription.CustomAttributes().OfType().Any(), -#if NET Summary = GenerateSummary(apiDescription), Description = GenerateDescription(apiDescription), -#endif }; apiDescription.TryGetMethodInfo(out MethodInfo methodInfo); @@ -408,7 +398,6 @@ private async Task GenerateOperationAsync( }); } -#if NET private async Task GenerateOpenApiOperationFromMetadataAsync(ApiDescription apiDescription, SchemaRepository schemaRepository) { var metadata = apiDescription.ActionDescriptor?.EndpointMetadata; @@ -514,7 +503,6 @@ private async Task GenerateOpenApiOperationFromMetadataAsync(A return operation; } -#endif private List GenerateOperationTags(OpenApiDocument document, ApiDescription apiDescription) => [.. _options.TagsSelector(apiDescription).Select(tagName => CreateTag(tagName, document))]; @@ -1118,7 +1106,6 @@ private static bool IsFromFormAttributeUsedWithIFormFile(ApiParameterDescription new("default", "Error") ]; -#if NET private static string GenerateSummary(ApiDescription apiDescription) => apiDescription.ActionDescriptor?.EndpointMetadata ?.OfType() @@ -1130,7 +1117,6 @@ private static string GenerateDescription(ApiDescription apiDescription) => ?.OfType() .Select((p) => p.Description) .LastOrDefault(); -#endif private static OpenApiTag CreateTag(string name, OpenApiDocument _) => new() { Name = name }; diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGeneratorOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGeneratorOptions.cs index b762ced1d7..38da942d54 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGeneratorOptions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGeneratorOptions.cs @@ -1,11 +1,7 @@ -#if NET +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http.Metadata; -#endif -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc.ApiExplorer; -#if NET using Microsoft.AspNetCore.Routing; -#endif using Microsoft.OpenApi.Models; namespace Swashbuckle.AspNetCore.SwaggerGen; @@ -96,20 +92,13 @@ private string DefaultOperationIdSelector(ApiDescription apiDescription) // endpoint name if no route name is available. This allows us to // generate operation IDs for endpoints that are defined using // minimal APIs. -#if NET return - actionDescriptor.AttributeRouteInfo?.Name - ?? (actionDescriptor.EndpointMetadata?.LastOrDefault(m => m is IEndpointNameMetadata) as IEndpointNameMetadata)?.EndpointName; -#else - return actionDescriptor.AttributeRouteInfo?.Name; -#endif + actionDescriptor.AttributeRouteInfo?.Name ?? + (actionDescriptor.EndpointMetadata?.LastOrDefault(m => m is IEndpointNameMetadata) as IEndpointNameMetadata)?.EndpointName; } private IList DefaultTagsSelector(ApiDescription apiDescription) { -#if !NET - return [apiDescription.ActionDescriptor.RouteValues["controller"]]; -#else var actionDescriptor = apiDescription.ActionDescriptor; if (actionDescriptor.EndpointMetadata?.LastOrDefault(m => m is ITagsMetadata) is ITagsMetadata metadata) { @@ -117,7 +106,6 @@ private IList DefaultTagsSelector(ApiDescription apiDescription) } return [apiDescription.ActionDescriptor.RouteValues["controller"]]; -#endif } private string DefaultSortKeySelector(ApiDescription apiDescription) diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj b/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj index c87992e2a8..4b492544d4 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/Swashbuckle.AspNetCore.SwaggerGen.csproj @@ -8,7 +8,7 @@ $(NoWarn);1591 swagger;documentation;discovery;help;webapi;aspnet;aspnetcore true - net9.0;net8.0;netstandard2.0 + $(DefaultTargetFrameworks) @@ -21,12 +21,6 @@ - - - - - - diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsTextHelper.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsTextHelper.cs index f6d106fc37..21cb434aa7 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsTextHelper.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsTextHelper.cs @@ -7,9 +7,7 @@ namespace Swashbuckle.AspNetCore.SwaggerGen; public static partial class XmlCommentsTextHelper { public static string Humanize(string text) - { - return Humanize(text, null); - } + => Humanize(text, null); public static string Humanize(string text, string xmlCommentEndOfLine) { @@ -43,17 +41,10 @@ private static string NormalizeIndentation(this string text, string xmlCommentEn { string line = lines[i].TrimEnd('\r'); // Remove trailing '\r' -#if NET if (padLen != 0 && line.Length >= padLen && line[..padLen] == padding) { line = line[padLen..]; } -#else - if (padLen != 0 && line.Length >= padLen && line.Substring(0, padLen) == padding) - { - line = line.Substring(padLen); - } -#endif lines[i] = line; } @@ -103,11 +94,7 @@ private static string GetCommonLeadingWhitespace(string[] lines) if (padLength > 0) { -#if NET return seed[..padLength]; -#else - return seed.Substring(0, padLength); -#endif } return null; @@ -138,22 +125,14 @@ private static string HumanizeMultilineCodeTags(this string text, string xmlComm { var builder = new StringBuilder().Append("```"); -#if NET if (!codeText.StartsWith('\r') && !codeText.StartsWith('\n')) -#else - if (!codeText.StartsWith("\r") && !codeText.StartsWith("\n")) -#endif { builder.Append(EndOfLine(xmlCommentEndOfLine)); } builder.Append(RemoveCommonLeadingWhitespace(codeText, xmlCommentEndOfLine)); -#if NET if (!codeText.EndsWith('\n')) -#else - if (!codeText.EndsWith("\n")) -#endif { builder.Append(EndOfLine(xmlCommentEndOfLine)); } @@ -198,11 +177,7 @@ private static string RemoveCommonLeadingWhitespace(string input, string xmlComm { builder.Append(string.IsNullOrWhiteSpace(line) ? line -#if NET : line[minLeadingSpaces..]); -#else - : line.Substring(minLeadingSpaces)); -#endif builder.Append(EndOfLine(xmlCommentEndOfLine)); } @@ -215,56 +190,27 @@ internal static string EndOfLine(string xmlCommentEndOfLine) return xmlCommentEndOfLine ?? Environment.NewLine; } - private const string RefTagPattern = @"<(see|paramref) (name|cref|langword)=""([TPF]{1}:)?(?.+?)"" ?/>"; - private const string CodeTagPattern = @"(?.+?)"; - private const string MultilineCodeTagPattern = @"(?.+?)"; - private const string ParaTagPattern = @"(?.+?)"; - private const string HrefPattern = @"\s*(.*?)\s*<\/see>"; - private const string BrPattern = @"(
)"; // handles
,
,
- private const string LineBreaksPattern = @"\r?\n"; - private const string DoubleUpLineBreaksPattern = @"(\r?\n){2,}"; - -#if NET - [GeneratedRegex(RefTagPattern)] + [GeneratedRegex(@"<(see|paramref) (name|cref|langword)=""([TPF]{1}:)?(?.+?)"" ?/>")] private static partial Regex RefTag(); - [GeneratedRegex(CodeTagPattern)] + [GeneratedRegex(@"(?.+?)")] private static partial Regex CodeTag(); - [GeneratedRegex(MultilineCodeTagPattern, RegexOptions.Singleline)] + [GeneratedRegex(@"(?.+?)", RegexOptions.Singleline)] private static partial Regex MultilineCodeTag(); - [GeneratedRegex(ParaTagPattern, RegexOptions.Singleline)] + [GeneratedRegex(@"(?.+?)", RegexOptions.Singleline)] private static partial Regex ParaTag(); - [GeneratedRegex(HrefPattern, RegexOptions.Singleline)] + [GeneratedRegex(@"\s*(.*?)\s*<\/see>", RegexOptions.Singleline)] private static partial Regex HrefTag(); - [GeneratedRegex(BrPattern)] + [GeneratedRegex(@"(
)")] // handles
,
,
private static partial Regex BrTag(); - [GeneratedRegex(LineBreaksPattern)] + [GeneratedRegex(@"\r?\n")] private static partial Regex LineBreaks(); - [GeneratedRegex(DoubleUpLineBreaksPattern)] + [GeneratedRegex(@"(\r?\n){2,}")] private static partial Regex DoubleUpLineBreaks(); -#else - private static readonly Regex _refTag = new(RefTagPattern); - private static readonly Regex _codeTag = new(CodeTagPattern); - private static readonly Regex _multilineCodeTag = new(MultilineCodeTagPattern, RegexOptions.Singleline); - private static readonly Regex _paraTag = new(ParaTagPattern, RegexOptions.Singleline); - private static readonly Regex _hrefTag = new(HrefPattern); - private static readonly Regex _brTag = new(BrPattern); - private static readonly Regex _lineBreaks = new(LineBreaksPattern); - private static readonly Regex _doubleUpLineBreaks = new(DoubleUpLineBreaksPattern); - - private static Regex RefTag() => _refTag; - private static Regex CodeTag() => _codeTag; - private static Regex MultilineCodeTag() => _multilineCodeTag; - private static Regex ParaTag() => _paraTag; - private static Regex HrefTag() => _hrefTag; - private static Regex BrTag() => _brTag; - private static Regex LineBreaks() => _lineBreaks; - private static Regex DoubleUpLineBreaks() => _doubleUpLineBreaks; -#endif } diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/ConfigObject.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/ConfigObject.cs index e8015e1836..729a0aee55 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/ConfigObject.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/ConfigObject.cs @@ -44,9 +44,7 @@ public class ConfigObject /// Controls how the model is shown when the API is first rendered. /// (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links) /// -#if NET [JsonConverter(typeof(JavascriptStringEnumConverter))] -#endif [JsonPropertyName("defaultModelRendering")] public ModelRendering DefaultModelRendering { get; set; } = ModelRendering.Example; @@ -60,9 +58,7 @@ public class ConfigObject /// Controls the default expansion setting for the operations and tags. /// It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing) /// -#if NET [JsonConverter(typeof(JavascriptStringEnumConverter))] -#endif [JsonPropertyName("docExpansion")] public DocExpansion DocExpansion { get; set; } = DocExpansion.List; @@ -102,16 +98,9 @@ public class ConfigObject /// List of HTTP methods that have the Try it out feature enabled. /// An empty array disables Try it out for all operations. This does not filter the operations from the display /// -#if NET [JsonConverter(typeof(JavascriptStringEnumEnumerableConverter))] -#endif [JsonPropertyName("supportedSubmitMethods")] - public IEnumerable SupportedSubmitMethods { get; set; } = -#if NET - Enum.GetValues(); -#else - Enum.GetValues(typeof(SubmitMethod)).Cast(); -#endif + public IEnumerable SupportedSubmitMethods { get; set; } = Enum.GetValues(); /// /// Controls whether the "Try it out" section should be enabled by default. diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumConverter.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumConverter.cs index 84c90c0dd0..3372fe612a 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumConverter.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumConverter.cs @@ -1,5 +1,4 @@ -#if NET -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; @@ -7,7 +6,4 @@ namespace Swashbuckle.AspNetCore.SwaggerUI; internal sealed class JavascriptStringEnumConverter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] TEnum>() : JsonStringEnumConverter(JsonNamingPolicy.CamelCase, false) - where TEnum : struct, Enum -{ -} -#endif + where TEnum : struct, Enum; diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumEnumerableConverter.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumEnumerableConverter.cs index bd9029a369..bad02bebd5 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumEnumerableConverter.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/JavascriptStringEnumEnumerableConverter.cs @@ -1,5 +1,4 @@ -#if NET -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; @@ -62,4 +61,3 @@ public override void Write(Utf8JsonWriter writer, IEnumerable value, Json } } } -#endif diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/PublicAPI/PublicAPI.Shipped.txt b/src/Swashbuckle.AspNetCore.SwaggerUI/PublicAPI/PublicAPI.Shipped.txt index bfb7cfb204..21112c4a99 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/PublicAPI/PublicAPI.Shipped.txt @@ -34,7 +34,6 @@ static Microsoft.AspNetCore.Builder.SwaggerUIOptionsExtensions.SupportedSubmitMe static Microsoft.AspNetCore.Builder.SwaggerUIOptionsExtensions.SwaggerEndpoint(this Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIOptions options, string url, string name) -> void static Microsoft.AspNetCore.Builder.SwaggerUIOptionsExtensions.UseRequestInterceptor(this Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIOptions options, string value) -> void static Microsoft.AspNetCore.Builder.SwaggerUIOptionsExtensions.UseResponseInterceptor(this Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIOptions options, string value) -> void -static Microsoft.AspNetCore.Builder.SwaggerUIOptionsExtensions.ValidatorUrl(this Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIOptions options, string url) -> void Swashbuckle.AspNetCore.SwaggerUI.ConfigObject Swashbuckle.AspNetCore.SwaggerUI.ConfigObject.AdditionalItems.get -> System.Collections.Generic.Dictionary Swashbuckle.AspNetCore.SwaggerUI.ConfigObject.AdditionalItems.set -> void diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs index 15616940b4..8855eb65dd 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIBuilderExtensions.cs @@ -1,13 +1,8 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Swashbuckle.AspNetCore.SwaggerUI; -#if NET -using Microsoft.AspNetCore.Hosting; -#else -using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment; -#endif - namespace Microsoft.AspNetCore.Builder; public static class SwaggerUIBuilderExtensions @@ -16,9 +11,7 @@ public static class SwaggerUIBuilderExtensions /// Register the SwaggerUI middleware with provided options /// public static IApplicationBuilder UseSwaggerUI(this IApplicationBuilder app, SwaggerUIOptions options) - { - return app.UseMiddleware(options); - } + => app.UseMiddleware(options); /// /// Register the SwaggerUI middleware with optional setup action for DI-injected options diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIJsonSerializerContext.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIJsonSerializerContext.cs index 0cc8d27962..ae2ceee046 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIJsonSerializerContext.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIJsonSerializerContext.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; @@ -39,4 +38,3 @@ namespace Swashbuckle.AspNetCore.SwaggerUI; DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] internal sealed partial class SwaggerUIOptionsJsonContext : JsonSerializerContext; -#endif diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs index 77f454671a..1ebb7edcd5 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs @@ -1,7 +1,9 @@ -using System.Text; +using System.Diagnostics.CodeAnalysis; +using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.FileProviders; @@ -10,14 +12,6 @@ using System.Reflection; 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.SwaggerUI; internal sealed partial class SwaggerUIMiddleware @@ -44,17 +38,6 @@ public SwaggerUIMiddleware( { _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"; @@ -154,11 +133,7 @@ private static void SetCacheHeaders(HttpResponse response, SwaggerUIOptions opti 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) @@ -201,18 +176,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", @@ -221,7 +189,6 @@ private static string HashText(string text) "AOT", "IL3050:RequiresDynamicCode", Justification = "Method is only called if the user provides their own custom JsonSerializerOptions.")] -#endif private async Task RespondWithDocumentUrls(HttpResponse response) { response.StatusCode = 200; @@ -229,20 +196,17 @@ private async Task RespondWithDocumentUrls(HttpResponse response) response.ContentType = "application/javascript;charset=utf-8"; string json = "[]"; -#if NET if (_jsonSerializerOptions is null) { var l = new List(_options.ConfigObject.Urls); json = JsonSerializer.Serialize(l, SwaggerUIOptionsJsonContext.Default.ListUrlDescriptor); } -#endif json ??= JsonSerializer.Serialize(_options.ConfigObject, _jsonSerializerOptions); await response.WriteAsync(json, Encoding.UTF8); } -#if NET [UnconditionalSuppressMessage( "AOT", "IL2026:RequiresUnreferencedCode", @@ -251,21 +215,18 @@ private async Task RespondWithDocumentUrls(HttpResponse response) "AOT", "IL3050:RequiresDynamicCode", Justification = "Method is only called if the user provides their own custom JsonSerializerOptions.")] -#endif private Dictionary GetIndexArguments() { string configObject = null; string oauthConfigObject = null; string interceptors = null; -#if NET if (_jsonSerializerOptions is null) { configObject = JsonSerializer.Serialize(_options.ConfigObject, SwaggerUIOptionsJsonContext.Default.ConfigObject); oauthConfigObject = JsonSerializer.Serialize(_options.OAuthConfigObject, SwaggerUIOptionsJsonContext.Default.OAuthConfigObject); interceptors = JsonSerializer.Serialize(_options.Interceptors, SwaggerUIOptionsJsonContext.Default.InterceptorFunctions); } -#endif configObject ??= JsonSerializer.Serialize(_options.ConfigObject, _jsonSerializerOptions); oauthConfigObject ??= JsonSerializer.Serialize(_options.OAuthConfigObject, _jsonSerializerOptions); diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs index d155d7b3f2..7801cacb42 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs @@ -194,12 +194,6 @@ public static void OAuth2RedirectUrl(this SwaggerUIOptions options, string url) options.ConfigObject.OAuth2RedirectUrl = url; } - [Obsolete("The validator is disabled by default. Use EnableValidator to enable it")] - public static void ValidatorUrl(this SwaggerUIOptions options, string url) - { - options.ConfigObject.ValidatorUrl = url; - } - /// /// You can use this parameter to enable the swagger-ui's built-in validator (badge) functionality /// Setting it to null will disable validation diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/Swashbuckle.AspNetCore.SwaggerUI.csproj b/src/Swashbuckle.AspNetCore.SwaggerUI/Swashbuckle.AspNetCore.SwaggerUI.csproj index 00075542f3..0e48416301 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/Swashbuckle.AspNetCore.SwaggerUI.csproj +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/Swashbuckle.AspNetCore.SwaggerUI.csproj @@ -3,16 +3,14 @@ Swashbuckle.AspNetCore.SwaggerUI.snk Middleware to expose an embedded version of the swagger-ui from an ASP.NET Core application + true true + true true $(NoWarn);1591 swagger;documentation;discovery;help;webapi;aspnet;aspnetcore true - net9.0;net8.0;netstandard2.0 - - - true - true + $(DefaultTargetFrameworks) @@ -21,14 +19,7 @@ - - - - - - - - + diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/package.json b/src/Swashbuckle.AspNetCore.SwaggerUI/package.json index 014ca372a8..4d9a9c6619 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/package.json +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/package.json @@ -1,11 +1,11 @@ -{ - "name": "swashbuckle", - "version": "1.0.0", - "private": true, - "dependencies": { - "swagger-ui-dist": "5.24.1" - }, - "scripts": { - "postinstall": "node scripts/remove-source-map-links.js" - } -} +{ + "name": "swashbuckle", + "version": "1.0.0", + "private": true, + "dependencies": { + "swagger-ui-dist": "5.24.1" + }, + "scripts": { + "postinstall": "node scripts/remove-source-map-links.js" + } +} diff --git a/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.csproj b/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.csproj index d2eeaecfbf..f031d23868 100644 --- a/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.csproj +++ b/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.csproj @@ -9,19 +9,15 @@ false false true - 6.0.5 $(MSBuildProjectName).nuspec Swashbuckle.AspNetCore swagger;documentation;discovery;help;webapi;aspnet;aspnetcore - net9.0;net8.0;netstandard2.0 + $(DefaultTargetFrameworks) - + 8.0.0 - - - - 9.0.0 + 9.0.0 diff --git a/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.nuspec b/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.nuspec index c92f7cf304..e6a3d2566e 100644 --- a/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.nuspec +++ b/src/Swashbuckle.AspNetCore/Swashbuckle.AspNetCore.nuspec @@ -12,14 +12,6 @@ $description$ $tags$ - - - - - - - - diff --git a/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj b/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj index d27b335c33..8b8a7e1a79 100644 --- a/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj +++ b/test/Swashbuckle.AspNetCore.Annotations.Test/Swashbuckle.AspNetCore.Annotations.Test.csproj @@ -2,7 +2,7 @@ Exe - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj b/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj index 6ab653daf8..889c78c3aa 100644 --- a/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj +++ b/test/Swashbuckle.AspNetCore.ApiTesting.Test/Swashbuckle.AspNetCore.ApiTesting.Test.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/Swashbuckle.AspNetCore.Cli.Test/Swashbuckle.AspNetCore.Cli.Test.csproj b/test/Swashbuckle.AspNetCore.Cli.Test/Swashbuckle.AspNetCore.Cli.Test.csproj index 8eaa53e4dc..eea2f46d29 100644 --- a/test/Swashbuckle.AspNetCore.Cli.Test/Swashbuckle.AspNetCore.Cli.Test.csproj +++ b/test/Swashbuckle.AspNetCore.Cli.Test/Swashbuckle.AspNetCore.Cli.Test.csproj @@ -2,7 +2,7 @@ Exe - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs b/test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs index bf9fe4e494..a57cb33235 100644 --- a/test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs +++ b/test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs @@ -69,27 +69,6 @@ public static void Can_Generate_Swagger_Json_v2_OpenApiVersion() Assert.True(productsPath.TryGetProperty("post", out _)); } - [Fact] - public static void Can_Generate_Swagger_Json_v2_SerializeAsV2() - { - using var document = RunToJsonCommand((outputPath) => - [ - "tofile", - "--output", - outputPath, - "--serializeasv2", - Path.Combine(Directory.GetCurrentDirectory(), "Basic.dll"), - "v1" - ]); - - Assert.Equal("2.0", document.RootElement.GetProperty("swagger").GetString()); - - // verify one of the endpoints - var paths = document.RootElement.GetProperty("paths"); - var productsPath = paths.GetProperty("/products"); - Assert.True(productsPath.TryGetProperty("post", out _)); - } - [Fact] public static void Can_Generate_Swagger_Json_v3() { diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/CustomDocumentSerializerTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/CustomDocumentSerializerTests.cs index 1b698b4237..19dc653086 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/CustomDocumentSerializerTests.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/CustomDocumentSerializerTests.cs @@ -76,11 +76,6 @@ await DocumentProviderWritesCustomV2Document( (options) => options.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi2_0); } - [Obsolete] - [Fact] - public async Task DocumentProvider_Writes_Custom_V2_Document_SerializeAsV2() - => await DocumentProviderWritesCustomV2Document((options) => options.SerializeAsV2 = true); - private async Task DocumentProviderWritesCustomV2Document(Action configure) { var testSite = new TestSite(typeof(CustomDocumentSerializer.Startup), outputHelper); diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/Swashbuckle.AspNetCore.IntegrationTests.csproj b/test/Swashbuckle.AspNetCore.IntegrationTests/Swashbuckle.AspNetCore.IntegrationTests.csproj index a3b564a574..f470f0ff4f 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/Swashbuckle.AspNetCore.IntegrationTests.csproj +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/Swashbuckle.AspNetCore.IntegrationTests.csproj @@ -1,35 +1,16 @@ - + $(MSBuildThisFileDirectory)..\..\src\Swashbuckle.AspNetCore.Swagger\Swashbuckle.AspNetCore.Swagger.snk $(NoWarn);8002 Exe true - net9.0;net8.0 + $(DefaultTargetFrameworks) - - - - - - - - - - - - - - - - - - - - - + + @@ -43,14 +24,9 @@ - - - - - - - + + diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs index 412162fff2..dbe50b446b 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs @@ -63,12 +63,10 @@ public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type) { typeof(Guid?), JsonSchemaTypes.String, "uuid" }, { typeof(DateOnly?), JsonSchemaTypes.String, "date" }, { typeof(TimeOnly?), JsonSchemaTypes.String, "time" }, -#if NET { typeof(Int128), JsonSchemaTypes.Integer, "int128" }, { typeof(Int128?), JsonSchemaTypes.Integer, "int128" }, { typeof(UInt128), JsonSchemaTypes.Integer, "int128" }, { typeof(UInt128?), JsonSchemaTypes.Integer, "int128" }, -#endif }; [Theory] @@ -368,7 +366,6 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(3, schema.Properties["StringWithMinMaxLength"].MaxLength); Assert.Equal(1, schema.Properties["ArrayWithMinMaxLength"].MinItems); Assert.Equal(3, schema.Properties["ArrayWithMinMaxLength"].MaxItems); -#if NET Assert.Equal(1, schema.Properties["StringWithLength"].MinLength); Assert.Equal(3, schema.Properties["StringWithLength"].MaxLength); Assert.Equal(1, schema.Properties["ArrayWithLength"].MinItems); @@ -377,7 +374,6 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMaximum); Assert.Equal("byte", schema.Properties["StringWithBase64"].Format); Assert.Equal(JsonSchemaTypes.String, schema.Properties["StringWithBase64"].Type); -#endif Assert.Null(schema.Properties["IntWithRange"].ExclusiveMinimum); Assert.Null(schema.Properties["IntWithRange"].ExclusiveMaximum); Assert.Equal(1, schema.Properties["IntWithRange"].Minimum); diff --git a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj index d2fb6a399a..2cece83730 100644 --- a/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj +++ b/test/Swashbuckle.AspNetCore.Newtonsoft.Test/Swashbuckle.AspNetCore.Newtonsoft.Test.csproj @@ -2,7 +2,7 @@ Exe - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/FakeController.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/FakeController.cs index 4544db2f22..9c87c07dd3 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/FakeController.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/FakeController.cs @@ -70,7 +70,6 @@ public void ActionWithAuthorizationFromHeaderParameter([FromHeader] string autho public void ActionWithObjectParameter(XmlAnnotatedType param) { } -#if NET public class TypeWithRequiredProperty { public required string RequiredProperty { get; set; } @@ -78,7 +77,6 @@ public class TypeWithRequiredProperty public void ActionWithRequiredMember(TypeWithRequiredProperty param) { } -#endif [Consumes("application/someMediaType")] public void ActionWithConsumesAttribute(string param) diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/JsonRequiredAnnotatedType.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/JsonRequiredAnnotatedType.cs index c58d47a10d..0e232260ac 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/JsonRequiredAnnotatedType.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Fixtures/JsonRequiredAnnotatedType.cs @@ -5,8 +5,6 @@ namespace Swashbuckle.AspNetCore.SwaggerGen.Test.Fixtures; internal class JsonRequiredAnnotatedType { -#if NET [JsonRequired] -#endif public string StringWithJsonRequired { get; set; } } diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs index 1b648fbbea..512773b38e 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing.Constraints; -using Microsoft.Extensions.Options; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen.Test.Fixtures; @@ -67,12 +66,10 @@ public void GenerateSchema_GeneratesFileSchema_BinaryStringResultType(Type type) { typeof(Guid?), JsonSchemaTypes.String, "uuid" }, { typeof(DateOnly?), JsonSchemaTypes.String, "date" }, { typeof(TimeOnly?), JsonSchemaTypes.String, "time" }, -#if NET { typeof(Int128), JsonSchemaTypes.Integer, "int128" }, { typeof(Int128?), JsonSchemaTypes.Integer, "int128" }, { typeof(UInt128), JsonSchemaTypes.Integer, "int128" }, { typeof(UInt128?), JsonSchemaTypes.Integer, "int128" }, -#endif }; [Theory] @@ -366,7 +363,6 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(3, schema.Properties["StringWithMinMaxLength"].MaxLength); Assert.Equal(1, schema.Properties["ArrayWithMinMaxLength"].MinItems); Assert.Equal(3, schema.Properties["ArrayWithMinMaxLength"].MaxItems); -#if NET Assert.Equal(1, schema.Properties["StringWithLength"].MinLength); Assert.Equal(3, schema.Properties["StringWithLength"].MaxLength); Assert.Equal(1, schema.Properties["ArrayWithLength"].MinItems); @@ -375,7 +371,6 @@ public void GenerateSchema_SetsValidationProperties_IfComplexTypeHasValidationAt Assert.Equal(true, schema.Properties["IntWithExclusiveRange"].ExclusiveMaximum); Assert.Equal("byte", schema.Properties["StringWithBase64"].Format); Assert.Equal(JsonSchemaTypes.String, schema.Properties["StringWithBase64"].Type); -#endif Assert.Null(schema.Properties["IntWithRange"].ExclusiveMinimum); Assert.Null(schema.Properties["IntWithRange"].ExclusiveMaximum); Assert.Equal(1, schema.Properties["IntWithRange"].Minimum); @@ -408,7 +403,6 @@ public void GenerateSchema_SetsReadOnlyAndWriteOnlyFlags_IfPropertyIsRestricted( Assert.True(schema.Properties["WriteOnlyProperty"].WriteOnly); } -#if NET public class TypeWithRequiredProperties { public required string RequiredString { get; set; } @@ -469,7 +463,6 @@ public void GenerateSchema_SetsRequiredAndNullable_IfPropertyHasRequiredKeywordA Assert.Contains("RequiredNonNullableString", schema.Required.ToArray()); } #nullable disable -#endif [Theory] [InlineData(typeof(TypeWithParameterizedConstructor), nameof(TypeWithParameterizedConstructor.Id), false)] @@ -1007,22 +1000,15 @@ public void GenerateSchema_SupportsOption_NonNullableReferenceTypesAsRequired_Re Assert.Equal(required, propertyIsRequired); } - [Obsolete($"{nameof(IOptions)} is not used.")] [Theory] - [InlineData(typeof(TypeWithNullableContextAnnotated), nameof(TypeWithNullableContextAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextAnnotated.NonNullableString), false)] - [InlineData(typeof(TypeWithNullableContextAnnotated), nameof(TypeWithNullableContextAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextAnnotated.NonNullableString), true)] - [InlineData(typeof(TypeWithNullableContextNotAnnotated), nameof(TypeWithNullableContextNotAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextNotAnnotated.NonNullableString), false)] - [InlineData(typeof(TypeWithNullableContextNotAnnotated), nameof(TypeWithNullableContextNotAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextNotAnnotated.NonNullableString), true)] + [InlineData(typeof(TypeWithNullableContextAnnotated), nameof(TypeWithNullableContextAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextAnnotated.NonNullableString))] + [InlineData(typeof(TypeWithNullableContextNotAnnotated), nameof(TypeWithNullableContextNotAnnotated.SubTypeWithOneNonNullableContent), nameof(TypeWithNullableContextNotAnnotated.NonNullableString))] public void GenerateSchema_SupportsOption_SuppressImplicitRequiredAttributeForNonNullableReferenceTypes( Type declaringType, string subType, - string propertyName, - bool suppress) + string propertyName) { - var subject = Subject( - configureGenerator: c => c.NonNullableReferenceTypesAsRequired = true, - configureMvcOptions: o => o.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = suppress - ); + var subject = Subject(c => c.NonNullableReferenceTypesAsRequired = true); var schemaRepository = new SchemaRepository(); subject.GenerateSchema(declaringType, schemaRepository); @@ -1235,7 +1221,6 @@ public void GenerateSchema_HonorsSerializerAttribute_JsonPropertyName() Assert.Equal(["string-with-json-property-name"], schema.Properties.Keys); } -#if NET [Fact] public void GenerateSchema_HonorsSerializerAttribute_JsonRequired() { @@ -1247,7 +1232,6 @@ public void GenerateSchema_HonorsSerializerAttribute_JsonRequired() Assert.Equal(["StringWithJsonRequired"], schema.Required); Assert.True(schema.Properties["StringWithJsonRequired"].Nullable); } -#endif [Fact] public void GenerateSchema_HonorsSerializerAttribute_JsonExtensionData() @@ -1365,19 +1349,13 @@ private static SchemaGenerator Subject( return new SchemaGenerator(generatorOptions, new JsonSerializerDataContractResolver(serializerOptions)); } - [Obsolete($"{nameof(IOptions)} is not used.")] - private static SchemaGenerator Subject( - Action configureGenerator, - Action configureMvcOptions) + private static SchemaGenerator Subject(Action configureGenerator) { var generatorOptions = new SchemaGeneratorOptions(); configureGenerator?.Invoke(generatorOptions); var serializerOptions = new JsonSerializerOptions(); - var mvcOptions = new MvcOptions(); - configureMvcOptions?.Invoke(mvcOptions); - - return new SchemaGenerator(generatorOptions, new JsonSerializerDataContractResolver(serializerOptions), Options.Create(mvcOptions)); + return new SchemaGenerator(generatorOptions, new JsonSerializerDataContractResolver(serializerOptions)); } } diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs index e6d53e8817..ccde891856 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SwaggerGenerator/SwaggerGeneratorTests.cs @@ -723,7 +723,6 @@ public void GetSwagger_SetsParameterRequired_IfActionParameterHasRequiredOrBindR Assert.Equal(expectedRequired, parameter.Required); } -#if NET [Fact] public void GetSwagger_SetsParameterRequired_IfActionParameterHasRequiredMember() { @@ -753,7 +752,6 @@ public void GetSwagger_SetsParameterRequired_IfActionParameterHasRequiredMember( var parameter = Assert.Single(operation.Parameters); Assert.True(parameter.Required); } -#endif [Theory] [InlineData(false)] @@ -1282,7 +1280,6 @@ public void GetSwagger_CanReadTagsFromMetadata() Assert.Equal(["Some", "Tags", "Here"], [.. document.Paths["/resource"].Operations[OperationType.Post].Tags?.Select(t => t.Name)]); } -#if NET [Fact] public void GetSwagger_CanReadEndpointSummaryFromMetadata() { @@ -1330,7 +1327,6 @@ public void GetSwagger_CanReadEndpointDescriptionFromMetadata() Assert.Equal("A Test Description", document.Paths["/resource"].Operations[OperationType.Post].Description); } -#endif [Fact] public void GetSwagger_SupportsOption_ConflictingActionsResolver() diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Swashbuckle.AspNetCore.SwaggerGen.Test.csproj b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Swashbuckle.AspNetCore.SwaggerGen.Test.csproj index d72fd2ebec..818f4af5a4 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Swashbuckle.AspNetCore.SwaggerGen.Test.csproj +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/Swashbuckle.AspNetCore.SwaggerGen.Test.csproj @@ -4,7 +4,7 @@ true 1701;1702;1591 Exe - net9.0;net8.0 + $(DefaultTargetFrameworks) True $(MSBuildThisFileDirectory)..\..\src\Swashbuckle.AspNetCore.Swagger\Swashbuckle.AspNetCore.Swagger.snk diff --git a/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributes.cs b/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributes.cs index ffc7d799d8..7e066b9480 100644 --- a/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributes.cs +++ b/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributes.cs @@ -14,8 +14,6 @@ public class TypeWithValidationAttributes [MinLength(1), MaxLength(3)] public string[] ArrayWithMinMaxLength { get; set; } -#if NET - [Length(1, 3)] public string StringWithLength { get; set; } @@ -28,8 +26,6 @@ public class TypeWithValidationAttributes [Base64String] public string StringWithBase64 { get; set; } -#endif - [Range(1, 10)] public int IntWithRange { get; set; } diff --git a/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributesViaMetadataType.cs b/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributesViaMetadataType.cs index 37f6057cb4..735f944f4a 100644 --- a/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributesViaMetadataType.cs +++ b/test/Swashbuckle.AspNetCore.TestSupport/Fixtures/TypeWithValidationAttributesViaMetadataType.cs @@ -13,8 +13,6 @@ public class TypeWithValidationAttributesViaMetadataType public string[] ArrayWithMinMaxLength { get; set; } -#if NET - public string StringWithLength { get; set; } public string[] ArrayWithLength { get; set; } @@ -23,8 +21,6 @@ public class TypeWithValidationAttributesViaMetadataType public double IntWithExclusiveRange { get; set; } -#endif - public int IntWithRange { get; set; } public string StringWithRegularExpression { get; set; } @@ -53,8 +49,6 @@ public class MetadataType [MinLength(1), MaxLength(3)] public string[] ArrayWithMinMaxLength { get; set; } -#if NET - [Length(1, 3)] public string StringWithLength { get; set; } @@ -67,8 +61,6 @@ public class MetadataType [Base64String] public string StringWithBase64 { get; set; } -#endif - [Range(1, 10)] public int IntWithRange { get; set; } diff --git a/test/Swashbuckle.AspNetCore.TestSupport/Swashbuckle.AspNetCore.TestSupport.csproj b/test/Swashbuckle.AspNetCore.TestSupport/Swashbuckle.AspNetCore.TestSupport.csproj index 15e97bebd4..c892add496 100644 --- a/test/Swashbuckle.AspNetCore.TestSupport/Swashbuckle.AspNetCore.TestSupport.csproj +++ b/test/Swashbuckle.AspNetCore.TestSupport/Swashbuckle.AspNetCore.TestSupport.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) false false 1.0.0 diff --git a/test/WebSites/Basic/Basic.csproj b/test/WebSites/Basic/Basic.csproj index b2ce944870..f894351d83 100644 --- a/test/WebSites/Basic/Basic.csproj +++ b/test/WebSites/Basic/Basic.csproj @@ -3,7 +3,7 @@ true $(NoWarn);1591 - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/Basic/Controllers/FilesController.cs b/test/WebSites/Basic/Controllers/FilesController.cs index 384c80daa7..b14c8245ed 100644 --- a/test/WebSites/Basic/Controllers/FilesController.cs +++ b/test/WebSites/Basic/Controllers/FilesController.cs @@ -24,11 +24,7 @@ public IActionResult PostFormWithFile([FromForm] FormWithFile formWithFile) } [HttpGet("{name}")] -#if NET [ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK, "text/plain", "application/zip")] -#else - [Produces("text/plain", "application/zip", Type = typeof(FileResult))] -#endif public FileResult GetFile(string name) { var stream = new MemoryStream(); diff --git a/test/WebSites/Basic/Controllers/Issue3013Controller.cs b/test/WebSites/Basic/Controllers/Issue3013Controller.cs index c44477248f..b827aa1291 100644 --- a/test/WebSites/Basic/Controllers/Issue3013Controller.cs +++ b/test/WebSites/Basic/Controllers/Issue3013Controller.cs @@ -1,5 +1,4 @@ -#if NET -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; namespace Basic.Controllers; @@ -23,4 +22,3 @@ public record TestResponse public record struct TestStruct(int A, int B); } -#endif diff --git a/test/WebSites/Basic/Properties/launchSettings.json b/test/WebSites/Basic/Properties/launchSettings.json index 25a7692072..7b7aee7c43 100644 --- a/test/WebSites/Basic/Properties/launchSettings.json +++ b/test/WebSites/Basic/Properties/launchSettings.json @@ -1,29 +1,29 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:53224" - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Basic": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "", - "applicationUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53224" + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Basic": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } } \ No newline at end of file diff --git a/test/WebSites/CliExample/CliExample.csproj b/test/WebSites/CliExample/CliExample.csproj index b54867c24d..db6f671266 100644 --- a/test/WebSites/CliExample/CliExample.csproj +++ b/test/WebSites/CliExample/CliExample.csproj @@ -2,7 +2,7 @@ false - net9.0;net8.0 + $(DefaultTargetFrameworks) $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration.ToLower())_$(TargetFramework)')) diff --git a/test/WebSites/CliExampleWithFactory/CliExampleWithFactory.csproj b/test/WebSites/CliExampleWithFactory/CliExampleWithFactory.csproj index ad43d3d3be..a6698906e5 100644 --- a/test/WebSites/CliExampleWithFactory/CliExampleWithFactory.csproj +++ b/test/WebSites/CliExampleWithFactory/CliExampleWithFactory.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration.ToLower())_$(TargetFramework)')) diff --git a/test/WebSites/ConfigFromFile/ConfigFromFile.csproj b/test/WebSites/ConfigFromFile/ConfigFromFile.csproj index 1af5f19ef9..5ef825d086 100644 --- a/test/WebSites/ConfigFromFile/ConfigFromFile.csproj +++ b/test/WebSites/ConfigFromFile/ConfigFromFile.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj b/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj index 858d03236e..2a898e01ec 100644 --- a/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj +++ b/test/WebSites/CustomDocumentSerializer/CustomDocumentSerializer.csproj @@ -1,7 +1,7 @@ - net9.0;net8.0 + $(DefaultTargetFrameworks) enable enable $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration)_$(TargetFramework)', 'dotnet-swagger.dll')) diff --git a/test/WebSites/CustomUIConfig/CustomUIConfig.csproj b/test/WebSites/CustomUIConfig/CustomUIConfig.csproj index d16a9d7d40..39fbb97cc4 100644 --- a/test/WebSites/CustomUIConfig/CustomUIConfig.csproj +++ b/test/WebSites/CustomUIConfig/CustomUIConfig.csproj @@ -1,12 +1,12 @@ - - - - net9.0;net8.0 - - - - - - - - + + + + $(DefaultTargetFrameworks) + + + + + + + + diff --git a/test/WebSites/CustomUIConfig/Startup.cs b/test/WebSites/CustomUIConfig/Startup.cs index f3ae87c48b..1cd43cc56c 100644 --- a/test/WebSites/CustomUIConfig/Startup.cs +++ b/test/WebSites/CustomUIConfig/Startup.cs @@ -91,14 +91,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) c.ConfigObject.AdditionalItems.Add("jsonArray", new JsonArray() { "string" }); c.ConfigObject.AdditionalItems.Add("jsonObject", new JsonObject() { ["foo"] = "bar" }); c.ConfigObject.AdditionalItems.Add("jsonDocument", JsonDocument.Parse("""{ "foo": "bar" }""")); - -#if NET c.ConfigObject.AdditionalItems.Add("dateOnlyProperty", new DateOnly(1977, 05, 25)); c.ConfigObject.AdditionalItems.Add("timeOnlyProperty", new TimeOnly(12, 34, 56)); c.ConfigObject.AdditionalItems.Add("halfProperty", Half.CreateChecked(1)); c.ConfigObject.AdditionalItems.Add("int128Property", Int128.CreateChecked(1)); c.ConfigObject.AdditionalItems.Add("unt128Property", UInt128.CreateChecked(1)); -#endif }); } } diff --git a/test/WebSites/CustomUIIndex/CustomUIIndex.csproj b/test/WebSites/CustomUIIndex/CustomUIIndex.csproj index 3f9df915cc..4bbbf9f6fc 100644 --- a/test/WebSites/CustomUIIndex/CustomUIIndex.csproj +++ b/test/WebSites/CustomUIIndex/CustomUIIndex.csproj @@ -1,20 +1,20 @@ - - - - net9.0;net8.0 - - - - - - - - - - - - - - - - + + + + $(DefaultTargetFrameworks) + + + + + + + + + + + + + + + + diff --git a/test/WebSites/GenericControllers/GenericControllers.csproj b/test/WebSites/GenericControllers/GenericControllers.csproj index 8d9690155b..f09c43f702 100644 --- a/test/WebSites/GenericControllers/GenericControllers.csproj +++ b/test/WebSites/GenericControllers/GenericControllers.csproj @@ -3,7 +3,7 @@ true $(NoWarn);1591 - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/MinimalApp/MinimalApp.csproj b/test/WebSites/MinimalApp/MinimalApp.csproj index 858d03236e..2a898e01ec 100644 --- a/test/WebSites/MinimalApp/MinimalApp.csproj +++ b/test/WebSites/MinimalApp/MinimalApp.csproj @@ -1,7 +1,7 @@ - net9.0;net8.0 + $(DefaultTargetFrameworks) enable enable $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration)_$(TargetFramework)', 'dotnet-swagger.dll')) diff --git a/test/WebSites/MinimalAppWithHostedServices/MinimalAppWithHostedServices.csproj b/test/WebSites/MinimalAppWithHostedServices/MinimalAppWithHostedServices.csproj index 3408ed67d8..bfd01ea7dd 100644 --- a/test/WebSites/MinimalAppWithHostedServices/MinimalAppWithHostedServices.csproj +++ b/test/WebSites/MinimalAppWithHostedServices/MinimalAppWithHostedServices.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) enable enable $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration)_$(TargetFramework)', 'dotnet-swagger.dll')) diff --git a/test/WebSites/MultipleVersions/MultipleVersions.csproj b/test/WebSites/MultipleVersions/MultipleVersions.csproj index 234e91d27f..035ccb519c 100644 --- a/test/WebSites/MultipleVersions/MultipleVersions.csproj +++ b/test/WebSites/MultipleVersions/MultipleVersions.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/MultipleVersions/Properties/launchSettings.json b/test/WebSites/MultipleVersions/Properties/launchSettings.json index dee1262a39..1aa39be1bb 100644 --- a/test/WebSites/MultipleVersions/Properties/launchSettings.json +++ b/test/WebSites/MultipleVersions/Properties/launchSettings.json @@ -1,30 +1,30 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:54830", - "sslPort": 0 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "MultipleVersions": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54830", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "MultipleVersions": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/test/WebSites/MvcWithNullable/MvcWithNullable.csproj b/test/WebSites/MvcWithNullable/MvcWithNullable.csproj index 5dd6bc3706..c30d63e221 100644 --- a/test/WebSites/MvcWithNullable/MvcWithNullable.csproj +++ b/test/WebSites/MvcWithNullable/MvcWithNullable.csproj @@ -5,7 +5,7 @@ $(NoWarn);CA1050 enable WebApi - net9.0;net8.0 + $(DefaultTargetFrameworks) @@ -18,7 +18,7 @@ - + diff --git a/test/WebSites/NswagClientExample/Controllers/SystemTextJsonAnimalsController.cs b/test/WebSites/NswagClientExample/Controllers/SystemTextJsonAnimalsController.cs index 79fea489cf..0c07ad83fb 100644 --- a/test/WebSites/NswagClientExample/Controllers/SystemTextJsonAnimalsController.cs +++ b/test/WebSites/NswagClientExample/Controllers/SystemTextJsonAnimalsController.cs @@ -4,7 +4,6 @@ namespace NSwagClientExample.Controllers; -#if NET [ApiController] [Route("[controller]")] public class SystemTextJsonAnimalsController : ControllerBase @@ -34,4 +33,3 @@ public class SystemTextJsonDog : SystemTextJsonAnimal { public string DogSpecificProperty { get; set; } } -#endif diff --git a/test/WebSites/NswagClientExample/NswagClientExample.csproj b/test/WebSites/NswagClientExample/NswagClientExample.csproj index 4d0328f6a6..5de3bfe65a 100644 --- a/test/WebSites/NswagClientExample/NswagClientExample.csproj +++ b/test/WebSites/NswagClientExample/NswagClientExample.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) $([System.IO.Path]::Combine('$(ArtifactsPath)', 'bin', 'Swashbuckle.AspNetCore.Cli', '$(Configuration.ToLower())_$(TargetFramework)')) <_NSwagTool>$(NSwagExe_Net80) <_NSwagTool Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">$(NSwagExe_Net90) diff --git a/test/WebSites/OAuth2Integration/OAuth2Integration.csproj b/test/WebSites/OAuth2Integration/OAuth2Integration.csproj index acfbee6473..c53691600d 100644 --- a/test/WebSites/OAuth2Integration/OAuth2Integration.csproj +++ b/test/WebSites/OAuth2Integration/OAuth2Integration.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) @@ -11,13 +11,13 @@ - - + + - - + + diff --git a/test/WebSites/ReDoc/ReDoc.csproj b/test/WebSites/ReDoc/ReDoc.csproj index b3fa4cd596..30db2a7cfc 100644 --- a/test/WebSites/ReDoc/ReDoc.csproj +++ b/test/WebSites/ReDoc/ReDoc.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj b/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj index d1b511f3d8..851f985fd6 100644 --- a/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj +++ b/test/WebSites/TestFirst.IntegrationTests/TestFirst.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/TestFirst/TestFirst.csproj b/test/WebSites/TestFirst/TestFirst.csproj index b259fbf32a..50d008be87 100644 --- a/test/WebSites/TestFirst/TestFirst.csproj +++ b/test/WebSites/TestFirst/TestFirst.csproj @@ -1,7 +1,7 @@  - net9.0;net8.0 + $(DefaultTargetFrameworks) diff --git a/test/WebSites/TopLevelSwaggerDoc/TopLevelSwaggerDoc.csproj b/test/WebSites/TopLevelSwaggerDoc/TopLevelSwaggerDoc.csproj index b64f64c4ec..b33a39eb3c 100644 --- a/test/WebSites/TopLevelSwaggerDoc/TopLevelSwaggerDoc.csproj +++ b/test/WebSites/TopLevelSwaggerDoc/TopLevelSwaggerDoc.csproj @@ -1,7 +1,7 @@ - net9.0;net8.0 + $(DefaultTargetFrameworks) enable enable diff --git a/test/WebSites/WebApi.Aot/WebApi.Aot.csproj b/test/WebSites/WebApi.Aot/WebApi.Aot.csproj index 9d7467fe77..c3cd2a01b5 100644 --- a/test/WebSites/WebApi.Aot/WebApi.Aot.csproj +++ b/test/WebSites/WebApi.Aot/WebApi.Aot.csproj @@ -5,7 +5,7 @@ true enable true - net9.0;net8.0 + $(DefaultTargetFrameworks) false diff --git a/test/WebSites/WebApi/WebApi.csproj b/test/WebSites/WebApi/WebApi.csproj index a25e4ef550..b05eb5144e 100644 --- a/test/WebSites/WebApi/WebApi.csproj +++ b/test/WebSites/WebApi/WebApi.csproj @@ -4,7 +4,7 @@ enable enable WebApi - net9.0;net8.0 + $(DefaultTargetFrameworks) true @@ -18,12 +18,8 @@ - - - - - +