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();