Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions MicroElements.Swashbuckle.FluentValidation.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
15 changes: 7 additions & 8 deletions samples/MinimalApi/MinimalApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.*-*" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MicroElements.Swashbuckle.FluentValidation\MicroElements.Swashbuckle.FluentValidation.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MicroElements.Swashbuckle.FluentValidation\MicroElements.Swashbuckle.FluentValidation.csproj" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions samples/MinimalApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentValidation;
using FluentValidation.AspNetCore;
using MicroElements.Swashbuckle.FluentValidation.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -12,10 +11,6 @@
// Add Swagger
services.AddSwaggerGen();

// Add FV
services.AddFluentValidationAutoValidation();
services.AddFluentValidationClientsideAdapters();

// Add FV validators
services.AddValidatorsFromAssemblyContaining<Program>();

Expand Down
11 changes: 5 additions & 6 deletions samples/SampleNSwagWebApi/SampleNSwagWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.1" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.*-*" />
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MicroElements.NSwag.FluentValidation\MicroElements.NSwag.FluentValidation.csproj" />
Expand Down
11 changes: 2 additions & 9 deletions samples/SampleNSwagWebApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using FluentValidation;
using FluentValidation.AspNetCore;
using MicroElements.NSwag.FluentValidation;
using MicroElements.NSwag.FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Builder;
Expand All @@ -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<Startup>(includeInternalTypes: true);
});

services.AddControllers();

services.AddOpenApiDocument((settings, serviceProvider) =>
{
var fluentValidationSchemaProcessor = serviceProvider.CreateScope().ServiceProvider.GetService<FluentValidationSchemaProcessor>();
Expand Down
11 changes: 6 additions & 5 deletions samples/SampleWebApi/SampleWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.*-*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.*-*" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.5" />
<PackageReference Include="NJsonSchema" Version="11.3.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="8.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="8.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions samples/SampleWebApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Linq;
using FluentValidation;
using FluentValidation.AspNetCore;
using MicroElements.Swashbuckle.FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -40,9 +39,6 @@ public void ConfigureServices(IServiceCollection services)
// Register FV validators
services.AddValidatorsFromAssemblyContaining<Startup>();

// 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)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -13,7 +14,6 @@
<Import Project="..\common.props" />

<ItemGroup>
<PackageReference Include="MicroElements.IsExternalInit" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="NJsonSchema" Version="11.3.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RootNamespace>MicroElements.OpenApi</RootNamespace>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>


<Import Project="..\common.props" />

<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="[10.0.0, 12)" Condition="'$(TargetFramework)' == 'netstandard2.0'"/>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="[12.0.0, 13)" Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'"/>
<PackageReference Include="FluentValidation" Version="12.0.0" />
<PackageReference Include="MicroElements.CodeContracts.Sources" Version="1.4.0" PrivateAssets="all" />
<PackageReference Include="MicroElements.IsExternalInit" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.*-*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -13,9 +14,7 @@
<Import Project="..\common.props" />

<ItemGroup>
<PackageReference Include="MicroElements.IsExternalInit" Version="1.1.0" PrivateAssets="all" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="8.1.*-*" Condition="'$(TargetFramework)' == 'netstandard2.0'"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.*-*" Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="8.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="8.4.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.1" Condition="'$(TargetFramework)' == 'net8.0' or '$(TargetFramework)' == 'net9.0'" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.3" />
<PackageReference Include="FluentAssertions" Version="8.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1" PrivateAssets="all" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using FluentValidation;
#if NET8_0_OR_GREATER
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
#endif

Check failure on line 4 in test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Unexpected preprocessor directive

Check failure on line 4 in test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Unexpected preprocessor directive
using MicroElements.OpenApi.FluentValidation;
using MicroElements.Swashbuckle.FluentValidation.AspNetCore;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -32,18 +30,13 @@
Action<SchemaGenerationOptions>? configureSchemaGenerationOptions = null,
Action<RegistrationOptions>? configureRegistration = null)
{
#if NET8_0_OR_GREATER
// Add FV
Services.AddFluentValidation();

// Json options by default no name policy.
Services.Configure<JsonOptions>(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);
});

Expand Down
Loading