stoplightio / json-schema-viewer

A JSON Schema viewer React component
Apache License 2.0
184 stars 37 forks source link

Annotations should not be considered as validations #169

Open P0lip opened 3 years ago

P0lip commented 3 years ago

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]
    }
  2. 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

raleigh04 commented 3 years ago

Add medium label/.