From 38abb2c04c56da452c11d942e80e520cd686a93c Mon Sep 17 00:00:00 2001 From: David Weber Date: Wed, 29 Mar 2023 23:49:55 +0200 Subject: [PATCH] feat(core): add documentUrl to JS api and cli formatters --- .../cli/src/formatters/__tests__/html.test.ts | 6 ++++++ .../html/html-template-message.html | 1 + packages/cli/src/formatters/html/index.ts | 1 + packages/cli/src/formatters/json.ts | 1 + packages/cli/src/formatters/junit.ts | 3 +++ packages/cli/src/formatters/pretty.ts | 5 +++++ packages/cli/src/formatters/stylish.ts | 1 + packages/cli/src/formatters/teamcity.ts | 3 ++- packages/cli/src/formatters/text.ts | 3 ++- packages/core/src/runner/lintNode.ts | 1 + packages/core/src/types/spectral.ts | 1 + .../__tests__/asyncApi2DocumentSchema.test.ts | 4 ++++ .../__tests__/oasDocumentSchema.test.ts | 5 +++++ .../scenarios/asyncapi2-streetlights.scenario | 14 ++++++------- .../duplicated-entry-in-enum.oas.scenario | 2 +- test-harness/scenarios/examples.oas2.scenario | 16 +++++++-------- test-harness/scenarios/examples.oas3.scenario | 20 +++++++++---------- .../formats/results-format-html.scenario | 3 +++ .../oas2-valid-media-example.oas2.scenario | 4 ++-- test-harness/scenarios/oas3-schema.scenario | 18 ++++++++--------- .../scenarios/oas3.1/webooks.scenario | 2 +- ...meter-description-parameters.oas2.scenario | 6 +++--- ...meter-description-parameters.oas3.scenario | 6 +++--- .../scenarios/typed-enum.oas3.scenario | 8 ++++---- 24 files changed, 84 insertions(+), 50 deletions(-) diff --git a/packages/cli/src/formatters/__tests__/html.test.ts b/packages/cli/src/formatters/__tests__/html.test.ts index f8bc1202d..b8adb2e62 100644 --- a/packages/cli/src/formatters/__tests__/html.test.ts +++ b/packages/cli/src/formatters/__tests__/html.test.ts @@ -18,36 +18,42 @@ describe('HTML formatter', () => { 3:10 hint Info object should contain \`contact\` object. + 3:10 warning OpenAPI object info \`description\` must be present and non-empty string. + 5:14 error Info must contain Stoplight + 17:13 information Operation \`description\` must be present and non-empty string. + 64:14 information Operation \`description\` must be present and non-empty string. + 86:13 information Operation \`description\` must be present and non-empty string. + `); }); }); diff --git a/packages/cli/src/formatters/html/html-template-message.html b/packages/cli/src/formatters/html/html-template-message.html index 73f5ba9d1..74ac39f98 100644 --- a/packages/cli/src/formatters/html/html-template-message.html +++ b/packages/cli/src/formatters/html/html-template-message.html @@ -2,4 +2,5 @@ <%= line %>:<%= character %> <%= severity %> <%- message %> + <% if(documentationUrl) { %>documentation<% } %> diff --git a/packages/cli/src/formatters/html/index.ts b/packages/cli/src/formatters/html/index.ts index f40cbeacd..41dec06a8 100644 --- a/packages/cli/src/formatters/html/index.ts +++ b/packages/cli/src/formatters/html/index.ts @@ -52,6 +52,7 @@ function renderMessages(messages: IRuleResult[], parentIndex: number): string { severity: getSeverityName(message.severity), message: message.message, code: message.code, + documentationUrl: message.documentationUrl, }); }) .join('\n'); diff --git a/packages/cli/src/formatters/json.ts b/packages/cli/src/formatters/json.ts index 4ff9fbce9..ac3a97b68 100644 --- a/packages/cli/src/formatters/json.ts +++ b/packages/cli/src/formatters/json.ts @@ -9,6 +9,7 @@ export const json: Formatter = results => { severity: result.severity, range: result.range, source: result.source, + documentationUrl: result.documentationUrl, }; }); return JSON.stringify(outputJson, null, '\t'); diff --git a/packages/cli/src/formatters/junit.ts b/packages/cli/src/formatters/junit.ts index 646341af5..60eebf2c3 100644 --- a/packages/cli/src/formatters/junit.ts +++ b/packages/cli/src/formatters/junit.ts @@ -62,6 +62,9 @@ export const junit: Formatter = (results, { failSeverity }) => { output += `line ${result.range.start.line + 1}, col ${result.range.start.character + 1}, `; output += `${prepareForCdata(result.message)} (${result.code}) `; output += `at path ${prepareForCdata(path)}`; + if (result.documentationUrl) { + output += `, ${result.documentationUrl}`; + } output += ']]>'; output += ``; output += '\n'; diff --git a/packages/cli/src/formatters/pretty.ts b/packages/cli/src/formatters/pretty.ts index 3d1a40403..a4fd63906 100644 --- a/packages/cli/src/formatters/pretty.ts +++ b/packages/cli/src/formatters/pretty.ts @@ -74,6 +74,11 @@ export const pretty: Formatter = results => { { text: chalk[color].bold(result.code), padding: PAD_TOP0_LEFT2, width: COLUMNS[2] }, { text: chalk.gray(result.message), padding: PAD_TOP0_LEFT2, width: COLUMNS[3] }, { text: chalk.cyan(printPath(result.path, PrintStyle.Dot)), padding: PAD_TOP0_LEFT2 }, + { + text: chalk.gray(result.documentationUrl ?? ''), + padding: PAD_TOP0_LEFT2, + width: result.documentationUrl ? undefined : 0.1, + }, ); ui.div(); }); diff --git a/packages/cli/src/formatters/stylish.ts b/packages/cli/src/formatters/stylish.ts index 7f0aecf34..013eb6439 100644 --- a/packages/cli/src/formatters/stylish.ts +++ b/packages/cli/src/formatters/stylish.ts @@ -72,6 +72,7 @@ export const stylish: Formatter = results => { result.code ?? '', result.message, printPath(result.path, PrintStyle.Dot), + result.documentationUrl ?? '', ]); output += `${table(pathTableData, { diff --git a/packages/cli/src/formatters/teamcity.ts b/packages/cli/src/formatters/teamcity.ts index 8b3a53e32..c69bf5df5 100644 --- a/packages/cli/src/formatters/teamcity.ts +++ b/packages/cli/src/formatters/teamcity.ts @@ -23,7 +23,8 @@ function inspectionType(result: IRuleResult & { source: string }): string { const code = escapeString(result.code); const severity = getSeverityName(result.severity); const message = escapeString(result.message); - return `##teamcity[inspectionType category='openapi' id='${code}' name='${code}' description='${severity} -- ${message}']`; + const documentationUrl = result.documentationUrl ? ` -- ${escapeString(result.documentationUrl)}` : ''; + return `##teamcity[inspectionType category='openapi' id='${code}' name='${code}' description='${severity} -- ${message}${documentationUrl}']`; } function inspection(result: IRuleResult & { source: string }): string { diff --git a/packages/cli/src/formatters/text.ts b/packages/cli/src/formatters/text.ts index 12638bf0c..54705272c 100644 --- a/packages/cli/src/formatters/text.ts +++ b/packages/cli/src/formatters/text.ts @@ -12,7 +12,8 @@ function renderResults(results: IRuleResult[]): string { const line = result.range.start.line + 1; const character = result.range.start.character + 1; const severity = getSeverityName(result.severity); - return `${result.source}:${line}:${character} ${severity} ${result.code} "${result.message}"`; + const documentationUrl = result.documentationUrl ? ` ${result.documentationUrl}` : ''; + return `${result.source}:${line}:${character} ${severity} ${result.code} "${result.message}"${documentationUrl}`; }) .join('\n'); } diff --git a/packages/core/src/runner/lintNode.ts b/packages/core/src/runner/lintNode.ts index 2dcf931c2..6070c6811 100644 --- a/packages/core/src/runner/lintNode.ts +++ b/packages/core/src/runner/lintNode.ts @@ -99,6 +99,7 @@ function processTargetResults( severity, ...(source !== null ? { source } : null), range, + documentationUrl: rule.documentationUrl ?? undefined, }); } } diff --git a/packages/core/src/types/spectral.ts b/packages/core/src/types/spectral.ts index 6b30d739e..a6ae3a1a2 100644 --- a/packages/core/src/types/spectral.ts +++ b/packages/core/src/types/spectral.ts @@ -13,6 +13,7 @@ export interface IRunOpts { export interface ISpectralDiagnostic extends IDiagnostic { path: JsonPath; code: string | number; + documentationUrl?: string; } export type IRuleResult = ISpectralDiagnostic; diff --git a/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2DocumentSchema.test.ts b/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2DocumentSchema.test.ts index d530b9930..11c9ebc9a 100644 --- a/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2DocumentSchema.test.ts +++ b/packages/rulesets/src/asyncapi/functions/__tests__/asyncApi2DocumentSchema.test.ts @@ -43,6 +43,7 @@ describe('asyncApi2DocumentSchema', () => { ).toEqual([ { code: 'asyncapi-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-schema', message: '"info" property must have required property "title"', path: ['info'], severity: DiagnosticSeverity.Error, @@ -131,6 +132,7 @@ describe('asyncApi2DocumentSchema', () => { ).toEqual([ { code: 'asyncapi-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-schema', message: '"0" property type must be string', path: ['channels', '/user/signedup', 'servers', '0'], severity: DiagnosticSeverity.Error, @@ -138,6 +140,7 @@ describe('asyncApi2DocumentSchema', () => { }, { code: 'asyncapi-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-schema', message: '"2" property type must be string', path: ['channels', '/user/signedup', 'servers', '2'], severity: DiagnosticSeverity.Error, @@ -184,6 +187,7 @@ describe('asyncApi2DocumentSchema', () => { ).toEqual([ { code: 'asyncapi-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-schema', message: '"kafka" property must have required property "url"', path: ['components', 'servers', 'kafka'], severity: DiagnosticSeverity.Error, diff --git a/packages/rulesets/src/oas/functions/__tests__/oasDocumentSchema.test.ts b/packages/rulesets/src/oas/functions/__tests__/oasDocumentSchema.test.ts index 0f9d33914..470c30977 100644 --- a/packages/rulesets/src/oas/functions/__tests__/oasDocumentSchema.test.ts +++ b/packages/rulesets/src/oas/functions/__tests__/oasDocumentSchema.test.ts @@ -39,6 +39,7 @@ describe('oasDocumentSchema', () => { ).toEqual([ { code: 'oas2-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-schema', message: 'Invalid basic authentication security definition.', path: ['securityDefinitions', 'basic'], severity: DiagnosticSeverity.Error, @@ -82,6 +83,7 @@ describe('oasDocumentSchema', () => { ).toEqual([ { code: 'oas3-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema', message: '"type" property type must be string.', path: ['paths', '/user', 'get', 'parameters', '0', 'schema', 'type'], severity: DiagnosticSeverity.Error, @@ -120,6 +122,7 @@ describe('oasDocumentSchema', () => { ).toEqual([ { code: 'oas3-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema', message: 'Invalid security scheme.', path: ['components', 'securitySchemes', 'basic'], severity: DiagnosticSeverity.Error, @@ -127,6 +130,7 @@ describe('oasDocumentSchema', () => { }, { code: 'oas3-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema', message: 'Property "foo" is not expected to be here.', path: ['components', 'securitySchemes', 'basic', 'foo'], severity: DiagnosticSeverity.Error, @@ -157,6 +161,7 @@ describe('oasDocumentSchema', () => { ).toEqual([ { code: 'oas3-schema', + documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema', message: '"200" property must have required property "description".', path: ['paths', '/user', 'get', 'responses', '200'], severity: DiagnosticSeverity.Error, diff --git a/test-harness/scenarios/asyncapi2-streetlights.scenario b/test-harness/scenarios/asyncapi2-streetlights.scenario index 1a3c075d4..b5b090d25 100644 --- a/test-harness/scenarios/asyncapi2-streetlights.scenario +++ b/test-harness/scenarios/asyncapi2-streetlights.scenario @@ -217,12 +217,12 @@ module.exports = asyncapi; {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 1:1 warning asyncapi-tags AsyncAPI object must have non-empty "tags" array. - 1:11 information asyncapi-latest-version The latest version is not used. You should update to the "2.6.0" version. asyncapi - 2:6 warning asyncapi-info-contact Info object must have "contact" object. info - 45:13 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured.publish - 57:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe - 68:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/off.subscribe - 79:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/dim.subscribe + 1:1 warning asyncapi-tags AsyncAPI object must have non-empty "tags" array. https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-tags + 1:11 information asyncapi-latest-version The latest version is not used. You should update to the "2.6.0" version. asyncapi https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-latest-version + 2:6 warning asyncapi-info-contact Info object must have "contact" object. info https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-info-contact + 45:13 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured.publish https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-operation-description + 57:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-operation-description + 68:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/turn/off.subscribe https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-operation-description + 79:15 warning asyncapi-operation-description Operation "description" must be present and non-empty string. channels.smartylighting/streetlights/1/0/action/{streetlightId}/dim.subscribe https://meta.stoplight.io/docs/spectral/docs/reference/asyncapi-rules.md#asyncapi-operation-description ✖ 7 problems (0 errors, 6 warnings, 1 info, 0 hints) diff --git a/test-harness/scenarios/duplicated-entry-in-enum.oas.scenario b/test-harness/scenarios/duplicated-entry-in-enum.oas.scenario index 4f8e2cf03..99d97916e 100644 --- a/test-harness/scenarios/duplicated-entry-in-enum.oas.scenario +++ b/test-harness/scenarios/duplicated-entry-in-enum.oas.scenario @@ -30,6 +30,6 @@ components: {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 10:16 error duplicated-entry-in-enum "enum" property must not have duplicate items (items ## 1 and 5 are identical) components.schemas.a_model.properties.id.enum + 10:16 error duplicated-entry-in-enum "enum" property must not have duplicate items (items ## 1 and 5 are identical) components.schemas.a_model.properties.id.enum https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#duplicated-entry-in-enum ✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/examples.oas2.scenario b/test-harness/scenarios/examples.oas2.scenario index 08f7bb0b5..d23e02419 100644 --- a/test-harness/scenarios/examples.oas2.scenario +++ b/test-harness/scenarios/examples.oas2.scenario @@ -264,13 +264,13 @@ module.exports = oas; {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 83:26 error oas2-valid-schema-example "completed" property type must be boolean paths./schema-example.get.responses[500].schema.example.completed - 91:26 error oas2-valid-schema-example "example" property type must be boolean paths./schema-example.get.responses[501].schema.properties.some-bool.example - 95:26 error oas2-valid-schema-example "example" property must match format "date-time" paths./schema-example.get.responses[501].schema.properties.some-date.example - 99:26 error oas2-valid-schema-example "example" property must match format "url" paths./schema-example.get.responses[501].schema.properties.some-url.example - 106:11 warning operation-tag-defined Operation tags must be defined in global tags. paths./param-examples.get.tags[0] - 120:22 error oas2-valid-schema-example "x-example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[1].x-example - 177:30 error oas2-valid-media-example "application/json" property must have required property "name" paths./response-examples.get.responses[500].examples.application/json - 194:30 error oas2-valid-media-example "application/json" property must have required property "user" paths./response-examples-via-$ref.get.responses[200].examples.application/json + 83:26 error oas2-valid-schema-example "completed" property type must be boolean paths./schema-example.get.responses[500].schema.example.completed https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-schema-example + 91:26 error oas2-valid-schema-example "example" property type must be boolean paths./schema-example.get.responses[501].schema.properties.some-bool.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-schema-example + 95:26 error oas2-valid-schema-example "example" property must match format "date-time" paths./schema-example.get.responses[501].schema.properties.some-date.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-schema-example + 99:26 error oas2-valid-schema-example "example" property must match format "url" paths./schema-example.get.responses[501].schema.properties.some-url.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-schema-example + 106:11 warning operation-tag-defined Operation tags must be defined in global tags. paths./param-examples.get.tags[0] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#operation-tag-defined + 120:22 error oas2-valid-schema-example "x-example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[1].x-example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-schema-example + 177:30 error oas2-valid-media-example "application/json" property must have required property "name" paths./response-examples.get.responses[500].examples.application/json https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-media-example + 194:30 error oas2-valid-media-example "application/json" property must have required property "user" paths./response-examples-via-$ref.get.responses[200].examples.application/json https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-media-example ✖ 8 problems (7 errors, 1 warning, 0 infos, 0 hints) diff --git a/test-harness/scenarios/examples.oas3.scenario b/test-harness/scenarios/examples.oas3.scenario index 727fad075..761b7f77f 100644 --- a/test-harness/scenarios/examples.oas3.scenario +++ b/test-harness/scenarios/examples.oas3.scenario @@ -353,15 +353,15 @@ module.exports = oas; {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 126:25 error oas3-valid-schema-example "example" property must have required property "name" paths./schema-example.get.responses[500].content.application/json.schema.example - 138:30 error oas3-valid-schema-example "example" property type must be boolean paths./schema-example.get.responses[501].content.application/json.schema.properties.some-bool.example - 142:30 error oas3-valid-schema-example "example" property must match format "date-time" paths./schema-example.get.responses[501].content.application/json.schema.properties.some-date.example - 146:30 error oas3-valid-schema-example "example" property must match format "url" paths./schema-example.get.responses[501].content.application/json.schema.properties.some-url.example - 169:20 error oas3-valid-media-example "example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[1].example - 185:22 error oas3-valid-schema-example "example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[3].schema.example - 197:22 error oas3-valid-media-example "value" property type must be string paths./param-examples.get.parameters[4].examples.the-bad.value - 199:21 error oas3-valid-media-example "value" property type must be string paths./param-examples.get.parameters[4].examples.the-ugly.value - 262:25 error oas3-valid-media-example "value" property must have required property "id" paths./response-examples.get.responses[500].content.application/json.examples.response.value - 282:25 error oas3-valid-media-example "value" property must have required property "user" paths./response-examples-via-$ref.get.responses[200].content.application/json.examples.response.value + 126:25 error oas3-valid-schema-example "example" property must have required property "name" paths./schema-example.get.responses[500].content.application/json.schema.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-schema-example + 138:30 error oas3-valid-schema-example "example" property type must be boolean paths./schema-example.get.responses[501].content.application/json.schema.properties.some-bool.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-schema-example + 142:30 error oas3-valid-schema-example "example" property must match format "date-time" paths./schema-example.get.responses[501].content.application/json.schema.properties.some-date.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-schema-example + 146:30 error oas3-valid-schema-example "example" property must match format "url" paths./schema-example.get.responses[501].content.application/json.schema.properties.some-url.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-schema-example + 169:20 error oas3-valid-media-example "example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[1].example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-media-example + 185:22 error oas3-valid-schema-example "example" property must be equal to one of the allowed values: "foo", "bar" paths./param-examples.get.parameters[3].schema.example https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-schema-example + 197:22 error oas3-valid-media-example "value" property type must be string paths./param-examples.get.parameters[4].examples.the-bad.value https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-media-example + 199:21 error oas3-valid-media-example "value" property type must be string paths./param-examples.get.parameters[4].examples.the-ugly.value https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-media-example + 262:25 error oas3-valid-media-example "value" property must have required property "id" paths./response-examples.get.responses[500].content.application/json.examples.response.value https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-media-example + 282:25 error oas3-valid-media-example "value" property must have required property "user" paths./response-examples-via-$ref.get.responses[200].content.application/json.examples.response.value https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-valid-media-example ✖ 10 problems (10 errors, 0 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/formats/results-format-html.scenario b/test-harness/scenarios/formats/results-format-html.scenario index 63ae922d7..75342e396 100644 --- a/test-harness/scenarios/formats/results-format-html.scenario +++ b/test-harness/scenarios/formats/results-format-html.scenario @@ -163,18 +163,21 @@ info: 1:1 warning "servers" must be present and non-empty array. + 2:6 warning Info object must have a "contact" object. + 2:6 warning Info "description" must be present and non-empty string. + diff --git a/test-harness/scenarios/oas2-valid-media-example.oas2.scenario b/test-harness/scenarios/oas2-valid-media-example.oas2.scenario index decabf238..190fb0cdf 100644 --- a/test-harness/scenarios/oas2-valid-media-example.oas2.scenario +++ b/test-harness/scenarios/oas2-valid-media-example.oas2.scenario @@ -41,7 +41,7 @@ module.exports = { {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 11:31 error oas2-valid-media-example "application/json" property type must be boolean paths./pets.get.responses[200].examples.application/json - 26:32 error oas2-valid-media-example "application/yaml" property must have required property "user" paths./pets.get.post.responses[200].examples.application/yaml + 11:31 error oas2-valid-media-example "application/json" property type must be boolean paths./pets.get.responses[200].examples.application/json https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-media-example + 26:32 error oas2-valid-media-example "application/yaml" property must have required property "user" paths./pets.get.post.responses[200].examples.application/yaml https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-valid-media-example ✖ 2 problems (2 errors, 0 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/oas3-schema.scenario b/test-harness/scenarios/oas3-schema.scenario index 552835f71..c4904dce1 100644 --- a/test-harness/scenarios/oas3-schema.scenario +++ b/test-harness/scenarios/oas3-schema.scenario @@ -60,14 +60,14 @@ module.exports = { {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 6:10 error oas3-schema Property "foo" is not expected to be here. info.contact.foo - 12:17 error oas3-schema Property "type" is not expected to be here. paths./user.get.parameters[0].type - 23:18 error oas3-schema "type" property type must be string. paths./user.get.parameters[1].schema.type - 24:11 error oas3-schema "2" property must have required property "schema". paths./user.get.parameters[2] - 26:17 error oas3-schema Property "type" is not expected to be here. paths./user.get.parameters[2].type - 37:28 error oas3-schema "user_id" property type must be object. paths./user.get.responses[200].content.application/json.schema.properties.user_id - 41:28 error oas3-schema "properties" property type must be object. paths./user.get.responses[200].content.application/yaml.schema.properties - 43:23 error oas3-schema "description" property type must be string. paths./user.get.responses[400].description - 46:17 error oas3-schema "responses" property must not have fewer than 1 items. paths./address.get.responses + 6:10 error oas3-schema Property "foo" is not expected to be here. info.contact.foo https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 12:17 error oas3-schema Property "type" is not expected to be here. paths./user.get.parameters[0].type https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 23:18 error oas3-schema "type" property type must be string. paths./user.get.parameters[1].schema.type https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 24:11 error oas3-schema "2" property must have required property "schema". paths./user.get.parameters[2] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 26:17 error oas3-schema Property "type" is not expected to be here. paths./user.get.parameters[2].type https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 37:28 error oas3-schema "user_id" property type must be object. paths./user.get.responses[200].content.application/json.schema.properties.user_id https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 41:28 error oas3-schema "properties" property type must be object. paths./user.get.responses[200].content.application/yaml.schema.properties https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 43:23 error oas3-schema "description" property type must be string. paths./user.get.responses[400].description https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema + 46:17 error oas3-schema "responses" property must not have fewer than 1 items. paths./address.get.responses https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema ✖ 9 problems (9 errors, 0 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/oas3.1/webooks.scenario b/test-harness/scenarios/oas3.1/webooks.scenario index 2e1880f29..0b46a3c6c 100644 --- a/test-harness/scenarios/oas3.1/webooks.scenario +++ b/test-harness/scenarios/oas3.1/webooks.scenario @@ -17,7 +17,7 @@ rules: {bin} lint {document} --ruleset {asset:ruleset.yaml} ====stdout==== {document} - 7:17 error oas3-schema "invalidNewPet" property must not have unevaluated properties. webhooks.invalidNewPet + 7:17 error oas3-schema "invalidNewPet" property must not have unevaluated properties. webhooks.invalidNewPet https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-schema ✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/parameter-description-parameters.oas2.scenario b/test-harness/scenarios/parameter-description-parameters.oas2.scenario index 97ae04087..fbb42468c 100644 --- a/test-harness/scenarios/parameter-description-parameters.oas2.scenario +++ b/test-harness/scenarios/parameter-description-parameters.oas2.scenario @@ -47,8 +47,8 @@ module.exports = { {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 5:9 warning oas2-parameter-description Parameter objects must have "description". paths./pets.parameters[0] - 14:11 warning oas2-parameter-description Parameter objects must have "description". paths./pets.get.parameters[0] - 25:13 warning oas2-parameter-description Parameter objects must have "description". parameters.skipParam + 5:9 warning oas2-parameter-description Parameter objects must have "description". paths./pets.parameters[0] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-parameter-description + 14:11 warning oas2-parameter-description Parameter objects must have "description". paths./pets.get.parameters[0] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-parameter-description + 25:13 warning oas2-parameter-description Parameter objects must have "description". parameters.skipParam https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas2-parameter-description ✖ 3 problems (0 errors, 3 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/parameter-description-parameters.oas3.scenario b/test-harness/scenarios/parameter-description-parameters.oas3.scenario index 03a6a7401..eb545ca9f 100644 --- a/test-harness/scenarios/parameter-description-parameters.oas3.scenario +++ b/test-harness/scenarios/parameter-description-parameters.oas3.scenario @@ -34,8 +34,8 @@ module.exports = { {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 5:9 warning oas3-parameter-description Parameter objects must have "description". paths./pets.parameters[0] - 9:11 warning oas3-parameter-description Parameter objects must have "description". paths./pets.get.parameters[0] - 16:15 warning oas3-parameter-description Parameter objects must have "description". components.parameters.skipParam + 5:9 warning oas3-parameter-description Parameter objects must have "description". paths./pets.parameters[0] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-parameter-description + 9:11 warning oas3-parameter-description Parameter objects must have "description". paths./pets.get.parameters[0] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-parameter-description + 16:15 warning oas3-parameter-description Parameter objects must have "description". components.parameters.skipParam https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#oas3-parameter-description ✖ 3 problems (0 errors, 3 warnings, 0 infos, 0 hints) diff --git a/test-harness/scenarios/typed-enum.oas3.scenario b/test-harness/scenarios/typed-enum.oas3.scenario index af1a1daea..da79c3398 100644 --- a/test-harness/scenarios/typed-enum.oas3.scenario +++ b/test-harness/scenarios/typed-enum.oas3.scenario @@ -30,9 +30,9 @@ components: {bin} lint {document} --ruleset "{asset:ruleset}" ====stdout==== {document} - 12:15 error typed-enum Enum value "Tap, tap, tap..." must be "integer". components.schemas.a_model.properties.id.enum[1] - 13:15 error typed-enum Enum value "Is thing thing on?" must be "integer". components.schemas.a_model.properties.id.enum[2] - 15:15 error typed-enum Enum value "You certainly wonder" must be "integer". components.schemas.a_model.properties.id.enum[4] - 16:15 error typed-enum Enum value "Why I gathered you all today..." must be "integer". components.schemas.a_model.properties.id.enum[5] + 12:15 error typed-enum Enum value "Tap, tap, tap..." must be "integer". components.schemas.a_model.properties.id.enum[1] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#typed-enum + 13:15 error typed-enum Enum value "Is thing thing on?" must be "integer". components.schemas.a_model.properties.id.enum[2] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#typed-enum + 15:15 error typed-enum Enum value "You certainly wonder" must be "integer". components.schemas.a_model.properties.id.enum[4] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#typed-enum + 16:15 error typed-enum Enum value "Why I gathered you all today..." must be "integer". components.schemas.a_model.properties.id.enum[5] https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md#typed-enum ✖ 4 problems (4 errors, 0 warnings, 0 infos, 0 hints)