Nullable values are 0 by default
See original GitHub issueI have nullable int https://swagger.io/docs/specification/data-models/data-types/#null
"SomeObject": {
"type": "object",
"properties": {
"something": {
"format": "int32",
"type": "integer",
"nullable": true
}
}
}
but the default value in swagger ui for this int? property is 0, but it should be null.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
What is the default value of the nullable type "int?" (including ...
The default value of a bool variable in C# is false (reference). Therefore, the HasValue property of a default Nullable<T> instance is false...
Read more >Nullable types - The complete C# tutorial
For an integer, the default/fallback value is 0 (zero), which is never to be confused with NULL - they are not at all...
Read more >Nullable value types - C# reference - Microsoft Learn
The default value of a nullable value type represents null , that is, it's an instance whose Nullable<T>.HasValue property returns false .
Read more >Keep default value as 0.0 for 0 or NULL for numeric column
This is just a matter of displaying the data as required: SQL> create table t1(c1 number(28,3)); Table created.
Read more >Db2 11 - Introduction - When to use null or default values - IBM
Allowing null values for the SALARY column; Using a non-null default value (such as, 0). By allowing null values, you can formulate the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@enemyofthedawn
nullable
means that property can benull
, it is not a default value, swagger-ui I suppose tries to guess best suited default value/example. Default value of given type seems more informative thatnull
so.Locking due to inactivity.
This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.
If you think you’re experiencing something similar to what you’ve found here: please open a new issue, follow the template, and reference this issue in your report.
Thanks!