json-schema-viewer icon indicating copy to clipboard operation
json-schema-viewer copied to clipboard

Falsy default values are not displayed

Open P0lip opened this issue 3 years ago • 1 comments

Describe the bug

Falsy default values aren't currently displayed and are entirely ignored.

To Reproduce

  1. Given any schema model with a falsy default value
{
  "type": "number",
  "default": 0
}
  1. It's not rendered

Expected behavior

They are displayed in the same as any other value.

Additional context

Caused by https://github.com/stoplightio/json-schema-viewer/blob/master/src/components/shared/Validations.tsx#L229 This correct code should look more or less as follows

     ...('default' in schemaNode.annotations ? { default: JSON.stringify(schemaNode.annotations.default) } : null),

Screenshots

image

image

P0lip avatar Sep 30 '21 09:09 P0lip

add medium label

raleigh04 avatar Oct 04 '21 14:10 raleigh04