diff --git a/Lykke.Common.ApiLibrary.sln b/Lykke.Common.ApiLibrary.sln
index 472042b..6ae52d7 100644
--- a/Lykke.Common.ApiLibrary.sln
+++ b/Lykke.Common.ApiLibrary.sln
@@ -1,22 +1,31 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26430.12
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lykke.Common.ApiLibrary", "src\Lykke.Common.ApiLibrary\Lykke.Common.ApiLibrary.csproj", "{1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Common.ApiLibrary", "src\Lykke.Common.ApiLibrary\Lykke.Common.ApiLibrary.csproj", "{1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWebService", "test\TestWebService\TestWebService.csproj", "{27EA72E9-6B13-4E7E-BB43-678C09103334}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DF2AA57-4EE8-4E83-A2E1-420ECCEA8999}.Release|Any CPU.Build.0 = Release|Any CPU
+ {27EA72E9-6B13-4E7E-BB43-678C09103334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {27EA72E9-6B13-4E7E-BB43-678C09103334}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {27EA72E9-6B13-4E7E-BB43-678C09103334}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {27EA72E9-6B13-4E7E-BB43-678C09103334}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {62E0D70F-9328-42B0-BB4F-FC9C4864AB10}
+ EndGlobalSection
+EndGlobal
diff --git a/src/Lykke.Common.ApiLibrary/Lykke.Common.ApiLibrary.csproj b/src/Lykke.Common.ApiLibrary/Lykke.Common.ApiLibrary.csproj
index f5376a7..56b4636 100644
--- a/src/Lykke.Common.ApiLibrary/Lykke.Common.ApiLibrary.csproj
+++ b/src/Lykke.Common.ApiLibrary/Lykke.Common.ApiLibrary.csproj
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/src/Lykke.Common.ApiLibrary/Swagger/XmsEnum/ResponseValueTypesRequiredSchemaFilter.cs b/src/Lykke.Common.ApiLibrary/Swagger/XmsEnum/ResponseValueTypesRequiredSchemaFilter.cs
index daf52a0..d232f89 100644
--- a/src/Lykke.Common.ApiLibrary/Swagger/XmsEnum/ResponseValueTypesRequiredSchemaFilter.cs
+++ b/src/Lykke.Common.ApiLibrary/Swagger/XmsEnum/ResponseValueTypesRequiredSchemaFilter.cs
@@ -1,12 +1,17 @@
using System;
using System.Linq;
using System.Reflection;
+using JetBrains.Annotations;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace Lykke.Common.ApiLibrary.Swagger.XmsEnum
{
- public class ResponseValueTypesRequiredSchemaFilter : ISchemaFilter
+ ///
+ /// Warning. It affects not only responses but also requests
+ ///
+ [UsedImplicitly]
+ internal class ResponseValueTypesRequiredSchemaFilter : ISchemaFilter
{
public void Apply(Schema schema, SchemaFilterContext context)
{
@@ -26,7 +31,7 @@ public void Apply(Schema schema, SchemaFilterContext context)
.Select(p => p.Name);
schema.Required = schema.Properties.Keys
- .Intersect(nonNulableValueTypedPropNames, StringComparer.OrdinalIgnoreCase)
+ .Union(nonNulableValueTypedPropNames, StringComparer.OrdinalIgnoreCase)
.ToList();
if (!schema.Required.Any())
diff --git a/test/TestWebService/Program.cs b/test/TestWebService/Program.cs
new file mode 100644
index 0000000..1ffe654
--- /dev/null
+++ b/test/TestWebService/Program.cs
@@ -0,0 +1,23 @@
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Hosting;
+
+namespace TestWebService
+{
+ internal static class Program
+ {
+ static Task Main(string[] args)
+ {
+ var host = new WebHostBuilder()
+ .UseKestrel()
+ .UseUrls("http://*:5000")
+ .UseContentRoot(Directory.GetCurrentDirectory())
+ .UseStartup()
+ .UseApplicationInsights()
+ .Build();
+
+ return host.RunAsync();
+ }
+ }
+}
diff --git a/test/TestWebService/Startup.cs b/test/TestWebService/Startup.cs
new file mode 100644
index 0000000..77a003f
--- /dev/null
+++ b/test/TestWebService/Startup.cs
@@ -0,0 +1,89 @@
+using System;
+using Autofac;
+using Autofac.Extensions.DependencyInjection;
+using Common.Log;
+using Lykke.Common.ApiLibrary.Middleware;
+using Lykke.Common.ApiLibrary.Swagger;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Newtonsoft.Json.Serialization;
+using Swashbuckle.AspNetCore.Swagger;
+
+namespace TestWebService
+{
+ public class Startup
+ {
+
+ public IContainer ApplicationContainer { get; private set; }
+ public IConfigurationRoot Configuration { get; }
+ public ILog Log { get; private set; }
+
+ public Startup(IHostingEnvironment env)
+ {
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(env.ContentRootPath)
+ .AddEnvironmentVariables();
+ Configuration = builder.Build();
+
+ }
+
+ public IServiceProvider ConfigureServices(IServiceCollection services)
+ {
+ services.AddMvc()
+ .AddJsonOptions(options =>
+ {
+ options.SerializerSettings.ContractResolver =
+ new DefaultContractResolver();
+ });
+
+ services.AddSwaggerGen(options =>
+ {
+ options.DefaultLykkeConfiguration("v1", "ClientAccountRecovery API");
+ // options.SwaggerDoc(
+ // $"v1",
+ // new Info
+ // {
+ // Version = "v1",
+ // Title = "App title"
+ // });
+
+ });
+ services.Configure(c =>
+ {
+ // Serialize all properties to camelCase by default
+ c.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
+ });
+
+
+ var builder = new ContainerBuilder();
+ builder.Populate(services);
+ ApplicationContainer = builder.Build();
+
+ return new AutofacServiceProvider(ApplicationContainer);
+
+ }
+
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+
+ app.UseMvc();
+ app.UseSwagger(c =>
+ {
+ c.PreSerializeFilters.Add((swagger, httpReq) => swagger.Host = httpReq.Host.Value);
+ });
+ app.UseSwaggerUI(x =>
+ {
+ x.RoutePrefix = "swagger/ui";
+ x.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
+ });
+ app.UseStaticFiles();
+ }
+ }
+}
diff --git a/test/TestWebService/TestController.cs b/test/TestWebService/TestController.cs
new file mode 100644
index 0000000..b26f4aa
--- /dev/null
+++ b/test/TestWebService/TestController.cs
@@ -0,0 +1,80 @@
+using System.ComponentModel.DataAnnotations;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Swashbuckle.AspNetCore.SwaggerGen;
+
+namespace TestWebService
+{
+ [Route("api/[controller]")]
+ [Produces("application/json")]
+ [Consumes("application/json")]
+ public class TestController : Controller
+ {
+ [HttpPost("one")]
+ [SwaggerOperation("NonNullableEnum")]
+ [ProducesResponseType(typeof(ResponseModel), 200)]
+ public IActionResult One([FromBody] RequestModel parameter)
+ {
+ if (!ModelState.IsValid)
+ {
+ return BadRequest(ModelState);
+ }
+ return Ok(new ResponseModel
+ {
+ NonNullable = parameter.NonNullable,
+ Nullable = parameter.Nullable,
+ SomeDouble = parameter.SomeDouble,
+ SomeInt = parameter.SomeInt,
+ SomeString = parameter.SomeString
+ });
+ }
+
+ }
+
+ [BindRequired]
+ public class RequestModel
+ {
+ [Required]
+ public Enum NonNullable { get; set; }
+
+ [Required]
+ public Enum? Nullable { get; set; }
+
+ [Required]
+ public string SomeString { get; set; }
+
+ [Required]
+ public int SomeInt { get; set; }
+
+ [Required]
+ public double SomeDouble { get; set; }
+
+
+ }
+
+ public class ResponseModel
+ {
+ [Required]
+ public Enum NonNullable { get; set; }
+
+ [Required]
+ public Enum? Nullable { get; set; }
+
+ [Required]
+ public string SomeString { get; set; }
+
+ [Required]
+ public int SomeInt { get; set; }
+
+ [Required]
+ public double SomeDouble { get; set; }
+
+
+ }
+ public enum Enum
+ {
+ One,
+ Two,
+ Three
+ }
+}
\ No newline at end of file
diff --git a/test/TestWebService/TestWebService.csproj b/test/TestWebService/TestWebService.csproj
new file mode 100644
index 0000000..21d4bb3
--- /dev/null
+++ b/test/TestWebService/TestWebService.csproj
@@ -0,0 +1,21 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
+ latest
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/TestWebService/TestWebService.csproj.DotSettings b/test/TestWebService/TestWebService.csproj.DotSettings
new file mode 100644
index 0000000..58ad6c8
--- /dev/null
+++ b/test/TestWebService/TestWebService.csproj.DotSettings
@@ -0,0 +1,2 @@
+
+ CSharp71
\ No newline at end of file