-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Avoid ArgumentNullException being thrown generating examples #3444
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
Conversation
…en using IncludeXmlComments related to: #3442
Move the null check nearer the call throwing to catch more cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #3442 by preventing an ArgumentNullException when generating examples. Key changes include improved test naming and coverage for different schema types and a null check in the JSON deserialization utility.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs | Updated test names and converted a test from [Fact] to [Theory] with multiple inline test cases for more robust behavior verification |
src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/OpenApiAnyFactory.cs | Added a null check for the JSON input to prevent an exception |
Comments suppressed due to low confidence (1)
test/Swashbuckle.AspNetCore.SwaggerGen.Test/XmlComments/XmlCommentsExampleHelperTests.cs:54
- [nitpick] The method name 'Create_Returns_Null_When_Type_String_And_Value_Is_Null' is misleading because the test expects an instance of OpenApiNull rather than a null value. Consider renaming it to indicate that it returns an OpenApiNull instance, for example 'Create_Builds_OpenApiNull_For_Null_Value_When_Type_String'.
public void Create_Returns_Null_When_Type_String_And_Value_Is_Null()
src/Swashbuckle.AspNetCore.SwaggerGen/XmlComments/XmlCommentsExampleHelper.cs
Outdated
Show resolved
Hide resolved
Revert change.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3444 +/- ##
=======================================
Coverage 93.54% 93.54%
=======================================
Files 110 110
Lines 3825 3827 +2
Branches 712 713 +1
=======================================
+ Hits 3578 3580 +2
Misses 247 247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Resolves #3442.