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
Nullable strings showing string null in examples #2151
Nullable strings showing string null in examples #2151
Conversation
…ing properties with null values correctly
…xample>null</example> will now resolve to a null value instead of the string "null"
@@ -26,6 +26,18 @@ public void CreateFromJson_SimpleType(string json, Type expectedType, object exp | |||
Assert.Equal(expectedValue, actualValue); | |||
} | |||
|
|||
[Theory] | |||
[InlineData("null", typeof(OpenApiNull), null)] |
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.
As there's currently only one case, and I can't really think of a need for others, I would define this test as a Fact
(no need for InlineData
plus parameters) rather than a Theory
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.
Makes sense, will do!
/// Summary for Nullable StringProperty | ||
/// </summary> | ||
/// <example>null</example> | ||
public string NullableStringProperty { get; set; } |
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.
A little nitpick (sorry) but the current name would make me think it's a nullable string in the context of nullable reference types. I think it would make more sense to name it StringPropertyWithNullExample
.
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.
I struggled with how to name this, your suggestion makes a lot more sense. Just updated the PR with this change.
@Dunnymeister a few minor comments but other than that looks great! |
@domaindrivendev Thanks very much for the quick feedback! |
when release this ? 6.1.5 |
Addresses a reversion in closed issue:
null
inside XML comments <example> tag. #1768Comments
XML Comments for String properties with tags that contain null were showing the string "null"
For the string property Subtitle:
Expected:
Actual:
This was initially fixed in PR #1866 but broke again in 6.0.1 when swagger-ui fixed a bug where it was being passed a string "null" and turning it into a "null" value. (See swagger-api/swagger-ui#6872)
Please find tests and bug fixes included.