Skip to content

Commit

Permalink
feat(core): use double quotes in errors reported by Ajv (#1718)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Jul 7, 2021
1 parent 84cc112 commit dd2a166
Show file tree
Hide file tree
Showing 36 changed files with 137 additions and 137 deletions.
18 changes: 9 additions & 9 deletions packages/cli/src/services/__tests__/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Linter service', () => {
expect(results).toEqual([
{
code: 'defined-name',
message: '`name` property must be truthy',
message: '"name" property must be truthy',
path: ['0', 'name'],
range: {
end: {
Expand All @@ -74,7 +74,7 @@ describe('Linter service', () => {
},
{
code: 'defined-name',
message: '`name` property must be truthy',
message: '"name" property must be truthy',
path: ['1', 'name'],
range: {
end: {
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('Linter service', () => {
return expect(run(`lint -r references/ruleset.js references/no-nested.json`)).resolves.toEqual([
expect.objectContaining({
code: 'valid-schema',
message: '`info` property must have required property `version`',
message: '"info" property must have required property "version"',
path: ['definitions', 'info'],
range: {
end: {
Expand All @@ -322,7 +322,7 @@ describe('Linter service', () => {
}),
expect.objectContaining({
code: 'valid-schema',
message: '`description` property type must be string',
message: '"description" property type must be string',
path: ['definitions', 'info', 'description'],
range: {
end: {
Expand All @@ -338,7 +338,7 @@ describe('Linter service', () => {
}),
expect.objectContaining({
code: 'valid-schema',
message: 'Property `foo` is not expected to be here',
message: 'Property "foo" is not expected to be here',
path: ['paths'],
range: {
end: {
Expand All @@ -359,7 +359,7 @@ describe('Linter service', () => {
return expect(run(`lint -r references/ruleset.js references/nested.json`)).resolves.toEqual([
expect.objectContaining({
code: 'valid-schema',
message: '`info` property must have required property `version`',
message: '"info" property must have required property "version"',
path: [],
range: {
end: {
Expand All @@ -375,7 +375,7 @@ describe('Linter service', () => {
}),
expect.objectContaining({
code: 'valid-schema',
message: '`description` property type must be string',
message: '"description" property type must be string',
path: ['description'],
range: {
end: {
Expand All @@ -391,7 +391,7 @@ describe('Linter service', () => {
}),
expect.objectContaining({
code: 'valid-schema',
message: '`get` property must have required property `responses`',
message: '"get" property must have required property "responses"',
path: ['paths', '/test', 'get'],
range: {
end: {
Expand All @@ -407,7 +407,7 @@ describe('Linter service', () => {
}),
expect.objectContaining({
code: 'valid-schema',
message: '`response` property type must be number',
message: '"response" property type must be number',
path: ['paths', '/test', 'get', 'response'],
range: {
end: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"postbuild": "node -r esm ./scripts/inline-version.mjs"
},
"dependencies": {
"@stoplight/better-ajv-errors": "0.1.1",
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/lifecycle": "2.3.2",
"@stoplight/path": "1.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/__tests__/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ responses:: !!foo
expect(results).toEqual([
{
code: 'falsy-foo',
message: '`foo` property must be falsy',
message: '"foo" property must be falsy',
path: ['0', 'foo'],
range: expect.any(Object),
severity: DiagnosticSeverity.Warning,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/__tests__/spectral.jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Spectral', () => {
expect(results).toEqual([
{
code: 'requires-type',
message: '`empty.type` property must be truthy',
message: '"empty.type" property must be truthy',
path: ['empty'],
range: {
end: {
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Spectral', () => {
},
{
code: 'requires-type',
message: '`allOf.type` property must be truthy',
message: '"allOf.type" property must be truthy',
path: ['allOf'],
range: {
end: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/runner/utils/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MessageReplacer.addFunction('print', function (type) {
switch (type) {
case 'property':
if (property !== void 0 && property !== '') {
return `\`${property}\` property `;
return `"${property}" property `;
}

return `The document `;
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"node": ">=12"
},
"dependencies": {
"@stoplight/better-ajv-errors": "^0.1.1",
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^0.0.0",
"@stoplight/spectral-formats": "^0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/__tests__/defined.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Core Functions / Defined', () => {
it('given undefined input, should return an error message', async () => {
expect(await runDefined({}, null, { then: { field: 'foo' } })).toEqual([
{
message: '`foo` property must be defined',
message: '"foo" property must be defined',
path: [],
},
]);
Expand Down
14 changes: 7 additions & 7 deletions packages/functions/src/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Core Functions / Schema', () => {
),
).toEqual([
{
message: '`bar` property type must be string',
message: '"bar" property type must be string',
path: ['foo', 'bar'],
},
]);
Expand All @@ -189,7 +189,7 @@ describe('Core Functions / Schema', () => {
),
).toEqual([
{
message: 'Property `baz` is not expected to be here',
message: 'Property "baz" is not expected to be here',
path: ['foo'],
},
]);
Expand All @@ -206,7 +206,7 @@ describe('Core Functions / Schema', () => {
const input = 'not an email';
expect(await runSchema(input, { schema })).toEqual([
{
message: 'String must match format `email`',
message: 'String must match format "email"',
path: [],
},
]);
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('Core Functions / Schema', () => {
expect(results).toEqual([
{
path: [],
message: expect.stringMatching(new RegExp(`^(Number|String|Value) must match format \`${format}\`$`)),
message: expect.stringMatching(new RegExp(`^(Number|String|Value) must match format "${format}"$`)),
},
]);
});
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('Core Functions / Schema', () => {
it('reports pretty enum errors for a string', async () => {
expect(await runSchema('baz', { schema })).toEqual([
{
message: 'String must be equal to one of the allowed values: `foo`, `bar`. Did you mean `bar`?',
message: 'String must be equal to one of the allowed values: "foo", "bar". Did you mean "bar"?',
path: [],
},
]);
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('Core Functions / Schema', () => {

expect(await runSchema('three', { schema })).toEqual([
{
message: 'String must be equal to one of the allowed values: `foo`, `bar`',
message: 'String must be equal to one of the allowed values: "foo", "bar"',
path: [],
},
]);
Expand All @@ -362,7 +362,7 @@ describe('Core Functions / Schema', () => {
const input = { foo: true };
expect(await runSchema(input, { schema: { additionalProperties: false } })).toEqual([
{
message: 'Property `foo` is not expected to be here',
message: 'Property "foo" is not expected to be here',
path: [],
},
]);
Expand Down
2 changes: 1 addition & 1 deletion packages/rulesets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"url": "https://github.com/stoplightio/spectral.git"
},
"dependencies": {
"@stoplight/better-ajv-errors": "0.1.1",
"@stoplight/better-ajv-errors": "0.2.0",
"@stoplight/json": "3.15.0",
"@stoplight/spectral-core": "^0.0.0",
"@stoplight/spectral-formats": "^0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ testRule('asyncapi-headers-schema-type-object', [
errors: [
{
message:
'Headers schema type must be "object" (`type` property must be equal to one of the allowed values: `object`. Did you mean `object`?).',
'Headers schema type must be "object" ("type" property must be equal to one of the allowed values: "object". Did you mean "object"?).',
path: ['components', 'messages', 'aMessage', 'headers', 'type'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -66,7 +66,7 @@ testRule('asyncapi-headers-schema-type-object', [
}),
errors: [
{
message: 'Headers schema type must be "object" (`headers` property must have required property `type`).',
message: 'Headers schema type must be "object" ("headers" property must have required property "type").',
path: ['components', 'messages', 'aMessage', 'headers'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -81,7 +81,7 @@ testRule('asyncapi-headers-schema-type-object', [
errors: [
{
message:
'Headers schema type must be "object" (`type` property must be equal to one of the allowed values: `object`. Did you mean `object`?).',
'Headers schema type must be "object" ("type" property must be equal to one of the allowed values: "object". Did you mean "object"?).',
path: ['components', 'messageTraits', 'aTrait', 'headers', 'type'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -95,7 +95,7 @@ testRule('asyncapi-headers-schema-type-object', [
}),
errors: [
{
message: 'Headers schema type must be "object" (`headers` property must have required property `type`).',
message: 'Headers schema type must be "object" ("headers" property must have required property "type").',
path: ['components', 'messageTraits', 'aTrait', 'headers'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -110,7 +110,7 @@ testRule('asyncapi-headers-schema-type-object', [
}),
errors: [
{
message: 'Headers schema type must be "object" (`headers` property must have required property `type`).',
message: 'Headers schema type must be "object" ("headers" property must have required property "type").',
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'headers'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -125,7 +125,7 @@ testRule('asyncapi-headers-schema-type-object', [
errors: [
{
message:
'Headers schema type must be "object" (`type` property must be equal to one of the allowed values: `object`. Did you mean `object`?).',
'Headers schema type must be "object" ("type" property must be equal to one of the allowed values: "object". Did you mean "object"?).',
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'headers', 'type'],
severity: DiagnosticSeverity.Error,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ testRule('asyncapi-payload-default', [
}),
errors: [
{
message: '`default` property must have required property `value`',
message: '"default" property must have required property "value"',
path: ['components', 'messages', 'aMessage', 'payload', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -72,7 +72,7 @@ testRule('asyncapi-payload-default', [
}),
errors: [
{
message: '`default` property must have required property `value`',
message: '"default" property must have required property "value"',
path: ['components', 'messageTraits', 'aTrait', 'payload', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -86,7 +86,7 @@ testRule('asyncapi-payload-default', [
}),
errors: [
{
message: '`default` property must have required property `value`',
message: '"default" property must have required property "value"',
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'payload', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ testRule('asyncapi-payload-examples', [
}),
errors: [
{
message: '`1` property must have required property `value`',
message: '"1" property must have required property "value"',
path: ['components', 'messages', 'aMessage', 'payload', 'examples', '1'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -72,7 +72,7 @@ testRule('asyncapi-payload-examples', [
}),
errors: [
{
message: '`1` property must have required property `value`',
message: '"1" property must have required property "value"',
path: ['components', 'messageTraits', 'aTrait', 'payload', 'examples', '1'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -86,7 +86,7 @@ testRule('asyncapi-payload-examples', [
}),
errors: [
{
message: '`1` property must have required property `value`',
message: '"1" property must have required property "value"',
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'payload', 'examples', '1'],
severity: DiagnosticSeverity.Error,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ testRule('asyncapi-payload', [
}),
errors: [
{
message: '`deprecated` property type must be boolean',
message: '"deprecated" property type must be boolean',
path: ['components', 'messages', 'aMessage', 'payload', 'deprecated'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -71,7 +71,7 @@ testRule('asyncapi-payload', [
}),
errors: [
{
message: '`deprecated` property type must be boolean',
message: '"deprecated" property type must be boolean',
path: ['components', 'messageTraits', 'aTrait', 'payload', 'deprecated'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -85,7 +85,7 @@ testRule('asyncapi-payload', [
}),
errors: [
{
message: '`deprecated` property type must be boolean',
message: '"deprecated" property type must be boolean',
path: ['channels', 'users/{userId}/signedUp', property, 'message', 'payload', 'deprecated'],
severity: DiagnosticSeverity.Error,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testRule('asyncapi-schema-default', [
}),
errors: [
{
message: '`default` property type must be string',
message: '"default" property type must be string',
path: ['components', 'schemas', 'aSchema', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -59,7 +59,7 @@ testRule('asyncapi-schema-default', [
}),
errors: [
{
message: '`default` property type must be string',
message: '"default" property type must be string',
path: ['components', 'parameters', 'orphanParameter', 'schema', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand All @@ -73,7 +73,7 @@ testRule('asyncapi-schema-default', [
}),
errors: [
{
message: '`default` property type must be string',
message: '"default" property type must be string',
path: ['channels', 'users/{userId}/signedUp', 'parameters', 'userId', 'schema', 'default'],
severity: DiagnosticSeverity.Error,
},
Expand Down

0 comments on commit dd2a166

Please sign in to comment.