diff --git a/package.json b/package.json index 27d2c5b4..3a82375e 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@emotion/styled": "^10.0.15", "@sambego/storybook-state": "^1.3.6", "@stoplight/markdown-viewer": "^3.5.5", - "@stoplight/scripts": "7.0.3", + "@stoplight/scripts": "7.0.4", "@stoplight/storybook-config": "^2.0.4", "@stoplight/tree-list": "^4.8.0", "@stoplight/types": "11.0.0", @@ -79,6 +79,7 @@ "jest": "^24.9.0", "jest-enzyme": "7.1.0", "mobx": "^5.13.0", + "prettier": "^1.19.1", "react": "16.9.0", "react-dom": "16.9.0", "rollup-plugin-commonjs": "^10.1.0", @@ -115,5 +116,10 @@ "release": { "extends": "@stoplight/scripts/release" }, - "typings": "src/index.d.ts" + "typings": "src/index.d.ts", + "prettier": { + "printWidth": 120, + "trailingComma": "es5", + "singleQuote": true + } } diff --git a/src/__fixtures__/default-schema.json b/src/__fixtures__/default-schema.json index 6aef0ec2..ca94e824 100644 --- a/src/__fixtures__/default-schema.json +++ b/src/__fixtures__/default-schema.json @@ -28,6 +28,8 @@ "email": { "type": "string", "format": "email", + "example": "email@email.com", + "deprecated": true, "minLength": 2 }, "plan": { @@ -42,6 +44,8 @@ "type": "string" } }, + "deprecated": false, + "example": "hi", "required": ["foo", "bar"] }, { diff --git a/src/utils/__tests__/__snapshots__/renderSchema.spec.ts.snap b/src/utils/__tests__/__snapshots__/renderSchema.spec.ts.snap index c1daa270..c7158128 100644 --- a/src/utils/__tests__/__snapshots__/renderSchema.spec.ts.snap +++ b/src/utils/__tests__/__snapshots__/renderSchema.spec.ts.snap @@ -612,6 +612,8 @@ Array [ "type": "string", }, "email": Object { + "deprecated": true, + "example": "email@email.com", "format": "email", "minLength": 2, "type": "string", @@ -650,6 +652,8 @@ Array [ "plan": Object { "anyOf": Array [ Object { + "deprecated": false, + "example": "hi", "properties": Object { "bar": Object { "type": "string", @@ -794,6 +798,8 @@ Array [ "required": false, "type": "string", "validations": Object { + "deprecated": true, + "example": "email@email.com", "format": "email", "minLength": 2, }, @@ -815,6 +821,8 @@ Array [ ], "properties": Array [ Object { + "deprecated": false, + "example": "hi", "properties": Object { "bar": Object { "type": "string", @@ -865,7 +873,10 @@ Array [ }, }, "type": "object", - "validations": Object {}, + "validations": Object { + "deprecated": false, + "example": "hi", + }, }, "name": "", }, @@ -1456,6 +1467,7 @@ Array [ "required": false, "type": "string", "validations": Object { + "default": "ACTIVE", "enum": Array [ "COMPLETED", "ACTIVE", @@ -1756,7 +1768,9 @@ Array [ ], "required": false, "type": "boolean", - "validations": Object {}, + "validations": Object { + "example": true, + }, }, "name": "", }, diff --git a/src/utils/getValidations.ts b/src/utils/getValidations.ts index ce6b28de..06e11423 100644 --- a/src/utils/getValidations.ts +++ b/src/utils/getValidations.ts @@ -5,6 +5,9 @@ import { flatMap as _flatMap, pick as _pick } from 'lodash-es'; export const COMMON_VALIDATION_TYPES = [ 'enum', // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 'format', // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-7 + 'default', + 'example', + 'deprecated', ]; const VALIDATION_TYPES = { diff --git a/tslint.json b/tslint.json index 66ced572..e0022fb2 100644 --- a/tslint.json +++ b/tslint.json @@ -1,5 +1,3 @@ { - "extends": [ - "@stoplight/scripts/tslint.json" - ] + "extends": ["tslint-config-stoplight"] } diff --git a/yarn.lock b/yarn.lock index f1ca7f7e..5a027931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1851,10 +1851,10 @@ unified "~8.3.2" unist-util-select "~2.0" -"@stoplight/scripts@7.0.3": - version "7.0.3" - resolved "https://registry.yarnpkg.com/@stoplight/scripts/-/scripts-7.0.3.tgz#024805f3a97c349836a50821b5ddf68d142be27d" - integrity sha512-7QybaFhfWTnI9O7MOFEHwWx0FfXMPgt7I16RvRv85CGFIzQxg3lBIhCsil7JuGvOVnpN19bHvjojhBbXAVrUfg== +"@stoplight/scripts@7.0.4": + version "7.0.4" + resolved "https://registry.yarnpkg.com/@stoplight/scripts/-/scripts-7.0.4.tgz#0099f9f7ef8e2e480bc38cc646d196e15f4c33d2" + integrity sha512-D4WUumY5Y5poX1BX928xQ0hoKw4gROTrgcrodtr5lfi8OgY3iokS2nuO/abzh/Ns1ZfCmVKeLylHhT2TQdBSDA== dependencies: "@commitlint/cli" "7.6.1" "@commitlint/config-conventional" "7.6.0" @@ -11583,6 +11583,11 @@ prettier@1.14.x: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895" integrity sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg== +prettier@^1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + pretty-error@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"