Skip to content

Commit bdd54b0

Browse files
committed
fix(schema): handle non-string enum values
1 parent 28ecf19 commit bdd54b0

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"inline-version": "node ./scripts/inline-version.js",
4444
"prelint": "tsc --noEmit",
4545
"lint.fix": "yarn lint.prettier --write && yarn lint.eslint --fix",
46-
"lint.eslint":" eslint --cache --cache-location .cache/ --ext=.js,.ts src test-harness",
46+
"lint.eslint": "eslint --cache --cache-location .cache/ --ext=.js,.ts src test-harness",
4747
"lint.prettier": "prettier --ignore-path .eslintignore --check {src,test-harness}/**/*.{json,yaml} docs/**/*.md README.md",
4848
"lint": "yarn lint.prettier && yarn lint.eslint",
4949
"copy.html-templates": "copyfiles -u 1 \"./src/formatters/html/*.html\" \"./dist/\"",
@@ -62,7 +62,7 @@
6262
"test": "jest --silent"
6363
},
6464
"dependencies": {
65-
"@stoplight/better-ajv-errors": "0.0.0",
65+
"@stoplight/better-ajv-errors": "0.0.2",
6666
"@stoplight/json": "3.9.0",
6767
"@stoplight/json-ref-readers": "1.2.1",
6868
"@stoplight/json-ref-resolver": "3.1.0",

src/functions/__tests__/schema.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ describe('schema', () => {
269269
it('reports pretty enum errors for a string', () => {
270270
expect(runSchema('baz', testSchema)).toEqual([
271271
{
272-
message: `String should be equal to one of the allowed values: foo, bar. Did you mean bar?`,
272+
message: 'String should be equal to one of the allowed values: `foo`, `bar`. Did you mean `bar`?',
273273
path: [],
274274
},
275275
]);
@@ -321,7 +321,7 @@ describe('schema', () => {
321321

322322
expect(runSchema('three', testSchema)).toEqual([
323323
{
324-
message: `String should be equal to one of the allowed values: foo, bar`,
324+
message: 'String should be equal to one of the allowed values: `foo`, `bar`',
325325
path: [],
326326
},
327327
]);

src/rulesets/asyncapi/__tests__/asyncapi-headers-schema-type-object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe(`Rule '${ruleName}'`, () => {
6363
expect.objectContaining({
6464
code: ruleName,
6565
message:
66-
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: object. Did you mean object?).',
66+
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: `object`. Did you mean `object`?).',
6767
path: ['components', 'messages', 'aMessage', 'headers', 'type'],
6868
severity: rule.severity,
6969
}),
@@ -98,7 +98,7 @@ describe(`Rule '${ruleName}'`, () => {
9898
expect.objectContaining({
9999
code: ruleName,
100100
message:
101-
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: object. Did you mean object?).',
101+
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: `object`. Did you mean `object`?).',
102102
path: ['components', 'messageTraits', 'aTrait', 'headers', 'type'],
103103
severity: rule.severity,
104104
}),
@@ -155,7 +155,7 @@ describe(`Rule '${ruleName}'`, () => {
155155
expect.objectContaining({
156156
code: ruleName,
157157
message:
158-
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: object. Did you mean object?).',
158+
'Headers schema type should be `object` (`type` property should be equal to one of the allowed values: `object`. Did you mean `object`?).',
159159
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'headers', 'type'],
160160
severity: rule.severity,
161161
}),

test-harness/scenarios/examples.oas2.scenario

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ OpenAPI 2.0 (Swagger) detected
268268
95:26 error oas2-valid-schema-example `example` property should match format `date-time`
269269
99:26 error oas2-valid-schema-example `example` property should match format `url`
270270
106:11 warning operation-tag-defined Operation tags should be defined in global tags.
271-
120:22 error oas2-valid-schema-example `x-example` property should be equal to one of the allowed values: foo, bar
271+
120:22 error oas2-valid-schema-example `x-example` property should be equal to one of the allowed values: `foo`, `bar`
272272
177:30 error oas2-valid-media-example `application/json` property should have required property `name`
273273
194:30 error oas2-valid-media-example `application/json` property should have required property `user`
274274

test-harness/scenarios/examples.oas3.scenario

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ OpenAPI 3.x detected
356356
138:30 error oas3-valid-schema-example `example` property type should be boolean
357357
142:30 error oas3-valid-schema-example `example` property should match format `date-time`
358358
146:30 error oas3-valid-schema-example `example` property should match format `url`
359-
169:20 error oas3-valid-media-example `example` property should be equal to one of the allowed values: foo, bar
360-
185:22 error oas3-valid-schema-example `example` property should be equal to one of the allowed values: foo, bar
359+
169:20 error oas3-valid-media-example `example` property should be equal to one of the allowed values: `foo`, `bar`
360+
185:22 error oas3-valid-schema-example `example` property should be equal to one of the allowed values: `foo`, `bar`
361361
197:22 error oas3-valid-media-example `value` property type should be string
362362
199:21 error oas3-valid-media-example `value` property type should be string
363363
262:25 error oas3-valid-media-example `value` property should have required property `id`

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,10 @@
593593
dependencies:
594594
type-detect "4.0.8"
595595

596-
"@stoplight/[email protected].0":
597-
version "0.0.0"
598-
resolved "https://registry.yarnpkg.com/@stoplight/better-ajv-errors/-/better-ajv-errors-0.0.0.tgz#18bf69c2380a00b72e4bd5fb7247c5adf615795a"
599-
integrity sha512-jA1i4J5HmCXMmZdZigdeEHpisFCGVg5QfK++ouxP58pxshATJ5G40U9uGec2vYnuR2MQnzWHAXYf0f8jvJhBwg==
596+
"@stoplight/[email protected].2":
597+
version "0.0.2"
598+
resolved "https://registry.yarnpkg.com/@stoplight/better-ajv-errors/-/better-ajv-errors-0.0.2.tgz#f941e53c03838fa85cdb51c07a7fa9d21ff405be"
599+
integrity sha512-XB6sISR7jRUPWXBcYGltxvn/Rq8vCfmmeGhG6SBfDJOnKfz2WMPqOOEeylCDqMRh9rtpImZLZxNyatRDQZ1ivQ==
600600
dependencies:
601601
jsonpointer "^4.0.1"
602602
leven "^3.1.0"

0 commit comments

Comments
 (0)