Open jeroenwo opened 2 years ago
Very related to #68
That issue was openend in 2020 and isn't closed yet. Does that mean that all hope is lost (in my case ;)? Without FV, everything seems to be in working order..
Would it be sufficient to avoid throwing exceptions on properties? If so, that can be discussed, I think.
I think changing the property getters not to throw is a good idea regardless. Perhaps return double.NaN
.
That said, ultimately, if your model contains an object that's serialized using our GeoJSON stuff and you use Swashbuckle or a similar tool to auto-generate the spec for it by reflecting over the CLR model instead of using that same GeoJSON stuff, then you're going to get an incorrect result. Changing a few property getters to stop throwing errors won't fix that.
As a workaround, I have removed builder.Services.AddFluentValidation();
. Since I am not using FV in the web API for model validation but more downstream, I was able to inject them using builder.Services.AddValidatorsFromAssemblyContaining<MyCustomValidator>();
and retrieving it via the IServiceProvider
.
I can use NTS.IO.GeoJSON4STJ now..
@jeroenwo we also discovered this issue yesterday.. sigh. This really does need fixing. Luckily we also do not use fluent validation in our asp.net pipeline. Our fluent validation occurs in our queries/commands. How can we get the Point and other objects to not throw an exception on {get} I wonder if the nullable changes 'required' keywords for C# can be used and would help...?
As a workaround you can add the FluentValidation.AspNetCore
nuget and use the [ValidateNever]
attribute on a Geometry
property.
Good morning,
I am using NetTopologySuite.Io.GeoJSON4STJ in combination with FluentValidation, and when I try to do a POST to an endpoint with for example an
IFeature
with Polygon data, I get the following exception:I have narrowed it down to th
FluentValidation
initialization:Reproduction:
<PackageReference Include="FluentValidation.AspNetCore" Version="10.3.3" />
Program.cs
:builder.Services.AddFluentValidation();
IFeature
Here is an example of the project I use: TestGeoJsonWebApi.zip
The complete stack trace:
I know it isn't a purely NTS problem but more an integration thing, but I was wondering if you can shed some light on it..