Skip to content

Conversation

martincostello
Copy link
Collaborator

Resolves #3442.

Pawel Cioch and others added 3 commits June 3, 2025 15:11
Add tests for scenario.
Move the null check nearer the call throwing to catch more cases.
@martincostello martincostello added this to the v8.1.4 milestone Jun 4, 2025
@Copilot Copilot AI review requested due to automatic review settings June 4, 2025 08:13
Copy link

@Copilot Copilot AI left a 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()

Copy link

codecov bot commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.54%. Comparing base (29579d8) to head (5062186).
Report is 1 commits behind head on master.

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           
Flag Coverage Δ
Linux 93.54% <100.00%> (+<0.01%) ⬆️
Windows 93.54% <100.00%> (+<0.01%) ⬆️
macOS 93.54% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello merged commit 3df2947 into master Jun 4, 2025
11 checks passed
@martincostello martincostello deleted the gh-3442 branch June 4, 2025 08:20
This was referenced Jul 28, 2025
This was referenced Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: v8 IncludeXmlComments will cause errors. Also not using Newtonsoft despite being configured
1 participant