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
Changes from 4 commits
0e0c690
babad77
b8dcad3
30f9bf9
cee9d0f
97357eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, will do! |
||
public void CreateFromJson_NullType(string json, Type expectedType, object expectedValue) | ||
{ | ||
var openApiAnyObject = OpenApiAnyFactory.CreateFromJson(json); | ||
Assert.NotNull(openApiAnyObject); | ||
Assert.Equal(expectedType, openApiAnyObject.GetType()); | ||
Assert.Equal(AnyType.Null, openApiAnyObject.AnyType); | ||
var valueProperty = expectedType.GetProperty("Value"); | ||
Assert.Equal(expectedValue, valueProperty); | ||
} | ||
|
||
[Theory] | ||
[InlineData("[1,2]", typeof(OpenApiInteger), 1, 2)] | ||
[InlineData("[4294877294,4294877295]", typeof(OpenApiLong), 4294877294L, 4294877295L)] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.