JsonApiDotNetCore
JsonApiDotNetCore copied to clipboard
Support NRT and MSV in `required` and `nullable`
This PR introduces improved support for required
and nullable
properties in OpenAPI schemas, by taking into account enabled/disabled nullable reference types and enabled/disabled model state validation. The mapping as outlined in the table in #1111 is now fully implemented.
Includes:
- Use the native
NullabilityInfoContext
for checking on nullability information rather than relying on Swashbuckles work-around (Supersedes #1167). - Take into account if model state validation is enabled/disabled when generating OpenAPI schemas.
- Small tweak in
OpenApiTestContext
to allow for retrieving a swagger file without having to write it to disk.
Closes #1111
Codecov Report
Merging #1185 (0dd49b0) into openapi (16a0026) will increase coverage by
0.06%
. The diff coverage is95.77%
.
@@ Coverage Diff @@
## openapi #1185 +/- ##
===========================================
+ Coverage 92.65% 92.72% +0.06%
===========================================
Files 329 329
Lines 9863 9941 +78
===========================================
+ Hits 9139 9218 +79
+ Misses 724 723 -1
Files | Coverage Δ | |
---|---|---|
...tNetCore.OpenApi.Client/Exceptions/ApiException.cs | 87.50% <ø> (ø) |
|
...piDotNetCore.OpenApi/ActionDescriptorExtensions.cs | 100.00% <100.00%> (ø) |
|
...enApi/JsonApiActionDescriptorCollectionProvider.cs | 96.00% <100.00%> (+0.05%) |
:arrow_up: |
...JsonApiMetadata/JsonApiEndpointMetadataProvider.cs | 96.00% <100.00%> (+1.00%) |
:arrow_up: |
...i/JsonApiMetadata/NonPrimaryDocumentTypeFactory.cs | 100.00% <100.00%> (ø) |
|
...OpenApi/JsonApiMetadata/RelationshipTypeFactory.cs | 100.00% <100.00%> (ø) |
|
...piDotNetCore.OpenApi/JsonApiOperationIdSelector.cs | 92.45% <ø> (ø) |
|
...iDotNetCore.OpenApi/ServiceCollectionExtensions.cs | 98.55% <100.00%> (+0.08%) |
:arrow_up: |
...enApi/SwaggerComponents/CachingSwaggerGenerator.cs | 100.00% <ø> (ø) |
|
...penApi/SwaggerComponents/EndpointOrderingFilter.cs | 100.00% <100.00%> (ø) |
|
... and 7 more |
I took the liberty to merge in #1186, I hope you don't mind. However, I was surprised that running the tests changed two swagger.g.json files on disk, without any of the tests failing. That doesn't seem right: when an OAS file changes unexpectedly, something definitely should fail.
The review items I've reacted to are processed in my latest commit. The other ones are related to something I'm still investigating and will follow
I took the liberty to merge in #1186, I hope you don't mind. However, I was surprised that running the tests changed two swagger.g.json files on disk, without any of the tests failing. That doesn't seem right: when an OAS file changes unexpectedly, something definitely should fail.
Haven't been able to reproduce this. Compared two fresh clones of this branch where in only one of them I ran the tests
@bkoelman there are tests failing due to timeouts unrelated to this PR. It seems to happens during the test cleanup phase which you recently worked on. Do you have any idea what could be causing this?
See for example https://ci.appveyor.com/project/json-api-dotnet/jsonapidotnetcore/builds/45792318/job/l2grxineggemqslq#L317