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

Annotations should not be considered as validations

Open P0lip opened this issue 3 years ago • 1 comments

Describe the bug

Since we mix validations & annotations, they undergo pretty much the same process. While avoiding true or false makes perfect sense in the case of validation keywords, it ruins the experience in the case of annotations.

To Reproduce

  1. Given a schema containing some annotation with booleanish value
{
  "type": "boolean",
  "examples": [true]
}
  1. The values are not displayed

Expected behavior

The values are displayed

Additional context

This is caused by https://github.com/stoplightio/json-schema-viewer/blob/master/src/components/shared/Validations.tsx#L112

We should filter out annotations The correct code could look so

    pickBy(validations, (v, k) => !['examples', 'default'].includes(k) && ['true', 'false'].includes(String(v))),

Screenshots image

image

P0lip avatar Sep 30 '21 10:09 P0lip

Add medium label/.

raleigh04 avatar Oct 04 '21 14:10 raleigh04