question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nullable values are 0 by default

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kojidevcommented, May 8, 2018

@enemyofthedawn nullable means that property can be null, 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 that null so.

0reactions
lock[bot]commented, Jul 2, 2019

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found