diff --git a/MicroElements.Swashbuckle.FluentValidation.sln b/MicroElements.Swashbuckle.FluentValidation.sln index a627e33..aef3baf 100644 --- a/MicroElements.Swashbuckle.FluentValidation.sln +++ b/MicroElements.Swashbuckle.FluentValidation.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29324.140 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36109.1 d17.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroElements.Swashbuckle.FluentValidation", "src\MicroElements.Swashbuckle.FluentValidation\MicroElements.Swashbuckle.FluentValidation.csproj", "{433D1CD9-A091-43C1-B230-7E25954DA621}" EndProject @@ -32,8 +32,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9ED7 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalApi", "samples\MinimalApi\MinimalApi.csproj", "{6F4B88CA-B550-4C5E-981A-4608EC254976}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroElements.Swashbuckle.FluentValidation.AspNetCore", "src\MicroElements.Swashbuckle.FluentValidation.AspNetCore\MicroElements.Swashbuckle.FluentValidation.AspNetCore.csproj", "{C80E2EF6-6408-4BF3-8245-9F9DD1FD8F50}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,20 +66,16 @@ Global {6F4B88CA-B550-4C5E-981A-4608EC254976}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F4B88CA-B550-4C5E-981A-4608EC254976}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F4B88CA-B550-4C5E-981A-4608EC254976}.Release|Any CPU.Build.0 = Release|Any CPU - {C80E2EF6-6408-4BF3-8245-9F9DD1FD8F50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C80E2EF6-6408-4BF3-8245-9F9DD1FD8F50}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C80E2EF6-6408-4BF3-8245-9F9DD1FD8F50}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C80E2EF6-6408-4BF3-8245-9F9DD1FD8F50}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1AA0A677-C642-44C8-A6CE-495E7B7074B8} - EndGlobalSection GlobalSection(NestedProjects) = preSolution - {2E20C501-F63A-4CA2-9A9F-8F1BE7BC5E14} = {9ED7D819-FC90-4504-A46D-D38E3BE107B7} {FEDDFEAF-E8D0-4E7D-BCDC-AEFE3517BEAD} = {9ED7D819-FC90-4504-A46D-D38E3BE107B7} + {2E20C501-F63A-4CA2-9A9F-8F1BE7BC5E14} = {9ED7D819-FC90-4504-A46D-D38E3BE107B7} {6F4B88CA-B550-4C5E-981A-4608EC254976} = {9ED7D819-FC90-4504-A46D-D38E3BE107B7} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1AA0A677-C642-44C8-A6CE-495E7B7074B8} + EndGlobalSection EndGlobal diff --git a/samples/MinimalApi/MinimalApi.csproj b/samples/MinimalApi/MinimalApi.csproj index de332ee..48ef9c4 100644 --- a/samples/MinimalApi/MinimalApi.csproj +++ b/samples/MinimalApi/MinimalApi.csproj @@ -7,14 +7,13 @@ enable - - - - - + + + + - - - + + + diff --git a/samples/MinimalApi/Program.cs b/samples/MinimalApi/Program.cs index 749b24c..1121c23 100644 --- a/samples/MinimalApi/Program.cs +++ b/samples/MinimalApi/Program.cs @@ -1,5 +1,4 @@ using FluentValidation; -using FluentValidation.AspNetCore; using MicroElements.Swashbuckle.FluentValidation.AspNetCore; var builder = WebApplication.CreateBuilder(args); @@ -12,10 +11,6 @@ // Add Swagger services.AddSwaggerGen(); -// Add FV -services.AddFluentValidationAutoValidation(); -services.AddFluentValidationClientsideAdapters(); - // Add FV validators services.AddValidatorsFromAssemblyContaining(); diff --git a/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj b/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj index ef6d5a8..161a3b9 100644 --- a/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj +++ b/samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj @@ -6,12 +6,11 @@ latest - - - - - - + + + + + diff --git a/samples/SampleNSwagWebApi/Startup.cs b/samples/SampleNSwagWebApi/Startup.cs index 029b6b8..f0f314f 100644 --- a/samples/SampleNSwagWebApi/Startup.cs +++ b/samples/SampleNSwagWebApi/Startup.cs @@ -1,5 +1,4 @@ using FluentValidation; -using FluentValidation.AspNetCore; using MicroElements.NSwag.FluentValidation; using MicroElements.NSwag.FluentValidation.AspNetCore; using Microsoft.AspNetCore.Builder; @@ -15,14 +14,8 @@ public void ConfigureServices(IServiceCollection services) // HttpContextValidatorRegistry requires access to HttpContext services.AddHttpContextAccessor(); - services - .AddControllers() - // Adds fluent validators to Asp.net - .AddFluentValidation(c => - { - c.RegisterValidatorsFromAssemblyContaining(includeInternalTypes: true); - }); - + services.AddControllers(); + services.AddOpenApiDocument((settings, serviceProvider) => { var fluentValidationSchemaProcessor = serviceProvider.CreateScope().ServiceProvider.GetService(); diff --git a/samples/SampleWebApi/SampleWebApi.csproj b/samples/SampleWebApi/SampleWebApi.csproj index f6b0688..5b9d663 100644 --- a/samples/SampleWebApi/SampleWebApi.csproj +++ b/samples/SampleWebApi/SampleWebApi.csproj @@ -7,13 +7,14 @@ - + - - + + + - - + + diff --git a/samples/SampleWebApi/Startup.cs b/samples/SampleWebApi/Startup.cs index 7d90dec..dde9b73 100644 --- a/samples/SampleWebApi/Startup.cs +++ b/samples/SampleWebApi/Startup.cs @@ -1,6 +1,5 @@ using System.Linq; using FluentValidation; -using FluentValidation.AspNetCore; using MicroElements.Swashbuckle.FluentValidation.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.EntityFrameworkCore; @@ -40,9 +39,6 @@ public void ConfigureServices(IServiceCollection services) // Register FV validators services.AddValidatorsFromAssemblyContaining(); - // Add FV to Asp.net - services.AddFluentValidationAutoValidation(); - // Register all validators as IValidator? //var serviceDescriptors = services.Where(descriptor => descriptor.ServiceType.GetInterfaces().Contains(typeof(IValidator))).ToList(); //serviceDescriptors.ForEach(descriptor => services.Add(ServiceDescriptor.Describe(typeof(IValidator), descriptor.ImplementationType, descriptor.Lifetime))); diff --git a/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj b/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj index cad1dba..18bf7cb 100644 --- a/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj +++ b/src/MicroElements.NSwag.FluentValidation/MicroElements.NSwag.FluentValidation.csproj @@ -1,7 +1,8 @@  - netstandard2.0;net8.0;net9.0 + Library + net8.0;net9.0 enable latest true @@ -13,7 +14,6 @@ - diff --git a/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj b/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj index 1acf69b..8925e28 100644 --- a/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj +++ b/src/MicroElements.OpenApi.FluentValidation/MicroElements.OpenApi.FluentValidation.csproj @@ -1,23 +1,26 @@  - netstandard2.0;net8.0;net9.0 + Library + net8.0;net9.0 enable latest true MicroElements.OpenApi + + + + + - - + - - - - + + \ No newline at end of file diff --git a/src/MicroElements.Swashbuckle.FluentValidation.AspNetCore/MicroElements.Swashbuckle.FluentValidation.AspNetCore.csproj b/src/MicroElements.Swashbuckle.FluentValidation.AspNetCore/MicroElements.Swashbuckle.FluentValidation.AspNetCore.csproj index 80bd0dd..9eadf90 100644 --- a/src/MicroElements.Swashbuckle.FluentValidation.AspNetCore/MicroElements.Swashbuckle.FluentValidation.AspNetCore.csproj +++ b/src/MicroElements.Swashbuckle.FluentValidation.AspNetCore/MicroElements.Swashbuckle.FluentValidation.AspNetCore.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net8.0;net9.0 + net8.0;net9.0 enable enable latest diff --git a/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj b/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj index 08934ac..172d005 100644 --- a/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj +++ b/src/MicroElements.Swashbuckle.FluentValidation/MicroElements.Swashbuckle.FluentValidation.csproj @@ -1,7 +1,8 @@  - netstandard2.0;net8.0;net9.0 + Library + net8.0;net9.0 enable latest true @@ -13,9 +14,7 @@ - - - + diff --git a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj index 41d41e1..4021561 100644 --- a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj +++ b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj @@ -8,12 +8,10 @@ - - - - + + - + diff --git a/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs b/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs index 9bf3354..2c3c4fb 100644 --- a/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs +++ b/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs @@ -1,7 +1,5 @@ using System; using FluentValidation; -#if NET8_0_OR_GREATER -using FluentValidation.AspNetCore; using Microsoft.AspNetCore.Mvc; #endif using MicroElements.OpenApi.FluentValidation; @@ -32,18 +30,13 @@ public SwaggerTestHost Configure( Action? configureSchemaGenerationOptions = null, Action? configureRegistration = null) { -#if NET8_0_OR_GREATER - // Add FV - Services.AddFluentValidation(); - // Json options by default no name policy. Services.Configure(options => options.JsonSerializerOptions.PropertyNamingPolicy = null); -#endif // Add Swagger Services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo{ Title = "API", Version = "v1" }); c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); });