Skip to content

Commit 90212df

Browse files
ssspearlottamus
authored andcommitted
fix: update common validations (#62)
* fix: update common validations * chore: update test snapshots
1 parent 5f75f99 commit 90212df

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@emotion/styled": "^10.0.15",
5757
"@sambego/storybook-state": "^1.3.6",
5858
"@stoplight/markdown-viewer": "^3.5.5",
59-
"@stoplight/scripts": "7.0.3",
59+
"@stoplight/scripts": "7.0.4",
6060
"@stoplight/storybook-config": "^2.0.4",
6161
"@stoplight/tree-list": "^4.8.0",
6262
"@stoplight/types": "11.0.0",
@@ -79,6 +79,7 @@
7979
"jest": "^24.9.0",
8080
"jest-enzyme": "7.1.0",
8181
"mobx": "^5.13.0",
82+
"prettier": "^1.19.1",
8283
"react": "16.9.0",
8384
"react-dom": "16.9.0",
8485
"rollup-plugin-commonjs": "^10.1.0",
@@ -115,5 +116,10 @@
115116
"release": {
116117
"extends": "@stoplight/scripts/release"
117118
},
118-
"typings": "src/index.d.ts"
119+
"typings": "src/index.d.ts",
120+
"prettier": {
121+
"printWidth": 120,
122+
"trailingComma": "es5",
123+
"singleQuote": true
124+
}
119125
}

src/__fixtures__/default-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"email": {
2929
"type": "string",
3030
"format": "email",
31+
"example": "email@email.com",
32+
"deprecated": true,
3133
"minLength": 2
3234
},
3335
"plan": {
@@ -42,6 +44,8 @@
4244
"type": "string"
4345
}
4446
},
47+
"deprecated": false,
48+
"example": "hi",
4549
"required": ["foo", "bar"]
4650
},
4751
{

src/utils/__tests__/__snapshots__/renderSchema.spec.ts.snap

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ Array [
612612
"type": "string",
613613
},
614614
"email": Object {
615+
"deprecated": true,
616+
"example": "email@email.com",
615617
"format": "email",
616618
"minLength": 2,
617619
"type": "string",
@@ -650,6 +652,8 @@ Array [
650652
"plan": Object {
651653
"anyOf": Array [
652654
Object {
655+
"deprecated": false,
656+
"example": "hi",
653657
"properties": Object {
654658
"bar": Object {
655659
"type": "string",
@@ -794,6 +798,8 @@ Array [
794798
"required": false,
795799
"type": "string",
796800
"validations": Object {
801+
"deprecated": true,
802+
"example": "email@email.com",
797803
"format": "email",
798804
"minLength": 2,
799805
},
@@ -815,6 +821,8 @@ Array [
815821
],
816822
"properties": Array [
817823
Object {
824+
"deprecated": false,
825+
"example": "hi",
818826
"properties": Object {
819827
"bar": Object {
820828
"type": "string",
@@ -865,7 +873,10 @@ Array [
865873
},
866874
},
867875
"type": "object",
868-
"validations": Object {},
876+
"validations": Object {
877+
"deprecated": false,
878+
"example": "hi",
879+
},
869880
},
870881
"name": "",
871882
},
@@ -1456,6 +1467,7 @@ Array [
14561467
"required": false,
14571468
"type": "string",
14581469
"validations": Object {
1470+
"default": "ACTIVE",
14591471
"enum": Array [
14601472
"COMPLETED",
14611473
"ACTIVE",
@@ -1756,7 +1768,9 @@ Array [
17561768
],
17571769
"required": false,
17581770
"type": "boolean",
1759-
"validations": Object {},
1771+
"validations": Object {
1772+
"example": true,
1773+
},
17601774
},
17611775
"name": "",
17621776
},

src/utils/getValidations.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { flatMap as _flatMap, pick as _pick } from 'lodash-es';
55
export const COMMON_VALIDATION_TYPES = [
66
'enum', // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1
77
'format', // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-7
8+
'default',
9+
'example',
10+
'deprecated',
811
];
912

1013
const VALIDATION_TYPES = {

tslint.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"extends": [
3-
"@stoplight/scripts/tslint.json"
4-
]
2+
"extends": ["tslint-config-stoplight"]
53
}

yarn.lock

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,10 +1851,10 @@
18511851
unified "~8.3.2"
18521852
unist-util-select "~2.0"
18531853

1854-
"@stoplight/scripts@7.0.3":
1855-
version "7.0.3"
1856-
resolved "https://registry.yarnpkg.com/@stoplight/scripts/-/scripts-7.0.3.tgz#024805f3a97c349836a50821b5ddf68d142be27d"
1857-
integrity sha512-7QybaFhfWTnI9O7MOFEHwWx0FfXMPgt7I16RvRv85CGFIzQxg3lBIhCsil7JuGvOVnpN19bHvjojhBbXAVrUfg==
1854+
"@stoplight/scripts@7.0.4":
1855+
version "7.0.4"
1856+
resolved "https://registry.yarnpkg.com/@stoplight/scripts/-/scripts-7.0.4.tgz#0099f9f7ef8e2e480bc38cc646d196e15f4c33d2"
1857+
integrity sha512-D4WUumY5Y5poX1BX928xQ0hoKw4gROTrgcrodtr5lfi8OgY3iokS2nuO/abzh/Ns1ZfCmVKeLylHhT2TQdBSDA==
18581858
dependencies:
18591859
"@commitlint/cli" "7.6.1"
18601860
"@commitlint/config-conventional" "7.6.0"
@@ -11583,6 +11583,11 @@ prettier@1.14.x:
1158311583
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895"
1158411584
integrity sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==
1158511585

11586+
prettier@^1.19.1:
11587+
version "1.19.1"
11588+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
11589+
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
11590+
1158611591
pretty-error@^2.1.1:
1158711592
version "2.1.1"
1158811593
resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"

0 commit comments

Comments
 (0)