Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NRT and MSV in required and nullable #1185

Merged
merged 76 commits into from
Oct 9, 2023

Conversation

maurei
Copy link
Member

@maurei maurei commented Sep 6, 2022

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 table in Google Sheets (copy below) supersedes the original table from #1111.

Includes:

  • Use the native NullabilityInfoContext to check nullability information rather than relying on Swashbuckles work-around (supersedes Use native NullabilityInfoContext #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
Closes #1242

image

QUALITY CHECKLIST

@maurei maurei changed the base branch from master to openapi September 6, 2022 15:40
@maurei maurei changed the title Openapi required and nullable properties Support for handling of non-nullable reference types in required Sep 6, 2022
@maurei maurei force-pushed the openapi-required-and-nullable-properties branch from a75fc23 to 916c753 Compare September 6, 2022 18:52
@maurei maurei changed the title Support for handling of non-nullable reference types in required Support for handling of non-nullable reference types in required Sep 6, 2022
@maurei maurei force-pushed the openapi-required-and-nullable-properties branch from 916c753 to c55a2cb Compare September 6, 2022 19:20
@codecov
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

Merging #1185 (0dd49b0) into openapi (16a0026) will increase coverage by 0.06%.
The diff coverage is 95.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%) ⬆️
...JsonApiMetadata/JsonApiEndpointMetadataProvider.cs 96.00% <100.00%> (+1.00%) ⬆️
...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%) ⬆️
...enApi/SwaggerComponents/CachingSwaggerGenerator.cs 100.00% <ø> (ø)
...penApi/SwaggerComponents/EndpointOrderingFilter.cs 100.00% <100.00%> (ø)
... and 7 more

... and 1 file with indirect coverage changes

@maurei maurei changed the title Support for handling of non-nullable reference types in required Support NRT and MSV in required and nullable Sep 7, 2022
@maurei maurei marked this pull request as ready for review September 7, 2022 05:29
@maurei maurei requested a review from bkoelman September 7, 2022 05:35
Copy link
Member

@bkoelman bkoelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job! The implementation is straightforward and it's easy to verify the tests against what's in https://user-images.githubusercontent.com/9339132/177394179-2943249b-f5f1-4a72-adab-1c1d7ae85fc6.png. The code looks clean with good naming and structure.

The used models remind me of the Cow and Chicken series that my younger brother always watched! :)

@bkoelman

This comment was marked as resolved.

bkoelman and others added 3 commits December 15, 2022 17:37
Merge openapi branch into PR 1185: Support NRT and MSV in required and nullable
OpenApiTests/SchemaProperties test collection:
* Allow for usage of OpenApiStartup directly
* Remove unneeded adding of JsonConverter
* Replace null checks with .ShouldHaveCount() calls
* Adjust test names
Misc:
* Reverted .editorconfig changes and fixed ApiException constructor instead
* Remove Debug statement
@maurei
Copy link
Member Author

maurei commented Dec 19, 2022

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

@maurei maurei force-pushed the openapi-required-and-nullable-properties branch 2 times, most recently from d462a9d to 589ad48 Compare December 20, 2022 12:26
@maurei

This comment was marked as resolved.

…erties"

This reverts commit 66a2dc4, reversing
changes made to c3c4844.
@bkoelman bkoelman merged commit c48dea3 into openapi Oct 9, 2023
16 checks passed
@bkoelman bkoelman deleted the openapi-required-and-nullable-properties branch October 9, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support for handling of non-nullable reference types in required.
2 participants