From 98afe461f096202e9392a8ab1a056050eb8c52cd Mon Sep 17 00:00:00 2001 From: Lukas Wiedemann Date: Wed, 17 Apr 2024 08:29:19 +0200 Subject: [PATCH] Improve naming of (Mark)NonNullableReferenceTypesAsRequired --- .../DependencyInjection/ConfigureSchemaGeneratorOptions.cs | 2 +- .../DependencyInjection/SwaggerGenOptionsExtensions.cs | 4 ++-- .../SchemaGenerator/SchemaGenerator.cs | 2 +- .../SchemaGenerator/SchemaGeneratorOptions.cs | 4 ++-- .../SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSchemaGeneratorOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSchemaGeneratorOptions.cs index d0e2881740..b518b6db4d 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSchemaGeneratorOptions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/ConfigureSchemaGeneratorOptions.cs @@ -41,7 +41,7 @@ private void DeepCopy(SchemaGeneratorOptions source, SchemaGeneratorOptions targ target.DiscriminatorValueSelector = source.DiscriminatorValueSelector; target.UseAllOfToExtendReferenceSchemas = source.UseAllOfToExtendReferenceSchemas; target.SupportNonNullableReferenceTypes = source.SupportNonNullableReferenceTypes; - target.MarkNonNullableReferenceTypesAsRequired = source.MarkNonNullableReferenceTypesAsRequired; + target.NonNullableReferenceTypesAsRequired = source.NonNullableReferenceTypesAsRequired; target.SchemaFilters = new List(source.SchemaFilters); } diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs index 1f5292abf9..fddd7a4d39 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs @@ -313,9 +313,9 @@ public static void SupportNonNullableReferenceTypes(this SwaggerGenOptions swagg /// Enable detection of non nullable reference types to set Required flag accordingly on schema properties /// /// - public static void MarkNonNullableReferenceTypesAsRequired(this SwaggerGenOptions swaggerGenOptions) + public static void NonNullableReferenceTypesAsRequired(this SwaggerGenOptions swaggerGenOptions) { - swaggerGenOptions.SchemaGeneratorOptions.MarkNonNullableReferenceTypesAsRequired = true; + swaggerGenOptions.SchemaGeneratorOptions.NonNullableReferenceTypesAsRequired = true; } /// diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs index 1cedf70614..7ac8e2a428 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs @@ -396,7 +396,7 @@ private OpenApiSchema CreateObjectSchema(DataContract dataContract, SchemaReposi : GenerateSchemaForType(dataProperty.MemberType, schemaRepository); var markNonNullableTypeAsRequired = (dataProperty.MemberInfo?.IsNonNullableReferenceType() ?? false) - && _generatorOptions.MarkNonNullableReferenceTypesAsRequired + && _generatorOptions.NonNullableReferenceTypesAsRequired #if !NETSTANDARD2_0 && !_mvcOptions.Value.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes #endif diff --git a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGeneratorOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGeneratorOptions.cs index c0e8bdc6d0..491f7b2546 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGeneratorOptions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGeneratorOptions.cs @@ -39,7 +39,7 @@ public SchemaGeneratorOptions() public bool SupportNonNullableReferenceTypes { get; set; } - public bool MarkNonNullableReferenceTypesAsRequired { get; set; } + public bool NonNullableReferenceTypesAsRequired { get; set; } public IList SchemaFilters { get; set; } @@ -69,4 +69,4 @@ private string DefaultDiscriminatorValueSelector(Type subType) return null; } } -} \ No newline at end of file +} diff --git a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs index 83ca84d581..4da8feaed8 100644 --- a/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs +++ b/test/Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs @@ -648,7 +648,7 @@ public void GenerateSchema_SupportsOption_MarkNonNullableReferenceTypesAsRequire bool required) { var subject = Subject( - configureGenerator: c => c.MarkNonNullableReferenceTypesAsRequired = true + configureGenerator: c => c.NonNullableReferenceTypesAsRequired = true ); var schemaRepository = new SchemaRepository();