chore: update typescript to v5 and synchronise predefined rulesets through strict typing (#1308)

This commit is contained in:
Andrew Tatomyr
2023-10-24 15:52:12 +03:00
committed by GitHub
parent 4e712a8c70
commit 72b225a698
85 changed files with 4615 additions and 6999 deletions

View File

@@ -21,6 +21,7 @@ rules:
'@typescript-eslint/no-empty-function': off '@typescript-eslint/no-empty-function': off
'@typescript-eslint/no-inferrable-types': off '@typescript-eslint/no-inferrable-types': off
'@typescript-eslint/ban-types': warn '@typescript-eslint/ban-types': warn
'@typescript-eslint/no-explicit-any': warn # TODO: make it error!
no-prototype-builtins: off no-prototype-builtins: off
no-useless-escape: warn no-useless-escape: warn
ignorePatterns: ignorePatterns:

View File

@@ -29,7 +29,6 @@ jobs:
env: env:
CI: true CI: true
# FIXME: fix this so the `cli` package includes the corresponding `core`
cli-package-test: cli-package-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@@ -97,7 +97,21 @@ Path parameter \`test_id\` is not used in the path \`/ping/{id}/{test}\`.
Error was generated by the path-parameters-defined rule. Error was generated by the path-parameters-defined rule.
[8] openapi.yaml:17:7 at #/paths/~1ping~1{id}~1{test}/get/responses [8] openapi.yaml:12:17 at #/paths/~1ping~1{id}~1{test}/get/parameters/0/name
Path parameter \`test_id\` is not used in the path \`/ping/{id}/{test}\`.
10 | parameters:
11 | - in: path
12 | name: test_id
| ^^^^^^^
13 | description: User id
14 | required: true
Error was generated by the path-params-defined rule.
[9] openapi.yaml:17:7 at #/paths/~1ping~1{id}~1{test}/get/responses
Operation must have at least one \`4XX\` response. Operation must have at least one \`4XX\` response.
@@ -111,7 +125,7 @@ Operation must have at least one \`4XX\` response.
Error was generated by the operation-4xx-response rule. Error was generated by the operation-4xx-response rule.
[9] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters [10] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters
The operation does not define the path parameter \`{id}\` expected by path \`/ping/{id}/{test}\`. The operation does not define the path parameter \`{id}\` expected by path \`/ping/{id}/{test}\`.
@@ -125,7 +139,7 @@ The operation does not define the path parameter \`{id}\` expected by path \`/pi
Error was generated by the path-parameters-defined rule. Error was generated by the path-parameters-defined rule.
[10] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters [11] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters
The operation does not define the path parameter \`{test}\` expected by path \`/ping/{id}/{test}\`. The operation does not define the path parameter \`{test}\` expected by path \`/ping/{id}/{test}\`.
@@ -139,7 +153,35 @@ The operation does not define the path parameter \`{test}\` expected by path \`/
Error was generated by the path-parameters-defined rule. Error was generated by the path-parameters-defined rule.
[11] openapi.yaml:8:3 at #/paths/~1ping~1{id}~1{test} [12] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters
The operation does not define the path parameter \`{id}\` expected by path \`/ping/{id}/{test}\`.
8 | '/ping/{id}/{test}':
9 | get:
10 | parameters:
| ^^^^^^^^^^
11 | - in: path
12 | name: test_id
Error was generated by the path-params-defined rule.
[13] openapi.yaml:10:7 at #/paths/~1ping~1{id}~1{test}/get/parameters
The operation does not define the path parameter \`{test}\` expected by path \`/ping/{id}/{test}\`.
8 | '/ping/{id}/{test}':
9 | get:
10 | parameters:
| ^^^^^^^^^^
11 | - in: path
12 | name: test_id
Error was generated by the path-params-defined rule.
[14] openapi.yaml:8:3 at #/paths/~1ping~1{id}~1{test}
path segment \`ping\` should be plural. path segment \`ping\` should be plural.
@@ -155,7 +197,7 @@ Error was generated by the path-segment-plural rule.
/openapi.yaml: validated in <test>ms /openapi.yaml: validated in <test>ms
❌ Validation failed with 11 errors. ❌ Validation failed with 14 errors.
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file. run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file.

8289
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -63,18 +63,19 @@
"@types/mark.js": "^8.11.5", "@types/mark.js": "^8.11.5",
"@types/marked": "^4.0.3", "@types/marked": "^4.0.3",
"@types/node": "^17.0.31", "@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "^5.33.0", "@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^5.33.0", "@typescript-eslint/parser": "^6.8.0",
"eslint": "^8.22.0", "eslint": "^8.22.0",
"jest": "^26.6.3", "jest": "^29.0.0",
"jest-environment-jsdom": "^29.7.0",
"null-loader": "^4.0.0", "null-loader": "^4.0.0",
"outdent": "^0.7.1", "outdent": "^0.7.1",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"slackify-markdown": "^4.3.1", "slackify-markdown": "^4.3.1",
"ts-jest": "^26.4.4", "ts-jest": "^29.1.1",
"ts-loader": "^8.0.2", "ts-loader": "^8.0.2",
"ts-node": "^9.0.0", "ts-node": "^9.0.0",
"typescript": "4.3.3", "typescript": "^5.2.2",
"webpack": "^5.76.0", "webpack": "^5.76.0",
"webpack-cli": "^4.10.0" "webpack-cli": "^4.10.0"
} }

View File

@@ -59,6 +59,6 @@
"@types/react-dom": "^17.0.0 || ^18.2.7", "@types/react-dom": "^17.0.0 || ^18.2.7",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.0",
"@types/yargs": "17.0.5", "@types/yargs": "17.0.5",
"typescript": "^4.0.3" "typescript": "^5.2.2"
} }
} }

View File

@@ -12,6 +12,9 @@ export default async (url: string, options = {}) => {
controller.abort(); controller.abort();
}, TIMEOUT); }, TIMEOUT);
// FIXME: fix this (possibly along with this issue: https://github.com/Redocly/redocly-cli/issues/1260)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const res = await nodeFetch(url, { signal: controller.signal, ...options }); const res = await nodeFetch(url, { signal: controller.signal, ...options });
clearTimeout(timeout); clearTimeout(timeout);
return res; return res;

View File

@@ -52,6 +52,6 @@
"@types/minimatch": "^3.0.5", "@types/minimatch": "^3.0.5",
"@types/node-fetch": "^2.5.7", "@types/node-fetch": "^2.5.7",
"@types/pluralize": "^0.0.29", "@types/pluralize": "^0.0.29",
"typescript": "^4.0.5" "typescript": "^5.2.2"
} }
} }

View File

@@ -27,11 +27,11 @@ describe('lint', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/license", "pointer": "#/info/license",
"reportOnKey": false, "reportOnKey": false,
"source": "/test/spec.yaml", "source": "/test/spec.yaml",
@@ -40,7 +40,7 @@ describe('lint', () => {
"message": "Expected type \`License\` (object) but got \`string\`", "message": "Expected type \`License\` (object) but got \`string\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -56,11 +56,11 @@ describe('lint', () => {
expect(replaceSourceWithRef(results, path.join(__dirname, 'fixtures/lint/'))) expect(replaceSourceWithRef(results, path.join(__dirname, 'fixtures/lint/')))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/license", "pointer": "#/info/license",
"reportOnKey": false, "reportOnKey": false,
"source": "openapi.yaml", "source": "openapi.yaml",
@@ -69,7 +69,7 @@ describe('lint', () => {
"message": "Expected type \`License\` (object) but got \`string\`", "message": "Expected type \`License\` (object) but got \`string\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -125,11 +125,11 @@ describe('lint', () => {
const results = await lintConfig({ document }); const results = await lintConfig({ document });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/eme", "pointer": "#/eme",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -138,17 +138,17 @@ describe('lint', () => {
"message": "Property \`eme\` is not expected here.", "message": "Property \`eme\` is not expected here.",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [ "suggest": [
"theme", "theme",
"env", "env",
"seo", "seo",
"sso", "sso",
], ],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/openapi", "pointer": "#/openapi",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -157,12 +157,12 @@ describe('lint', () => {
"message": "Property \`openapi\` is not expected here.", "message": "Property \`openapi\` is not expected here.",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/apis", "pointer": "#/apis",
"reportOnKey": false, "reportOnKey": false,
"source": "", "source": "",
@@ -171,7 +171,7 @@ describe('lint', () => {
"message": "Expected type \`ConfigApis\` (object) but got \`string\`", "message": "Expected type \`ConfigApis\` (object) but got \`string\`",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -191,11 +191,11 @@ describe('lint', () => {
const results = await lintConfig({ document }); const results = await lintConfig({ document });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/api", "pointer": "#/api",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -204,7 +204,7 @@ describe('lint', () => {
"message": "Property \`api\` is not expected here.", "message": "Property \`api\` is not expected here.",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [ "suggest": [
"apis", "apis",
"seo", "seo",
"sso", "sso",
@@ -231,11 +231,11 @@ describe('lint', () => {
const results = await lintConfig({ document }); const results = await lintConfig({ document });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/referenceDocs", "pointer": "#/referenceDocs",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -244,7 +244,7 @@ describe('lint', () => {
"message": "Property \`referenceDocs\` is not expected here.", "message": "Property \`referenceDocs\` is not expected here.",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -266,11 +266,11 @@ describe('lint', () => {
const results = await lintConfig({ document }); const results = await lintConfig({ document });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/apis/main/plugins", "pointer": "#/apis/main/plugins",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -279,7 +279,7 @@ describe('lint', () => {
"message": "Property \`plugins\` is not expected here.", "message": "Property \`plugins\` is not expected here.",
"ruleId": "configuration spec", "ruleId": "configuration spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -323,7 +323,7 @@ describe('lint', () => {
config: await makeConfig({ spec: 'error' }), config: await makeConfig({ spec: 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('detect OpenAPI should throw an error when version is not string', () => { it('detect OpenAPI should throw an error when version is not string', () => {
@@ -402,7 +402,7 @@ describe('lint', () => {
config: await makeConfig({ spec: 'error' }), config: await makeConfig({ spec: 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should ignore error because ignore file passed', async () => { it('should ignore error because ignore file passed', async () => {

View File

@@ -1,4 +1,10 @@
import { normalizeVisitors, VisitorLevelContext } from '../visitors'; import {
BaseVisitor,
NestedVisitObject,
normalizeVisitors,
RuleInstanceConfig,
VisitorLevelContext,
} from '../visitors';
import { Oas3RuleSet } from '../oas-types'; import { Oas3RuleSet } from '../oas-types';
import { Oas3Types } from '../types/oas3'; import { Oas3Types } from '../types/oas3';
import { normalizeTypes } from '../types'; import { normalizeTypes } from '../types';
@@ -25,7 +31,10 @@ describe('Normalize visitors', () => {
})) }))
); );
const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types)); const normalized = normalizeVisitors(
visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
normalizeTypes(Oas3Types)
);
expect(normalized).toBeDefined(); expect(normalized).toBeDefined();
expect(normalized.Schema.enter).toHaveLength(1); expect(normalized.Schema.enter).toHaveLength(1);
expect(normalized.Schema.enter[0].visit).toEqual(schemaEnter); expect(normalized.Schema.enter[0].visit).toEqual(schemaEnter);
@@ -69,7 +78,10 @@ describe('Normalize visitors', () => {
})) }))
); );
const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types)); const normalized = normalizeVisitors(
visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
normalizeTypes(Oas3Types)
);
expect(normalized).toBeDefined(); expect(normalized).toBeDefined();
expect(normalized.Info.enter).toHaveLength(1); expect(normalized.Info.enter).toHaveLength(1);
@@ -107,7 +119,10 @@ describe('Normalize visitors', () => {
})) }))
); );
const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types)); const normalized = normalizeVisitors(
visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
normalizeTypes(Oas3Types)
);
expect(normalized).toBeDefined(); expect(normalized).toBeDefined();
expect(normalized.PathItem.enter).toHaveLength(1); expect(normalized.PathItem.enter).toHaveLength(1);
expect(normalized.Operation.enter).toHaveLength(1); expect(normalized.Operation.enter).toHaveLength(1);
@@ -142,7 +157,10 @@ describe('Normalize visitors', () => {
})) }))
); );
const normalized = normalizeVisitors(visitors, normalizeTypes(Oas3Types)); const normalized = normalizeVisitors(
visitors as (RuleInstanceConfig & { visitor: NestedVisitObject<any, BaseVisitor> })[],
normalizeTypes(Oas3Types)
);
expect(normalized).toBeDefined(); expect(normalized).toBeDefined();
expect(normalized.Parameter.enter).toHaveLength(2); expect(normalized.Parameter.enter).toHaveLength(2);
expect(normalized.Parameter.enter[0].visit).toStrictEqual(operationParam); expect(normalized.Parameter.enter[0].visit).toStrictEqual(operationParam);

View File

@@ -9,8 +9,8 @@ describe('ref-utils', () => {
it(`should unescape refs with '/'`, () => { it(`should unescape refs with '/'`, () => {
const reference = 'somefile.yaml#/components/schemas/scope~1domain-schema'; const reference = 'somefile.yaml#/components/schemas/scope~1domain-schema';
expect(parseRef(reference)).toMatchInlineSnapshot(` expect(parseRef(reference)).toMatchInlineSnapshot(`
Object { {
"pointer": Array [ "pointer": [
"components", "components",
"schemas", "schemas",
"scope/domain-schema", "scope/domain-schema",
@@ -23,8 +23,8 @@ describe('ref-utils', () => {
it(`should unescape refs with '~'`, () => { it(`should unescape refs with '~'`, () => {
const reference = 'somefile.yaml#/components/schemas/complex~0name'; const reference = 'somefile.yaml#/components/schemas/complex~0name';
expect(parseRef(reference)).toMatchInlineSnapshot(` expect(parseRef(reference)).toMatchInlineSnapshot(`
Object { {
"pointer": Array [ "pointer": [
"components", "components",
"schemas", "schemas",
"complex~name", "complex~name",
@@ -37,8 +37,8 @@ describe('ref-utils', () => {
it(`should unescape complex urlencoded paths`, () => { it(`should unescape complex urlencoded paths`, () => {
const referene = 'somefile.yaml#/components/schemas/scope%2Fcomplex~name'; const referene = 'somefile.yaml#/components/schemas/scope%2Fcomplex~name';
expect(parseRef(referene)).toMatchInlineSnapshot(` expect(parseRef(referene)).toMatchInlineSnapshot(`
Object { {
"pointer": Array [ "pointer": [
"components", "components",
"schemas", "schemas",
"scope/complex~name", "scope/complex~name",
@@ -93,7 +93,7 @@ describe('ref-utils', () => {
config: new StyleguideConfig({}), config: new StyleguideConfig({}),
}); });
expect(result).toMatchInlineSnapshot(`Array []`); expect(result).toMatchInlineSnapshot(`[]`);
}); });
describe('refBaseName', () => { describe('refBaseName', () => {

View File

@@ -48,25 +48,25 @@ describe('Resolve http-headers', () => {
expect(fetchMock).toBeCalledTimes(3); expect(fetchMock).toBeCalledTimes(3);
expect(fetchMock.mock.calls).toMatchInlineSnapshot(` expect(fetchMock.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
"https://example.com/test.yaml", "https://example.com/test.yaml",
Object { {
"headers": Object { "headers": {
"X_TEST": "123", "X_TEST": "123",
}, },
}, },
], ],
Array [ [
"https://sample.com/test.yaml", "https://sample.com/test.yaml",
Object { {
"headers": Object {}, "headers": {},
}, },
], ],
Array [ [
"https://sample.com/test/a/test.yaml", "https://sample.com/test/a/test.yaml",
Object { {
"headers": Object { "headers": {
"X_TEST": "321", "X_TEST": "321",
}, },
}, },

View File

@@ -33,7 +33,7 @@ describe('collect refs', () => {
expect(Array.from(resolvedRefs.keys())).toMatchInlineSnapshot( expect(Array.from(resolvedRefs.keys())).toMatchInlineSnapshot(
[`foobar.yaml::#/defs/info`], [`foobar.yaml::#/defs/info`],
` `
Array [ [
"foobar.yaml::#/defs/info", "foobar.yaml::#/defs/info",
] ]
` `
@@ -198,7 +198,7 @@ describe('collect refs', () => {
.map((ref) => ref.substring(cwd.length + 1)) .map((ref) => ref.substring(cwd.length + 1))
.sort() .sort()
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
"openapi-with-back.yaml::./schemas/type-a.yaml#/", "openapi-with-back.yaml::./schemas/type-a.yaml#/",
"openapi-with-back.yaml::./schemas/type-b.yaml#/", "openapi-with-back.yaml::./schemas/type-b.yaml#/",
"schemas/type-a.yaml::../openapi-with-back.yaml#/components/schemas/TypeB", "schemas/type-a.yaml::../openapi-with-back.yaml#/components/schemas/TypeB",
@@ -214,19 +214,19 @@ describe('collect refs', () => {
return getKey(firstEl).localeCompare(getKey(secondEl)); return getKey(firstEl).localeCompare(getKey(secondEl));
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"allOf": Array [ "allOf": [
Object { {
"properties": Object { "properties": {
"integration_type": Object { "integration_type": {
"$ref": "../openapi-with-back.yaml#/components/schemas/TypeB", "$ref": "../openapi-with-back.yaml#/components/schemas/TypeB",
}, },
"name": Object { "name": {
"type": "string", "type": "string",
}, },
}, },
"required": Array [ "required": [
"name", "name",
"integration_type", "integration_type",
], ],
@@ -234,8 +234,8 @@ describe('collect refs', () => {
}, },
], ],
}, },
Object { {
"enum": Array [ "enum": [
"webhook", "webhook",
"api_key", "api_key",
"sftp", "sftp",
@@ -243,8 +243,8 @@ describe('collect refs', () => {
], ],
"type": "string", "type": "string",
}, },
Object { {
"enum": Array [ "enum": [
"webhook", "webhook",
"api_key", "api_key",
"sftp", "sftp",
@@ -270,7 +270,7 @@ describe('collect refs', () => {
expect(resolvedRefs).toBeDefined(); expect(resolvedRefs).toBeDefined();
expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1))) expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Array [ [
"openapi.yaml::#/components/schemas/Local", "openapi.yaml::#/components/schemas/Local",
"openapi.yaml::#/components/schemas/Local/properties/string", "openapi.yaml::#/components/schemas/Local/properties/string",
"openapi.yaml::./External.yaml#/properties/string", "openapi.yaml::./External.yaml#/properties/string",
@@ -281,62 +281,62 @@ describe('collect refs', () => {
`); `);
expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(` expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(`
Array [ [
Object { {
"properties": Object { "properties": {
"localCircular": Object { "localCircular": {
"$ref": "#/components/schemas/Local", "$ref": "#/components/schemas/Local",
}, },
"number": Object { "number": {
"type": "number", "type": "number",
}, },
"string": Object { "string": {
"type": "string", "type": "string",
}, },
}, },
}, },
Object { {
"type": "string", "type": "string",
}, },
Object { {
"type": "string", "type": "string",
}, },
Object { {
"properties": Object { "properties": {
"external": Object { "external": {
"$ref": "./External2.yaml", "$ref": "./External2.yaml",
}, },
"number": Object { "number": {
"type": "number", "type": "number",
}, },
"string": Object { "string": {
"type": "string", "type": "string",
}, },
"unknown": Object { "unknown": {
"type": "string", "type": "string",
}, },
}, },
"type": "object", "type": "object",
}, },
Object { {
"properties": Object { "properties": {
"circularParent": Object { "circularParent": {
"$ref": "./External.yaml#/properties", "$ref": "./External.yaml#/properties",
}, },
}, },
"type": "object", "type": "object",
}, },
Object { {
"external": Object { "external": {
"$ref": "./External2.yaml", "$ref": "./External2.yaml",
}, },
"number": Object { "number": {
"type": "number", "type": "number",
}, },
"string": Object { "string": {
"type": "string", "type": "string",
}, },
"unknown": Object { "unknown": {
"type": "string", "type": "string",
}, },
}, },
@@ -366,12 +366,12 @@ describe('collect refs', () => {
// expect(resolvedRefs.size).toEqual(2); // expect(resolvedRefs.size).toEqual(2);
expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1))) expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Array [ [
"openapi-with-md-description.yaml::./description.md", "openapi-with-md-description.yaml::./description.md",
] ]
`); `);
expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(` expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(`
Array [ [
"# Hello World "# Hello World
Lorem ipsum Lorem ipsum

View File

@@ -188,7 +188,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter param path-param", "enter param path-param",
"leave param path-param", "leave param path-param",
"enter operation: get", "enter operation: get",
@@ -268,7 +268,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter param path-param", "enter param path-param",
"leave param path-param", "leave param path-param",
"enter operation: get", "enter operation: get",
@@ -349,7 +349,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter operation: get", "enter operation: get",
"enter operation get > param shared-a", "enter operation get > param shared-a",
"enter param shared-a", "enter param shared-a",
@@ -421,7 +421,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter path pet > param path-param", "enter path pet > param path-param",
"enter path pet > param shared-a", "enter path pet > param shared-a",
"enter path pet > param get_b", "enter path pet > param get_b",
@@ -493,7 +493,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter path pet > param path-param", "enter path pet > param path-param",
"enter operation get > param shared-a", "enter operation get > param shared-a",
"enter operation get > param get_b", "enter operation get > param get_b",
@@ -560,7 +560,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter path pet > param path-param", "enter path pet > param path-param",
"leave path pet > param path-param", "leave path pet > param path-param",
"enter path pet > op get", "enter path pet > op get",
@@ -614,7 +614,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter schema shared_a", "enter schema shared_a",
"enter schema nested", "enter schema nested",
] ]
@@ -670,7 +670,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter param a > schema shared_a", "enter param a > schema shared_a",
"enter param b > schema shared_a", "enter param b > schema shared_a",
] ]
@@ -712,7 +712,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter operation get", "enter operation get",
"leave operation get", "leave operation get",
] ]
@@ -767,7 +767,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter operation get > param shared-a", "enter operation get > param shared-a",
"enter operation get > param get_b", "enter operation get > param get_b",
"enter operation get > param get_c", "enter operation get > param get_c",
@@ -853,7 +853,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter path pet > param path-param", "enter path pet > param path-param",
"leave path pet > param path-param", "leave path pet > param path-param",
"enter operation get > param shared-a", "enter operation get > param shared-a",
@@ -932,7 +932,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter nested schema inline-top > inline-top", "enter nested schema inline-top > inline-top",
"enter nested schema inline-top > inline-nested", "enter nested schema inline-top > inline-nested",
"enter nested schema inline-nested > inline-nested-nested", "enter nested schema inline-nested > inline-nested-nested",
@@ -1004,7 +1004,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter $ref #/components/parameters/shared_b with target shared-b", "enter $ref #/components/parameters/shared_b with target shared-b",
"enter $ref #/components/parameters/shared_b with target shared-b", "enter $ref #/components/parameters/shared_b with target shared-b",
"enter $ref #/components/parameters/shared_a with target shared-a", "enter $ref #/components/parameters/shared_a with target shared-a",
@@ -1048,7 +1048,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter schema a: string", "enter schema a: string",
"enter schema b: number", "enter schema b: number",
] ]
@@ -1113,7 +1113,7 @@ describe('walk order', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter Root", "enter Root",
"enter Paths", "enter Paths",
"enter PathItem", "enter PathItem",
@@ -1202,10 +1202,10 @@ describe('context.report', () => {
expect(results).toHaveLength(3); expect(results).toHaveLength(3);
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/parameters/0", "pointer": "#/paths/~1pet/get/parameters/0",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -1214,11 +1214,11 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: get_a", "message": "Parameter name shouldn't contain '_: get_a",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/parameters/1", "pointer": "#/paths/~1pet/get/parameters/1",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -1227,11 +1227,11 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: get_b", "message": "Parameter name shouldn't contain '_: get_b",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/shared_a", "pointer": "#/components/parameters/shared_a",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -1240,7 +1240,7 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: shared_a", "message": "Parameter name shouldn't contain '_: shared_a",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -1282,10 +1282,10 @@ describe('context.report', () => {
expect(results).toHaveLength(4); expect(results).toHaveLength(4);
expect(replaceSourceWithRef(results, cwd)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results, cwd)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/path-param", "pointer": "#/components/parameters/path-param",
"reportOnKey": false, "reportOnKey": false,
"source": "openapi-with-external-refs.yaml", "source": "openapi-with-external-refs.yaml",
@@ -1294,11 +1294,11 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: path_param", "message": "Parameter name shouldn't contain '_: path_param",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/param-a", "pointer": "#/components/parameters/param-a",
"reportOnKey": false, "reportOnKey": false,
"source": "openapi-with-external-refs.yaml", "source": "openapi-with-external-refs.yaml",
@@ -1307,11 +1307,11 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: param_a", "message": "Parameter name shouldn't contain '_: param_a",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "param-c.yaml", "source": "param-c.yaml",
@@ -1320,11 +1320,11 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: param_c", "message": "Parameter name shouldn't contain '_: param_c",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "param-b.yaml", "source": "param-b.yaml",
@@ -1333,7 +1333,7 @@ describe('context.report', () => {
"message": "Parameter name shouldn't contain '_: param_b", "message": "Parameter name shouldn't contain '_: param_b",
"ruleId": "test/test", "ruleId": "test/test",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -1350,7 +1350,7 @@ describe('context.resolve', () => {
expect(schema.properties.a.$ref).toBeDefined(); expect(schema.properties.a.$ref).toBeDefined();
const { location, node } = resolve(schema.properties.a); const { location, node } = resolve(schema.properties.a);
expect(node).toMatchInlineSnapshot(` expect(node).toMatchInlineSnapshot(`
Object { {
"type": "string", "type": "string",
} }
`); `);
@@ -1460,7 +1460,7 @@ describe('type extensions', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter Root", "enter Root",
"enter XWebHooks", "enter XWebHooks",
"enter hook test", "enter hook test",
@@ -1532,7 +1532,7 @@ describe('ignoreNextRules', () => {
}); });
expect(calls).toMatchInlineSnapshot(` expect(calls).toMatchInlineSnapshot(`
Array [ [
"enter and skip operation get", "enter and skip operation get",
"leave skipped operation get", "leave skipped operation get",
"enter and not skip operation put", "enter and not skip operation put",

View File

@@ -1,51 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`resolveConfig should ignore minimal from the root and read local file 1`] = ` exports[`resolveConfig should ignore minimal from the root and read local file 1`] = `
Object { {
"decorators": Object {}, "decorators": {},
"doNotResolveExamples": undefined, "doNotResolveExamples": undefined,
"oas2Decorators": Object {}, "oas2Decorators": {},
"oas2Preprocessors": Object {}, "oas2Preprocessors": {},
"oas2Rules": Object {}, "oas2Rules": {
"oas3_0Decorators": Object {}, "boolean-parameter-prefixes": "error",
"oas3_0Preprocessors": Object {}, "request-mime-type": "off",
"oas3_0Rules": Object { "response-contains-property": "off",
"no-empty-servers": "error", "response-mime-type": "off",
"no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "error",
"no-server-example.com": "warn",
"no-server-trailing-slash": "error",
"no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error",
"no-unused-components": "warn",
"spec-components-invalid-map-name": "error",
}, },
"oas3_1Decorators": Object {}, "oas3_0Decorators": {},
"oas3_1Preprocessors": Object {}, "oas3_0Preprocessors": {},
"oas3_1Rules": Object { "oas3_0Rules": {
"no-empty-servers": "error",
"no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "error",
"no-server-example.com": "warn",
"no-server-trailing-slash": "error",
"no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error",
"no-unused-components": "warn",
"spec-components-invalid-map-name": "error",
},
"preprocessors": Object {},
"recommendedFallback": false,
"rules": Object {
"boolean-parameter-prefixes": "error", "boolean-parameter-prefixes": "error",
"component-name-unique": "off", "component-name-unique": "off",
"no-empty-servers": "error",
"no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "error",
"no-server-example.com": "warn",
"no-server-trailing-slash": "error",
"no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error",
"no-unused-components": "warn",
"operation-4xx-problem-details-rfc7807": "off",
"request-mime-type": "off",
"response-contains-property": "off",
"response-mime-type": "off",
"spec-components-invalid-map-name": "error",
},
"oas3_1Decorators": {},
"oas3_1Preprocessors": {},
"oas3_1Rules": {
"boolean-parameter-prefixes": "error",
"component-name-unique": "off",
"no-empty-servers": "error",
"no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "error",
"no-server-example.com": "warn",
"no-server-trailing-slash": "error",
"no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error",
"no-unused-components": "warn",
"operation-4xx-problem-details-rfc7807": "off",
"request-mime-type": "off",
"response-contains-property": "off",
"response-mime-type": "off",
"spec-components-invalid-map-name": "error",
},
"preprocessors": {},
"recommendedFallback": false,
"rules": {
"boolean-parameter-prefixes": "error",
"info-contact": "off", "info-contact": "off",
"info-license": "warn", "info-license": "warn",
"info-license-url": "warn", "info-license-url": "warn",
"local/operation-id-not-test": "error", "local/operation-id-not-test": "error",
"no-ambiguous-paths": "warn", "no-ambiguous-paths": "warn",
"no-enum-type-mismatch": "error", "no-enum-type-mismatch": "error",
"no-http-verbs-in-paths": "off",
"no-identical-paths": "error", "no-identical-paths": "error",
"no-invalid-media-type-examples": "error", "no-invalid-media-type-examples": "error",
"no-invalid-parameter-examples": "off",
"no-invalid-schema-examples": "off",
"no-path-trailing-slash": "error", "no-path-trailing-slash": "error",
"no-unresolved-refs": "error", "no-unresolved-refs": "error",
"operation-2xx-response": "warn", "operation-2xx-response": "warn",
@@ -60,10 +79,16 @@ Object {
"operation-tag-defined": "off", "operation-tag-defined": "off",
"parameter-description": "off", "parameter-description": "off",
"path-declaration-must-exist": "error", "path-declaration-must-exist": "error",
"path-excludes-patterns": "off",
"path-http-verbs-order": "error", "path-http-verbs-order": "error",
"path-not-include-query": "error", "path-not-include-query": "error",
"path-parameters-defined": "error", "path-parameters-defined": "error",
"path-params-defined": "off",
"path-segment-plural": "off",
"paths-kebab-case": "off", "paths-kebab-case": "off",
"required-string-property-missing-min-length": "off",
"response-contains-header": "off",
"scalar-property-missing-example": "off",
"security-defined": "error", "security-defined": "error",
"spec": "error", "spec": "error",
"spec-strict-refs": "off", "spec-strict-refs": "off",
@@ -74,15 +99,22 @@ Object {
`; `;
exports[`resolveStyleguideConfig should resolve extends with local file config which contains path to nested config 1`] = ` exports[`resolveStyleguideConfig should resolve extends with local file config which contains path to nested config 1`] = `
Object { {
"decorators": Object {}, "decorators": {},
"doNotResolveExamples": undefined, "doNotResolveExamples": undefined,
"oas2Decorators": Object {}, "oas2Decorators": {},
"oas2Preprocessors": Object {}, "oas2Preprocessors": {},
"oas2Rules": Object {}, "oas2Rules": {
"oas3_0Decorators": Object {}, "boolean-parameter-prefixes": "error",
"oas3_0Preprocessors": Object {}, "request-mime-type": "off",
"oas3_0Rules": Object { "response-contains-property": "off",
"response-mime-type": "off",
},
"oas3_0Decorators": {},
"oas3_0Preprocessors": {},
"oas3_0Rules": {
"boolean-parameter-prefixes": "error",
"component-name-unique": "off",
"no-empty-servers": "error", "no-empty-servers": "error",
"no-example-value-and-externalValue": "error", "no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "warn", "no-invalid-media-type-examples": "warn",
@@ -91,11 +123,17 @@ Object {
"no-server-variables-empty-enum": "error", "no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error", "no-undefined-server-variable": "error",
"no-unused-components": "warn", "no-unused-components": "warn",
"operation-4xx-problem-details-rfc7807": "off",
"request-mime-type": "off",
"response-contains-property": "off",
"response-mime-type": "off",
"spec-components-invalid-map-name": "error", "spec-components-invalid-map-name": "error",
}, },
"oas3_1Decorators": Object {}, "oas3_1Decorators": {},
"oas3_1Preprocessors": Object {}, "oas3_1Preprocessors": {},
"oas3_1Rules": Object { "oas3_1Rules": {
"boolean-parameter-prefixes": "error",
"component-name-unique": "off",
"no-empty-servers": "error", "no-empty-servers": "error",
"no-example-value-and-externalValue": "error", "no-example-value-and-externalValue": "error",
"no-invalid-media-type-examples": "warn", "no-invalid-media-type-examples": "warn",
@@ -104,39 +142,45 @@ Object {
"no-server-variables-empty-enum": "error", "no-server-variables-empty-enum": "error",
"no-undefined-server-variable": "error", "no-undefined-server-variable": "error",
"no-unused-components": "warn", "no-unused-components": "warn",
"operation-4xx-problem-details-rfc7807": "off",
"request-mime-type": "off",
"response-contains-property": "off",
"response-mime-type": "off",
"spec-components-invalid-map-name": "error", "spec-components-invalid-map-name": "error",
}, },
"preprocessors": Object {}, "preprocessors": {},
"recommendedFallback": undefined, "recommendedFallback": undefined,
"rules": Object { "rules": {
"assertions": Array [ "assertions": [
Object { {
"assertionId": "rule/path-item-get-defined", "assertionId": "rule/path-item-get-defined",
"defined": true, "defined": true,
"message": "Every path item must have a GET operation.", "message": "Every path item must have a GET operation.",
"property": "get", "property": "get",
"subject": "PathItem", "subject": "PathItem",
}, },
Object { {
"assertionId": "rule/tag-description", "assertionId": "rule/tag-description",
"message": "Tag description must be at least 13 characters and end with a full stop.", "message": "Tag description must be at least 13 characters and end with a full stop.",
"minLength": 13, "minLength": 13,
"pattern": "/\\\\.$/", "pattern": "/\\.$/",
"property": "description", "property": "description",
"severity": "error", "severity": "error",
"subject": "Tag", "subject": "Tag",
}, },
], ],
"boolean-parameter-prefixes": "error", "boolean-parameter-prefixes": "error",
"component-name-unique": "off",
"info-contact": "off", "info-contact": "off",
"info-license": "warn", "info-license": "warn",
"info-license-url": "warn", "info-license-url": "warn",
"local/operation-id-not-test": "error", "local/operation-id-not-test": "error",
"no-ambiguous-paths": "warn", "no-ambiguous-paths": "warn",
"no-enum-type-mismatch": "error", "no-enum-type-mismatch": "error",
"no-http-verbs-in-paths": "off",
"no-identical-paths": "error", "no-identical-paths": "error",
"no-invalid-media-type-examples": "warn", "no-invalid-media-type-examples": "warn",
"no-invalid-parameter-examples": "off",
"no-invalid-schema-examples": "off",
"no-path-trailing-slash": "error", "no-path-trailing-slash": "error",
"no-unresolved-refs": "error", "no-unresolved-refs": "error",
"operation-2xx-response": "error", "operation-2xx-response": "error",
@@ -151,9 +195,16 @@ Object {
"operation-tag-defined": "off", "operation-tag-defined": "off",
"parameter-description": "off", "parameter-description": "off",
"path-declaration-must-exist": "error", "path-declaration-must-exist": "error",
"path-excludes-patterns": "off",
"path-http-verbs-order": "off",
"path-not-include-query": "error", "path-not-include-query": "error",
"path-parameters-defined": "error", "path-parameters-defined": "error",
"path-params-defined": "off",
"path-segment-plural": "off",
"paths-kebab-case": "off", "paths-kebab-case": "off",
"required-string-property-missing-min-length": "off",
"response-contains-header": "off",
"scalar-property-missing-example": "off",
"security-defined": "error", "security-defined": "error",
"spec": "error", "spec": "error",
"spec-strict-refs": "off", "spec-strict-refs": "off",

View File

@@ -5,160 +5,160 @@ StyleguideConfig {
"_usedRules": Set {}, "_usedRules": Set {},
"_usedVersions": Set {}, "_usedVersions": Set {},
"configFile": undefined, "configFile": undefined,
"decorators": Object { "decorators": {
"async2": Object { "async2": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas2": Object { "oas2": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas3_0": Object { "oas3_0": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas3_1": Object { "oas3_1": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
}, },
"doNotResolveExamples": false, "doNotResolveExamples": false,
"extendPaths": Array [], "extendPaths": [],
"ignore": Object { "ignore": {
"https://some-path.yaml": Object { "https://some-path.yaml": {
"no-unused-components": Set { "no-unused-components": Set {
"#/components/schemas/Foo", "#/components/schemas/Foo",
}, },
}, },
"some-path/openapi.yaml": Object { "some-path/openapi.yaml": {
"no-unused-components": Set { "no-unused-components": Set {
"#/components/schemas/Foo", "#/components/schemas/Foo",
}, },
}, },
}, },
"pluginPaths": Array [], "pluginPaths": [],
"plugins": Array [], "plugins": [],
"preprocessors": Object { "preprocessors": {
"async2": Object { "async2": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas2": Object { "oas2": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas3_0": Object { "oas3_0": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"oas3_1": Object { "oas3_1": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
}, },
"rawConfig": Object { "rawConfig": {
"_usedRules": Set {}, "_usedRules": Set {},
"_usedVersions": Set {}, "_usedVersions": Set {},
"configFile": "redocly.yaml", "configFile": "redocly.yaml",
"decorators": Object { "decorators": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"doNotResolveExamples": false, "doNotResolveExamples": false,
"ignore": Object {}, "ignore": {},
"plugins": Array [], "plugins": [],
"preprocessors": Object { "preprocessors": {
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"rawConfig": Object { "rawConfig": {
"plugins": Array [], "plugins": [],
"rules": Object { "rules": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"recommendedFallback": false, "recommendedFallback": false,
"rules": Object { "rules": {
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
}, },
"recommendedFallback": false, "recommendedFallback": false,
"rules": Object { "rules": {
"async2": Object { "async2": {
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"oas2": Object { "oas2": {
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"oas3_0": Object { "oas3_0": {
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"oas3_1": Object { "oas3_1": {
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },

View File

@@ -69,95 +69,95 @@ describe('getMergedConfig', () => {
it('should get styleguide defined in "apis" section', () => { it('should get styleguide defined in "apis" section', () => {
expect(getMergedConfig(testConfig, 'test@v1')).toMatchInlineSnapshot(` expect(getMergedConfig(testConfig, 'test@v1')).toMatchInlineSnapshot(`
Config { Config {
"apis": Object { "apis": {
"test@v1": Object { "test@v1": {
"root": "resources/pets.yaml", "root": "resources/pets.yaml",
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
}, },
}, },
"configFile": "redocly.yaml", "configFile": "redocly.yaml",
"files": Array [], "files": [],
"organization": "redocly-test", "organization": "redocly-test",
"rawConfig": Object { "rawConfig": {
"apis": Object { "apis": {
"test@v1": Object { "test@v1": {
"root": "resources/pets.yaml", "root": "resources/pets.yaml",
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
}, },
}, },
"files": Array [], "files": [],
"organization": "redocly-test", "organization": "redocly-test",
"styleguide": Object { "styleguide": {
"extendPaths": Array [], "extendPaths": [],
"pluginPaths": Array [], "pluginPaths": [],
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
"telemetry": "on", "telemetry": "on",
"theme": Object {}, "theme": {},
}, },
"region": undefined, "region": undefined,
"resolve": Object { "resolve": {
"http": Object { "http": {
"customFetch": undefined, "customFetch": undefined,
"headers": Array [], "headers": [],
}, },
}, },
"styleguide": StyleguideConfig { "styleguide": StyleguideConfig {
"_usedRules": Set {}, "_usedRules": Set {},
"_usedVersions": Set {}, "_usedVersions": Set {},
"configFile": "redocly.yaml", "configFile": "redocly.yaml",
"decorators": Object { "decorators": {
"async2": Object {}, "async2": {},
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"doNotResolveExamples": false, "doNotResolveExamples": false,
"extendPaths": Array [], "extendPaths": [],
"ignore": Object {}, "ignore": {},
"pluginPaths": Array [], "pluginPaths": [],
"plugins": Array [], "plugins": [],
"preprocessors": Object { "preprocessors": {
"async2": Object {}, "async2": {},
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"rawConfig": Object { "rawConfig": {
"extendPaths": Array [], "extendPaths": [],
"pluginPaths": Array [], "pluginPaths": [],
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
"recommendedFallback": false, "recommendedFallback": false,
"rules": Object { "rules": {
"async2": Object { "async2": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
"oas2": Object { "oas2": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
"oas3_0": Object { "oas3_0": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
"oas3_1": Object { "oas3_1": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
}, },
"telemetry": "on", "telemetry": "on",
"theme": Object {}, "theme": {},
} }
`); `);
}); });
@@ -172,103 +172,103 @@ describe('getMergedConfig', () => {
it('should handle wrong alias - return the same styleguide, empty features', () => { it('should handle wrong alias - return the same styleguide, empty features', () => {
expect(getMergedConfig(testConfig, 'wrong-alias')).toMatchInlineSnapshot(` expect(getMergedConfig(testConfig, 'wrong-alias')).toMatchInlineSnapshot(`
Config { Config {
"apis": Object { "apis": {
"test@v1": Object { "test@v1": {
"root": "resources/pets.yaml", "root": "resources/pets.yaml",
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
}, },
}, },
"configFile": "redocly.yaml", "configFile": "redocly.yaml",
"files": Array [], "files": [],
"organization": "redocly-test", "organization": "redocly-test",
"rawConfig": Object { "rawConfig": {
"apis": Object { "apis": {
"test@v1": Object { "test@v1": {
"root": "resources/pets.yaml", "root": "resources/pets.yaml",
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-summary": "warn", "operation-summary": "warn",
}, },
}, },
}, },
}, },
"files": Array [], "files": [],
"organization": "redocly-test", "organization": "redocly-test",
"styleguide": Object { "styleguide": {
"extendPaths": Array [], "extendPaths": [],
"pluginPaths": Array [], "pluginPaths": [],
"plugins": Array [], "plugins": [],
"rules": Object { "rules": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"telemetry": "on", "telemetry": "on",
"theme": Object {}, "theme": {},
}, },
"region": undefined, "region": undefined,
"resolve": Object { "resolve": {
"http": Object { "http": {
"customFetch": undefined, "customFetch": undefined,
"headers": Array [], "headers": [],
}, },
}, },
"styleguide": StyleguideConfig { "styleguide": StyleguideConfig {
"_usedRules": Set {}, "_usedRules": Set {},
"_usedVersions": Set {}, "_usedVersions": Set {},
"configFile": "redocly.yaml", "configFile": "redocly.yaml",
"decorators": Object { "decorators": {
"async2": Object {}, "async2": {},
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"doNotResolveExamples": false, "doNotResolveExamples": false,
"extendPaths": Array [], "extendPaths": [],
"ignore": Object {}, "ignore": {},
"pluginPaths": Array [], "pluginPaths": [],
"plugins": Array [], "plugins": [],
"preprocessors": Object { "preprocessors": {
"async2": Object {}, "async2": {},
"oas2": Object {}, "oas2": {},
"oas3_0": Object {}, "oas3_0": {},
"oas3_1": Object {}, "oas3_1": {},
}, },
"rawConfig": Object { "rawConfig": {
"extendPaths": Array [], "extendPaths": [],
"pluginPaths": Array [], "pluginPaths": [],
"plugins": Array [], "plugins": [],
"rules": Object { "rules": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
"recommendedFallback": false, "recommendedFallback": false,
"rules": Object { "rules": {
"async2": Object { "async2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas2": Object { "oas2": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_0": Object { "oas3_0": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
"oas3_1": Object { "oas3_1": {
"no-empty-servers": "error", "no-empty-servers": "error",
"operation-summary": "error", "operation-summary": "error",
}, },
}, },
}, },
"telemetry": "on", "telemetry": "on",
"theme": Object {}, "theme": {},
} }
`); `);
}); });

View File

@@ -172,17 +172,21 @@ function verifyExtendedConfig(
const recommendedRules = defaultPlugin?.configs?.[extendsRuleSet]; const recommendedRules = defaultPlugin?.configs?.[extendsRuleSet];
expect(recommendedRules).toBeDefined(); expect(recommendedRules).toBeDefined();
verifyOasRules(config.styleguide.rules.oas2, overridesRules, recommendedRules?.rules || {});
verifyOasRules( verifyOasRules(
config.styleguide.rules.oas3_0, config.styleguide.rules.oas2,
overridesRules, overridesRules,
Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_0Rules) { ...recommendedRules?.rules, ...recommendedRules?.oas2Rules } || {}
);
verifyOasRules(
config.styleguide.rules.oas3_1,
overridesRules,
Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_1Rules)
); );
verifyOasRules(config.styleguide.rules.oas3_0, overridesRules, {
...recommendedRules?.rules,
...recommendedRules?.oas3_0Rules,
});
verifyOasRules(config.styleguide.rules.oas3_1, overridesRules, {
...recommendedRules?.rules,
...recommendedRules?.oas3_1Rules,
});
} }
function verifyOasRules( function verifyOasRules(

View File

@@ -78,25 +78,25 @@ describe('transformConfig', () => {
makeTestRawConfig('styleguide', 'styleguide') makeTestRawConfig('styleguide', 'styleguide')
); );
expect(transformedRawConfig).toMatchInlineSnapshot(` expect(transformedRawConfig).toMatchInlineSnapshot(`
Object { {
"apis": Object { "apis": {
"test@v1": Object { "test@v1": {
"root": "root.yaml", "root": "root.yaml",
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-2xx-response": "error", "operation-2xx-response": "error",
}, },
}, },
}, },
}, },
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-4xx-response": "warn", "operation-4xx-response": "warn",
}, },
}, },
"theme": Object { "theme": {
"mockServer": Object {}, "mockServer": {},
"openapi": Object {}, "openapi": {},
}, },
} }
`); `);
@@ -111,20 +111,20 @@ describe('transformConfig', () => {
testRawConfig.apis = undefined; testRawConfig.apis = undefined;
testRawConfig.apiDefinitions = { legacyApiDefinition: 'file.yaml' }; testRawConfig.apiDefinitions = { legacyApiDefinition: 'file.yaml' };
expect(utils.transformConfig(testRawConfig)).toMatchInlineSnapshot(` expect(utils.transformConfig(testRawConfig)).toMatchInlineSnapshot(`
Object { {
"apis": Object { "apis": {
"legacyApiDefinition": Object { "legacyApiDefinition": {
"root": "file.yaml", "root": "file.yaml",
}, },
}, },
"styleguide": Object { "styleguide": {
"rules": Object { "rules": {
"operation-4xx-response": "warn", "operation-4xx-response": "warn",
}, },
}, },
"theme": Object { "theme": {
"mockServer": Object {}, "mockServer": {},
"openapi": Object {}, "openapi": {},
}, },
} }
`); `);

View File

@@ -1,6 +1,6 @@
import type { PluginStyleguideConfig } from './types'; import type { PluginStyleguideConfig } from './types';
export default { const all: PluginStyleguideConfig<'built-in'> = {
rules: { rules: {
'info-contact': 'error', 'info-contact': 'error',
'info-license': 'error', 'info-license': 'error',
@@ -28,13 +28,24 @@ export default {
'operation-singular-tag': 'error', 'operation-singular-tag': 'error',
'no-unresolved-refs': 'error', 'no-unresolved-refs': 'error',
'no-enum-type-mismatch': 'error', 'no-enum-type-mismatch': 'error',
'boolean-parameter-prefixes': 'error',
'paths-kebab-case': 'error', 'paths-kebab-case': 'error',
'no-http-verbs-in-paths': 'error', 'no-http-verbs-in-paths': 'error',
'path-excludes-patterns': { 'path-excludes-patterns': {
severity: 'error', severity: 'error',
patterns: [], patterns: [],
}, },
spec: 'error',
'no-invalid-schema-examples': 'error',
'no-invalid-parameter-examples': 'error',
'scalar-property-missing-example': 'error',
'spec-strict-refs': 'error',
'path-http-verbs-order': 'error',
'path-params-defined': 'error',
'required-string-property-missing-min-length': 'error',
'response-contains-header': 'error',
},
oas2Rules: {
'boolean-parameter-prefixes': 'error',
'request-mime-type': { 'request-mime-type': {
severity: 'error', severity: 'error',
allowedValues: ['application/json'], allowedValues: ['application/json'],
@@ -43,12 +54,7 @@ export default {
severity: 'error', severity: 'error',
allowedValues: ['application/json'], allowedValues: ['application/json'],
}, },
spec: 'error', 'response-contains-property': 'error',
'no-invalid-schema-examples': 'error',
'no-invalid-parameter-examples': 'error',
'scalar-property-missing-example': 'error',
'spec-strict-refs': 'error',
'component-name-unique': 'error',
}, },
oas3_0Rules: { oas3_0Rules: {
'no-invalid-media-type-examples': 'error', 'no-invalid-media-type-examples': 'error',
@@ -60,8 +66,21 @@ export default {
'no-undefined-server-variable': 'error', 'no-undefined-server-variable': 'error',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'operation-4xx-problem-details-rfc7807': 'error', 'operation-4xx-problem-details-rfc7807': 'error',
'boolean-parameter-prefixes': 'error',
'request-mime-type': {
severity: 'error',
allowedValues: ['application/json'],
},
'response-mime-type': {
severity: 'error',
allowedValues: ['application/json'],
},
'component-name-unique': 'error',
'response-contains-property': 'error',
'spec-components-invalid-map-name': 'error',
}, },
oas3_1Rules: { oas3_1Rules: {
'no-invalid-media-type-examples': 'error',
'no-server-example.com': 'error', 'no-server-example.com': 'error',
'no-server-trailing-slash': 'error', 'no-server-trailing-slash': 'error',
'no-empty-servers': 'error', 'no-empty-servers': 'error',
@@ -70,5 +89,23 @@ export default {
'no-undefined-server-variable': 'error', 'no-undefined-server-variable': 'error',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'operation-4xx-problem-details-rfc7807': 'error', 'operation-4xx-problem-details-rfc7807': 'error',
'boolean-parameter-prefixes': 'error',
'request-mime-type': {
severity: 'error',
allowedValues: ['application/json'],
},
'response-mime-type': {
severity: 'error',
allowedValues: ['application/json'],
},
'component-name-unique': 'error',
'response-contains-property': 'error',
'spec-components-invalid-map-name': 'error',
}, },
} as PluginStyleguideConfig; async2Rules: {
'channels-kebab-case': 'error',
'no-channel-trailing-slash': 'error',
},
};
export default all;

View File

@@ -1,6 +1,6 @@
import type { PluginStyleguideConfig } from './types'; import type { PluginStyleguideConfig } from './types';
export default { const minimal: PluginStyleguideConfig<'built-in'> = {
rules: { rules: {
'info-contact': 'off', 'info-contact': 'off',
'info-license': 'off', 'info-license': 'off',
@@ -27,11 +27,25 @@ export default {
'operation-singular-tag': 'off', 'operation-singular-tag': 'off',
'no-unresolved-refs': 'error', 'no-unresolved-refs': 'error',
'no-enum-type-mismatch': 'warn', 'no-enum-type-mismatch': 'warn',
'boolean-parameter-prefixes': 'off',
'paths-kebab-case': 'off', 'paths-kebab-case': 'off',
spec: 'error', spec: 'error',
'spec-strict-refs': 'off', 'spec-strict-refs': 'off',
'component-name-unique': 'off', 'no-http-verbs-in-paths': 'off',
'no-invalid-parameter-examples': 'off',
'no-invalid-schema-examples': 'off',
'path-excludes-patterns': 'off',
'path-http-verbs-order': 'off',
'path-params-defined': 'off',
'required-string-property-missing-min-length': 'off',
'response-contains-header': 'off',
'path-segment-plural': 'off',
'scalar-property-missing-example': 'off',
},
oas2Rules: {
'boolean-parameter-prefixes': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
oas3_0Rules: { oas3_0Rules: {
'no-invalid-media-type-examples': { 'no-invalid-media-type-examples': {
@@ -46,6 +60,12 @@ export default {
'no-undefined-server-variable': 'warn', 'no-undefined-server-variable': 'warn',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'spec-components-invalid-map-name': 'warn', 'spec-components-invalid-map-name': 'warn',
'boolean-parameter-prefixes': 'off',
'component-name-unique': 'off',
'operation-4xx-problem-details-rfc7807': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
oas3_1Rules: { oas3_1Rules: {
'no-invalid-media-type-examples': 'warn', 'no-invalid-media-type-examples': 'warn',
@@ -57,5 +77,17 @@ export default {
'no-undefined-server-variable': 'warn', 'no-undefined-server-variable': 'warn',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'spec-components-invalid-map-name': 'warn', 'spec-components-invalid-map-name': 'warn',
'boolean-parameter-prefixes': 'off',
'component-name-unique': 'off',
'operation-4xx-problem-details-rfc7807': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
} as PluginStyleguideConfig; async2Rules: {
'channels-kebab-case': 'off',
'no-channel-trailing-slash': 'off',
},
};
export default minimal;

View File

@@ -1,6 +1,6 @@
import type { PluginStyleguideConfig } from './types'; import type { PluginStyleguideConfig } from './types';
export default { const recommended: PluginStyleguideConfig<'built-in'> = {
rules: { rules: {
'info-contact': 'off', 'info-contact': 'off',
'info-license': 'warn', 'info-license': 'warn',
@@ -27,11 +27,25 @@ export default {
'operation-singular-tag': 'off', 'operation-singular-tag': 'off',
'no-unresolved-refs': 'error', 'no-unresolved-refs': 'error',
'no-enum-type-mismatch': 'error', 'no-enum-type-mismatch': 'error',
'boolean-parameter-prefixes': 'off',
'paths-kebab-case': 'off', 'paths-kebab-case': 'off',
spec: 'error', spec: 'error',
'spec-strict-refs': 'off', 'spec-strict-refs': 'off',
'component-name-unique': 'off', 'no-http-verbs-in-paths': 'off',
'no-invalid-parameter-examples': 'off',
'no-invalid-schema-examples': 'off',
'path-excludes-patterns': 'off',
'path-http-verbs-order': 'off',
'path-params-defined': 'off',
'path-segment-plural': 'off',
'required-string-property-missing-min-length': 'off',
'response-contains-header': 'off',
'scalar-property-missing-example': 'off',
},
oas2Rules: {
'boolean-parameter-prefixes': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
oas3_0Rules: { oas3_0Rules: {
'no-invalid-media-type-examples': { 'no-invalid-media-type-examples': {
@@ -46,6 +60,12 @@ export default {
'no-undefined-server-variable': 'error', 'no-undefined-server-variable': 'error',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'spec-components-invalid-map-name': 'error', 'spec-components-invalid-map-name': 'error',
'boolean-parameter-prefixes': 'off',
'component-name-unique': 'off',
'operation-4xx-problem-details-rfc7807': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
oas3_1Rules: { oas3_1Rules: {
'no-invalid-media-type-examples': 'warn', 'no-invalid-media-type-examples': 'warn',
@@ -57,5 +77,17 @@ export default {
'no-undefined-server-variable': 'error', 'no-undefined-server-variable': 'error',
'no-server-variables-empty-enum': 'error', 'no-server-variables-empty-enum': 'error',
'spec-components-invalid-map-name': 'error', 'spec-components-invalid-map-name': 'error',
'boolean-parameter-prefixes': 'off',
'component-name-unique': 'off',
'operation-4xx-problem-details-rfc7807': 'off',
'request-mime-type': 'off',
'response-contains-property': 'off',
'response-mime-type': 'off',
}, },
} as PluginStyleguideConfig; async2Rules: {
'channels-kebab-case': 'off',
'no-channel-trailing-slash': 'off',
},
};
export default recommended;

View File

@@ -11,11 +11,19 @@ import type {
Async2PreprocessorsSet, Async2PreprocessorsSet,
Async2DecoratorsSet, Async2DecoratorsSet,
Async2RuleSet, Async2RuleSet,
RuleMap,
} from '../oas-types'; } from '../oas-types';
import type { NodeType } from '../types'; import type { NodeType } from '../types';
import { Location } from '../ref-utils'; import { Location } from '../ref-utils';
import type { SkipFunctionContext } from '../visitors'; import type { SkipFunctionContext } from '../visitors';
import {
BuiltInAsync2RuleId,
BuiltInCommonOASRuleId,
BuiltInCommonRuleId,
BuiltInOAS2RuleId,
BuiltInOAS3RuleId,
} from '../types/redocly-yaml';
export type RuleSeverity = ProblemSeverity | 'off'; export type RuleSeverity = ProblemSeverity | 'off';
@@ -37,17 +45,17 @@ export type PreprocessorConfig =
export type DecoratorConfig = PreprocessorConfig; export type DecoratorConfig = PreprocessorConfig;
export type StyleguideRawConfig = { export type StyleguideRawConfig<T = undefined> = {
plugins?: (string | Plugin)[]; plugins?: (string | Plugin)[];
extends?: string[]; extends?: string[];
doNotResolveExamples?: boolean; doNotResolveExamples?: boolean;
recommendedFallback?: boolean; recommendedFallback?: boolean;
rules?: Record<string, RuleConfig>; rules?: RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId, RuleConfig, T>;
oas2Rules?: Record<string, RuleConfig>; oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
oas3_0Rules?: Record<string, RuleConfig>; oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
oas3_1Rules?: Record<string, RuleConfig>; oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
async2Rules?: Record<string, RuleConfig>; async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
preprocessors?: Record<string, PreprocessorConfig>; preprocessors?: Record<string, PreprocessorConfig>;
oas2Preprocessors?: Record<string, PreprocessorConfig>; oas2Preprocessors?: Record<string, PreprocessorConfig>;
@@ -118,7 +126,10 @@ export type Plugin = {
assertions?: AssertionsConfig; assertions?: AssertionsConfig;
}; };
export type PluginStyleguideConfig = Omit<StyleguideRawConfig, 'plugins' | 'extends'>; export type PluginStyleguideConfig<T = undefined> = Omit<
StyleguideRawConfig<T>,
'plugins' | 'extends'
>;
export type ResolveHeader = export type ResolveHeader =
| { | {

View File

@@ -2,7 +2,7 @@ import { Oas3Decorator } from '../../visitors';
import { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi'; import { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi';
import { yamlAndJsonSyncReader } from '../../utils'; import { yamlAndJsonSyncReader } from '../../utils';
import { isRef } from '../../ref-utils'; import { isRef } from '../../ref-utils';
import { ResolveFn, UserContext } from '../../walk'; import { NonUndefined, ResolveFn, UserContext } from '../../walk';
export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => { export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => {
return { return {
@@ -69,7 +69,7 @@ export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => {
}; };
}; };
function checkAndResolveRef<T>(node: any, resolver: ResolveFn): T | undefined { function checkAndResolveRef<T extends NonUndefined>(node: any, resolver: ResolveFn): T | undefined {
if (!isRef(node)) { if (!isRef(node)) {
return node; return node;
} }

View File

@@ -5,7 +5,7 @@ import { ProblemSeverity, WalkContext, walkDocument } from './walk';
import { StyleguideConfig, Config, initRules, defaultPlugin, resolvePlugins } from './config'; import { StyleguideConfig, Config, initRules, defaultPlugin, resolvePlugins } from './config';
import { normalizeTypes } from './types'; import { normalizeTypes } from './types';
import { releaseAjvInstance } from './rules/ajv'; import { releaseAjvInstance } from './rules/ajv';
import { Oas3RuleSet, SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types'; import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types';
import { ConfigTypes } from './types/redocly-yaml'; import { ConfigTypes } from './types/redocly-yaml';
import { Spec } from './rules/common/spec'; import { Spec } from './rules/common/spec';
@@ -65,8 +65,8 @@ export async function lintDocument(opts: {
visitorsData: {}, visitorsData: {},
}; };
const preprocessors = initRules(rules as any, config, 'preprocessors', specVersion); const preprocessors = initRules(rules, config, 'preprocessors', specVersion);
const regularRules = initRules(rules as Oas3RuleSet[], config, 'rules', specVersion); const regularRules = initRules(rules, config, 'rules', specVersion);
let resolvedRefMap = await resolveDocument({ let resolvedRefMap = await resolveDocument({
rootDocument: document, rootDocument: document,

View File

@@ -10,6 +10,13 @@ import { Oas2Types } from './types/oas2';
import { Oas3Types } from './types/oas3'; import { Oas3Types } from './types/oas3';
import { Oas3_1Types } from './types/oas3_1'; import { Oas3_1Types } from './types/oas3_1';
import { AsyncApi2Types } from './types/asyncapi'; import { AsyncApi2Types } from './types/asyncapi';
import {
BuiltInAsync2RuleId,
BuiltInCommonOASRuleId,
BuiltInCommonRuleId,
BuiltInOAS2RuleId,
BuiltInOAS3RuleId,
} from './types/redocly-yaml';
export type RuleSet<T> = Record<string, T>; export type RuleSet<T> = Record<string, T>;
@@ -33,9 +40,25 @@ const typesMap = {
[SpecVersion.Async2]: AsyncApi2Types, [SpecVersion.Async2]: AsyncApi2Types,
}; };
export type Oas3RuleSet = Record<string, Oas3Rule>; export type RuleMap<Key extends string, RuleConfig, T> = Record<
export type Oas2RuleSet = Record<string, Oas2Rule>; T extends 'built-in' ? Key : string,
export type Async2RuleSet = Record<string, Async2Rule>; RuleConfig
>;
export type Oas3RuleSet<T = undefined> = RuleMap<
BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS3RuleId | 'assertions',
Oas3Rule,
T
>;
export type Oas2RuleSet<T = undefined> = RuleMap<
BuiltInCommonRuleId | BuiltInCommonOASRuleId | BuiltInOAS2RuleId | 'assertions',
Oas2Rule,
T
>;
export type Async2RuleSet<T = undefined> = RuleMap<
BuiltInCommonRuleId | BuiltInAsync2RuleId | 'assertions',
Async2Rule,
T
>;
export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>; export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>; export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>; export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;

View File

@@ -27,10 +27,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/requestBody", "pointer": "#/paths/~1test/put/requestBody",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -39,7 +39,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
"message": "Can't resolve $ref: ENOENT: no such file or directory 'invalid.yaml'", "message": "Can't resolve $ref: ENOENT: no such file or directory 'invalid.yaml'",
"ruleId": "no-unresolved-refs", "ruleId": "no-unresolved-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -67,36 +67,36 @@ describe('oas3 boolean-parameter-prefixes', () => {
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": undefined, "pointer": undefined,
"reportOnKey": false, "reportOnKey": false,
"source": "fixtures/invalid-yaml.yaml", "source": "fixtures/invalid-yaml.yaml",
"start": Object { "start": {
"col": 1, "col": 1,
"line": 2, "line": 2,
}, },
}, },
], ],
"message": "Failed to parse: unexpected end of the stream within a single quoted scalar in \\"fixtures/invalid-yaml.yaml\\" (2:1)", "message": "Failed to parse: unexpected end of the stream within a single quoted scalar in "fixtures/invalid-yaml.yaml" (2:1)",
"ruleId": "no-unresolved-refs", "ruleId": "no-unresolved-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/requestBody", "pointer": "#/paths/~1test/put/requestBody",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Can't resolve $ref: unexpected end of the stream within a single quoted scalar in \\"fixtures/invalid-yaml.yaml\\" (2:1)", "message": "Can't resolve $ref: unexpected end of the stream within a single quoted scalar in "fixtures/invalid-yaml.yaml" (2:1)",
"ruleId": "no-unresolved-refs", "ruleId": "no-unresolved-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -123,7 +123,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
}); });
it('should report on unresolved localr ref', async () => { it('should report on unresolved localr ref', async () => {
@@ -148,10 +148,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/requestBody", "pointer": "#/paths/~1test/put/requestBody",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -160,7 +160,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
"message": "Can't resolve $ref", "message": "Can't resolve $ref",
"ruleId": "no-unresolved-refs", "ruleId": "no-unresolved-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -194,7 +194,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on nested refs inside specification extensions', async () => { it('should not report on nested refs inside specification extensions', async () => {
@@ -223,7 +223,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on nested refs inside specification extensions for 3.1', async () => { it('should not report on nested refs inside specification extensions for 3.1', async () => {
@@ -252,6 +252,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -27,10 +27,10 @@ describe('Async2 channels-kebab-case', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/channels/NOT_A_KEBAB", "pointer": "#/channels/NOT_A_KEBAB",
"reportOnKey": true, "reportOnKey": true,
"source": "asyncapi.yaml", "source": "asyncapi.yaml",
@@ -39,7 +39,7 @@ describe('Async2 channels-kebab-case', () => {
"message": "\`NOT_A_KEBAB\` does not use kebab-case.", "message": "\`NOT_A_KEBAB\` does not use kebab-case.",
"ruleId": "channels-kebab-case", "ruleId": "channels-kebab-case",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -68,10 +68,10 @@ describe('Async2 channels-kebab-case', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/channels/snake_kebab", "pointer": "#/channels/snake_kebab",
"reportOnKey": true, "reportOnKey": true,
"source": "asyncapi.yaml", "source": "asyncapi.yaml",
@@ -80,7 +80,7 @@ describe('Async2 channels-kebab-case', () => {
"message": "\`snake_kebab\` does not use kebab-case.", "message": "\`snake_kebab\` does not use kebab-case.",
"ruleId": "channels-kebab-case", "ruleId": "channels-kebab-case",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -110,7 +110,7 @@ describe('Async2 channels-kebab-case', () => {
'no-path-trailing-slash': 'off', 'no-path-trailing-slash': 'off',
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('words with hyphens are allowed with "channels-kebab-case" rule', async () => { it('words with hyphens are allowed with "channels-kebab-case" rule', async () => {
@@ -136,6 +136,6 @@ describe('Async2 channels-kebab-case', () => {
'paths-kebab-case': 'error', 'paths-kebab-case': 'error',
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -27,10 +27,10 @@ describe('no-channel-trailing-slash', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/channels/~1trailing~1", "pointer": "#/channels/~1trailing~1",
"reportOnKey": true, "reportOnKey": true,
"source": "asyncapi.yaml", "source": "asyncapi.yaml",
@@ -39,7 +39,7 @@ describe('no-channel-trailing-slash', () => {
"message": "\`/trailing/\` should not have a trailing slash.", "message": "\`/trailing/\` should not have a trailing slash.",
"ruleId": "no-channel-trailing-slash", "ruleId": "no-channel-trailing-slash",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -67,7 +67,7 @@ describe('no-channel-trailing-slash', () => {
config: await makeConfig({ 'no-channel-trailing-slash': 'error' }), config: await makeConfig({ 'no-channel-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on trailing slash in path if the path is root', async () => { it('should not report on trailing slash in path if the path is root', async () => {
@@ -92,6 +92,6 @@ describe('no-channel-trailing-slash', () => {
config: await makeConfig({ 'no-channel-trailing-slash': 'error' }), config: await makeConfig({ 'no-channel-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -7,8 +7,9 @@ import { TagDescription } from '../common/tag-description';
import { TagsAlphabetical } from '../common/tags-alphabetical'; import { TagsAlphabetical } from '../common/tags-alphabetical';
import { ChannelsKebabCase } from './channels-kebab-case'; import { ChannelsKebabCase } from './channels-kebab-case';
import { NoChannelTrailingSlash } from './no-channel-trailing-slash'; import { NoChannelTrailingSlash } from './no-channel-trailing-slash';
import type { Async2RuleSet } from '../../oas-types';
export const rules = { export const rules: Async2RuleSet<'built-in'> = {
spec: Spec as Async2Rule, spec: Spec as Async2Rule,
assertions: Assertions, assertions: Assertions,
'info-contact': InfoContact, 'info-contact': InfoContact,

View File

@@ -21,10 +21,10 @@ describe('Oas3 info-license', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/info", "pointer": "#/info",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -33,7 +33,7 @@ describe('Oas3 info-license', () => {
"message": "Info object should contain \`license\` field.", "message": "Info object should contain \`license\` field.",
"ruleId": "info-license", "ruleId": "info-license",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -57,6 +57,6 @@ describe('Oas3 info-license', () => {
config: await makeConfig({ 'info-license': 'error' }), config: await makeConfig({ 'info-license': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -22,10 +22,10 @@ describe('Oas3 license-url', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/info/license/url", "pointer": "#/info/license/url",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -34,7 +34,7 @@ describe('Oas3 license-url', () => {
"message": "License object should contain \`url\` field.", "message": "License object should contain \`url\` field.",
"ruleId": "info-license-url", "ruleId": "info-license-url",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -58,6 +58,6 @@ describe('Oas3 license-url', () => {
config: await makeConfig({ 'info-license-url': 'error' }), config: await makeConfig({ 'info-license-url': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -50,10 +50,10 @@ describe('no-ambiguous-paths', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1{id}~1ambiguous", "pointer": "#/paths/~1{id}~1ambiguous",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -62,11 +62,11 @@ describe('no-ambiguous-paths', () => {
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}\` and \`/{id}/ambiguous\`.", "message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}\` and \`/{id}/ambiguous\`.",
"ruleId": "no-ambiguous-paths", "ruleId": "no-ambiguous-paths",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1ambiguous~1{id}", "pointer": "#/paths/~1ambiguous~1{id}",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -75,11 +75,11 @@ describe('no-ambiguous-paths', () => {
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/{id}/ambiguous\` and \`/ambiguous/{id}\`.", "message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/{id}/ambiguous\` and \`/ambiguous/{id}\`.",
"ruleId": "no-ambiguous-paths", "ruleId": "no-ambiguous-paths",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1{entity}~1{id}~1last", "pointer": "#/paths/~1{entity}~1{id}~1last",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -88,7 +88,7 @@ describe('no-ambiguous-paths', () => {
"message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}/{pet}\` and \`/{entity}/{id}/last\`.", "message": "Paths should resolve unambiguously. Found two ambiguous paths: \`/good/{id}/{pet}\` and \`/{entity}/{id}/last\`.",
"ruleId": "no-ambiguous-paths", "ruleId": "no-ambiguous-paths",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -32,7 +32,7 @@ describe('Oas3 typed enum', () => {
config: await makeConfig({ 'no-enum-type-mismatch': 'error' }), config: await makeConfig({ 'no-enum-type-mismatch': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on enum object if all items match type and enum is nullable', async () => { it('should not report on enum object if all items match type and enum is nullable', async () => {
@@ -65,7 +65,7 @@ describe('Oas3 typed enum', () => {
config: await makeConfig({ 'no-enum-type-mismatch': 'error' }), config: await makeConfig({ 'no-enum-type-mismatch': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report on enum object if not all items match type', async () => { it('should report on enum object if not all items match type', async () => {
@@ -96,19 +96,19 @@ describe('Oas3 typed enum', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1", "pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "All values of \`enum\` field must be of the same type as the \`type\` field: expected \\"integer\\" but received \\"string\\".", "message": "All values of \`enum\` field must be of the same type as the \`type\` field: expected "integer" but received "string".",
"ruleId": "no-enum-type-mismatch", "ruleId": "no-enum-type-mismatch",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -144,10 +144,10 @@ describe('Oas3 typed enum', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1", "pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -156,7 +156,7 @@ describe('Oas3 typed enum', () => {
"message": "Enum value \`string\` must be of allowed types: \`integer,array\`.", "message": "Enum value \`string\` must be of allowed types: \`integer,array\`.",
"ruleId": "no-enum-type-mismatch", "ruleId": "no-enum-type-mismatch",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -189,11 +189,11 @@ describe('Oas3 typed enum', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema", "pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -202,7 +202,7 @@ describe('Oas3 typed enum', () => {
"message": "Expected type \`Schema\` (object) but got \`null\`", "message": "Expected type \`Schema\` (object) but got \`null\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -38,10 +38,10 @@ describe('no-identical-paths', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1good~1{hash}", "pointer": "#/paths/~1good~1{hash}",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -50,7 +50,7 @@ describe('no-identical-paths', () => {
"message": "The path already exists which differs only by path parameter name(s): \`/good/{id}\` and \`/good/{hash}\`.", "message": "The path already exists which differs only by path parameter name(s): \`/good/{id}\` and \`/good/{hash}\`.",
"ruleId": "no-identical-paths", "ruleId": "no-identical-paths",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -23,10 +23,10 @@ describe('no-path-trailing-slash', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1bad~1", "pointer": "#/paths/~1bad~1",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -35,7 +35,7 @@ describe('no-path-trailing-slash', () => {
"message": "\`/bad/\` should not have a trailing slash.", "message": "\`/bad/\` should not have a trailing slash.",
"ruleId": "no-path-trailing-slash", "ruleId": "no-path-trailing-slash",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -64,10 +64,10 @@ describe('no-path-trailing-slash', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1bad~1", "pointer": "#/paths/~1bad~1",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -76,7 +76,7 @@ describe('no-path-trailing-slash', () => {
"message": "\`/bad/\` should not have a trailing slash.", "message": "\`/bad/\` should not have a trailing slash.",
"ruleId": "no-path-trailing-slash", "ruleId": "no-path-trailing-slash",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -100,7 +100,7 @@ describe('no-path-trailing-slash', () => {
config: await makeConfig({ 'no-path-trailing-slash': 'error' }), config: await makeConfig({ 'no-path-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on trailing slash in path if the path is root', async () => { it('should not report on trailing slash in path if the path is root', async () => {
@@ -121,6 +121,6 @@ describe('no-path-trailing-slash', () => {
config: await makeConfig({ 'no-path-trailing-slash': 'error' }), config: await makeConfig({ 'no-path-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -25,10 +25,10 @@ describe('Oas3 operation-2xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/responses", "pointer": "#/paths/~1test/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -37,7 +37,7 @@ describe('Oas3 operation-2xx-response', () => {
"message": "Operation must have at least one \`2XX\` response.", "message": "Operation must have at least one \`2XX\` response.",
"ruleId": "operation-2xx-response", "ruleId": "operation-2xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -63,7 +63,7 @@ describe('Oas3 operation-2xx-response', () => {
config: await makeConfig({ 'operation-2xx-response': 'error' }), config: await makeConfig({ 'operation-2xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report for present default', async () => { it('should not report for present default', async () => {
@@ -86,7 +86,7 @@ describe('Oas3 operation-2xx-response', () => {
config: await makeConfig({ 'operation-2xx-response': 'error' }), config: await makeConfig({ 'operation-2xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report even if the responses are null', async () => { it('should report even if the responses are null', async () => {
@@ -108,10 +108,10 @@ describe('Oas3 operation-2xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test~1/put/responses", "pointer": "#/paths/~1test~1/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -120,7 +120,7 @@ describe('Oas3 operation-2xx-response', () => {
"message": "Operation must have at least one \`2XX\` response.", "message": "Operation must have at least one \`2XX\` response.",
"ruleId": "operation-2xx-response", "ruleId": "operation-2xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -149,10 +149,10 @@ describe('Oas3 operation-2xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/webhooks/~1test~1/put/responses", "pointer": "#/webhooks/~1test~1/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -161,7 +161,7 @@ describe('Oas3 operation-2xx-response', () => {
"message": "Operation must have at least one \`2XX\` response.", "message": "Operation must have at least one \`2XX\` response.",
"ruleId": "operation-2xx-response", "ruleId": "operation-2xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -187,6 +187,6 @@ describe('Oas3 operation-2xx-response', () => {
config: await makeConfig({ 'operation-2xx-response': 'error' }), config: await makeConfig({ 'operation-2xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -25,10 +25,10 @@ describe('Oas3 operation-4xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/responses", "pointer": "#/paths/~1test/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -37,7 +37,7 @@ describe('Oas3 operation-4xx-response', () => {
"message": "Operation must have at least one \`4XX\` response.", "message": "Operation must have at least one \`4XX\` response.",
"ruleId": "operation-4xx-response", "ruleId": "operation-4xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -63,7 +63,7 @@ describe('Oas3 operation-4xx-response', () => {
config: await makeConfig({ 'operation-4xx-response': 'error' }), config: await makeConfig({ 'operation-4xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report for present 4XX response', async () => { it('should not report for present 4XX response', async () => {
@@ -86,7 +86,7 @@ describe('Oas3 operation-4xx-response', () => {
config: await makeConfig({ 'operation-4xx-response': 'error' }), config: await makeConfig({ 'operation-4xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report if default is present but missing 4xx response', async () => { it('should report if default is present but missing 4xx response', async () => {
@@ -110,10 +110,10 @@ describe('Oas3 operation-4xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test~1/put/responses", "pointer": "#/paths/~1test~1/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -122,7 +122,7 @@ describe('Oas3 operation-4xx-response', () => {
"message": "Operation must have at least one \`4XX\` response.", "message": "Operation must have at least one \`4XX\` response.",
"ruleId": "operation-4xx-response", "ruleId": "operation-4xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -147,10 +147,10 @@ describe('Oas3 operation-4xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test~1/put/responses", "pointer": "#/paths/~1test~1/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -159,7 +159,7 @@ describe('Oas3 operation-4xx-response', () => {
"message": "Operation must have at least one \`2XX\` response.", "message": "Operation must have at least one \`2XX\` response.",
"ruleId": "operation-2xx-response", "ruleId": "operation-2xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -188,10 +188,10 @@ describe('Oas3 operation-4xx-response', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/webhooks/~1test~1/put/responses", "pointer": "#/webhooks/~1test~1/put/responses",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -200,7 +200,7 @@ describe('Oas3 operation-4xx-response', () => {
"message": "Operation must have at least one \`4XX\` response.", "message": "Operation must have at least one \`4XX\` response.",
"ruleId": "operation-4xx-response", "ruleId": "operation-4xx-response",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -226,6 +226,6 @@ describe('Oas3 operation-4xx-response', () => {
config: await makeConfig({ 'operation-4xx-response': 'error' }), config: await makeConfig({ 'operation-4xx-response': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -30,10 +30,10 @@ describe('Oas3 operation-operationId-unique', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test2/post/test2", "pointer": "#/paths/~1test2/post/test2",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -42,7 +42,7 @@ describe('Oas3 operation-operationId-unique', () => {
"message": "Every operation must have a unique \`operationId\`.", "message": "Every operation must have a unique \`operationId\`.",
"ruleId": "operation-operationId-unique", "ruleId": "operation-operationId-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -71,6 +71,6 @@ describe('Oas3 operation-operationId-unique', () => {
config: await makeConfig({ 'peration-operationId-unique': 'error' }), config: await makeConfig({ 'peration-operationId-unique': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -25,10 +25,10 @@ describe('Oas3 operation-operationId-url-safe', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/operationId", "pointer": "#/paths/~1test/put/operationId",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -37,7 +37,7 @@ describe('Oas3 operation-operationId-url-safe', () => {
"message": "Operation \`operationId\` should not have URL invalid characters.", "message": "Operation \`operationId\` should not have URL invalid characters.",
"ruleId": "operation-operationId-url-safe", "ruleId": "operation-operationId-url-safe",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -26,10 +26,10 @@ describe('Oas3 operation-parameters-unique', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/parameters/1", "pointer": "#/paths/~1test/parameters/1",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -39,7 +39,7 @@ describe('Oas3 operation-parameters-unique', () => {
Repeats of \`in:query\` + \`name:a\`.", Repeats of \`in:query\` + \`name:a\`.",
"ruleId": "operation-parameters-unique", "ruleId": "operation-parameters-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -68,7 +68,7 @@ describe('Oas3 operation-parameters-unique', () => {
config: await makeConfig({ 'operation-parameters-unique': 'error' }), config: await makeConfig({ 'operation-parameters-unique': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report when operation with duplicated params', async () => { it('should report when operation with duplicated params', async () => {
@@ -99,10 +99,10 @@ describe('Oas3 operation-parameters-unique', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/parameters/2", "pointer": "#/paths/~1test/put/parameters/2",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -111,7 +111,7 @@ describe('Oas3 operation-parameters-unique', () => {
"message": "Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:query\` + \`name:a\`.", "message": "Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:query\` + \`name:a\`.",
"ruleId": "operation-parameters-unique", "ruleId": "operation-parameters-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -147,10 +147,10 @@ describe('Oas3 operation-parameters-unique', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/put/parameters/2", "pointer": "#/paths/~1test/put/parameters/2",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -159,7 +159,7 @@ describe('Oas3 operation-parameters-unique', () => {
"message": "Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:query\` + \`name:a\`.", "message": "Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:query\` + \`name:a\`.",
"ruleId": "operation-parameters-unique", "ruleId": "operation-parameters-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -28,10 +28,10 @@ describe('Oas3 operation-singular-tag', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/get/tags", "pointer": "#/paths/~1some/get/tags",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -40,7 +40,7 @@ describe('Oas3 operation-singular-tag', () => {
"message": "Operation \`tags\` object should have only one tag.", "message": "Operation \`tags\` object should have only one tag.",
"ruleId": "operation-singular-tag", "ruleId": "operation-singular-tag",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -67,6 +67,6 @@ describe('Oas3 operation-singular-tag', () => {
config: await makeConfig({ 'operation-singular-tag': 'error' }), config: await makeConfig({ 'operation-singular-tag': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -27,10 +27,10 @@ describe('Common path-http-verbs-order', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/post", "pointer": "#/paths/~1some/post",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -39,11 +39,11 @@ describe('Common path-http-verbs-order', () => {
"message": "Operation http verbs must be ordered.", "message": "Operation http verbs must be ordered.",
"ruleId": "path-http-verbs-order", "ruleId": "path-http-verbs-order",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some/get", "pointer": "#/paths/~1some/get",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -52,7 +52,7 @@ describe('Common path-http-verbs-order', () => {
"message": "Operation http verbs must be ordered.", "message": "Operation http verbs must be ordered.",
"ruleId": "path-http-verbs-order", "ruleId": "path-http-verbs-order",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -90,6 +90,6 @@ describe('Common path-http-verbs-order', () => {
config: await makeConfig({ 'path-http-verbs-order': 'error' }), config: await makeConfig({ 'path-http-verbs-order': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -23,10 +23,10 @@ describe('Oas3 path-not-include-query', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some?input", "pointer": "#/paths/~1some?input",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -35,7 +35,7 @@ describe('Oas3 path-not-include-query', () => {
"message": "Don't put query string items in the path, they belong in parameters with \`in: query\`.", "message": "Don't put query string items in the path, they belong in parameters with \`in: query\`.",
"ruleId": "path-not-include-query", "ruleId": "path-not-include-query",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -59,6 +59,6 @@ describe('Oas3 path-not-include-query', () => {
config: await makeConfig({ 'path-not-include-query': 'error' }), config: await makeConfig({ 'path-not-include-query': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -27,7 +27,7 @@ describe('Oas3 path-params-defined', () => {
config: await makeConfig({ 'path-params-defined': 'error' }), config: await makeConfig({ 'path-params-defined': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report on undefined param params', async () => { it('should report on undefined param params', async () => {
@@ -56,10 +56,10 @@ describe('Oas3 path-params-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets~1{a}~1{b}/get/parameters", "pointer": "#/paths/~1pets~1{a}~1{b}/get/parameters",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -68,7 +68,7 @@ describe('Oas3 path-params-defined', () => {
"message": "The operation does not define the path parameter \`{b}\` expected by path \`/pets/{a}/{b}\`.", "message": "The operation does not define the path parameter \`{b}\` expected by path \`/pets/{a}/{b}\`.",
"ruleId": "path-params-defined", "ruleId": "path-params-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -100,10 +100,10 @@ describe('Oas3 path-params-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets~1{a}/parameters/1/name", "pointer": "#/paths/~1pets~1{a}/parameters/1/name",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -112,11 +112,11 @@ describe('Oas3 path-params-defined', () => {
"message": "Path parameter \`d\` is not used in the path \`/pets/{a}\`.", "message": "Path parameter \`d\` is not used in the path \`/pets/{a}\`.",
"ruleId": "path-params-defined", "ruleId": "path-params-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets~1{a}/get/parameters/0/name", "pointer": "#/paths/~1pets~1{a}/get/parameters/0/name",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -125,7 +125,7 @@ describe('Oas3 path-params-defined', () => {
"message": "Path parameter \`c\` is not used in the path \`/pets/{a}\`.", "message": "Path parameter \`c\` is not used in the path \`/pets/{a}\`.",
"ruleId": "path-params-defined", "ruleId": "path-params-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -154,10 +154,10 @@ describe('Oas3 path-params-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets~1{a}/post/parameters", "pointer": "#/paths/~1pets~1{a}/post/parameters",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -166,7 +166,7 @@ describe('Oas3 path-params-defined', () => {
"message": "The operation does not define the path parameter \`{a}\` expected by path \`/pets/{a}\`.", "message": "The operation does not define the path parameter \`{a}\` expected by path \`/pets/{a}\`.",
"ruleId": "path-params-defined", "ruleId": "path-params-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -197,6 +197,6 @@ describe('Oas3 path-params-defined', () => {
config: await makeConfig({ 'path-params-defined': 'error' }), config: await makeConfig({ 'path-params-defined': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -26,10 +26,10 @@ describe('Oas3 paths-kebab-case', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1someTest", "pointer": "#/paths/~1someTest",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -38,7 +38,7 @@ describe('Oas3 paths-kebab-case', () => {
"message": "\`/someTest\` does not use kebab-case.", "message": "\`/someTest\` does not use kebab-case.",
"ruleId": "paths-kebab-case", "ruleId": "paths-kebab-case",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -65,10 +65,10 @@ describe('Oas3 paths-kebab-case', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1some_test", "pointer": "#/paths/~1some_test",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -77,7 +77,7 @@ describe('Oas3 paths-kebab-case', () => {
"message": "\`/some_test\` does not use kebab-case.", "message": "\`/some_test\` does not use kebab-case.",
"ruleId": "paths-kebab-case", "ruleId": "paths-kebab-case",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -103,6 +103,6 @@ describe('Oas3 paths-kebab-case', () => {
'no-path-trailing-slash': 'off', 'no-path-trailing-slash': 'off',
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -28,19 +28,19 @@ describe('Oas3 scalar-property-missing-example', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/User/properties/email", "pointer": "#/components/schemas/User/properties/email",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Scalar property should have \\"example\\" defined.", "message": "Scalar property should have "example" defined.",
"ruleId": "scalar-property-missing-example", "ruleId": "scalar-property-missing-example",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -72,19 +72,19 @@ describe('Oas3.1 scalar-property-missing-example', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/User/properties/email", "pointer": "#/components/schemas/User/properties/email",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Scalar property should have \\"example\\" or \\"examples\\" defined.", "message": "Scalar property should have "example" or "examples" defined.",
"ruleId": "scalar-property-missing-example", "ruleId": "scalar-property-missing-example",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -114,7 +114,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on a scalar property with an examples', async () => { it('should not report on a scalar property with an examples', async () => {
@@ -143,7 +143,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on a non-scalar property missing an example', async () => { it('should not report on a non-scalar property missing an example', async () => {
@@ -177,7 +177,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on a scalar property of binary format missing an example', async () => { it('should not report on a scalar property of binary format missing an example', async () => {
@@ -202,7 +202,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on a scalar property of falsy values', async () => { it('should not report on a scalar property of falsy values', async () => {
@@ -233,7 +233,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on a nullable scalar property values', async () => { it('should not report on a nullable scalar property values', async () => {
@@ -259,6 +259,6 @@ describe('Oas3.1 scalar-property-missing-example', () => {
config: await makeConfig({ 'scalar-property-missing-example': 'error' }), config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -23,10 +23,10 @@ describe('Oas3 security-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get/security/0/some", "pointer": "#/paths/~1pets/get/security/0/some",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -35,7 +35,7 @@ describe('Oas3 security-defined', () => {
"message": "There is no \`some\` security scheme defined.", "message": "There is no \`some\` security scheme defined.",
"ruleId": "security-defined", "ruleId": "security-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -56,7 +56,7 @@ describe('Oas3 security-defined', () => {
config: await makeConfig({ 'security-defined': 'error' }), config: await makeConfig({ 'security-defined': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report if security not defined at all', async () => { it('should report if security not defined at all', async () => {
@@ -77,10 +77,10 @@ describe('Oas3 security-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get", "pointer": "#/paths/~1pets/get",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -89,7 +89,7 @@ describe('Oas3 security-defined', () => {
"message": "Every operation should have security defined on it or on the root level.", "message": "Every operation should have security defined on it or on the root level.",
"ruleId": "security-defined", "ruleId": "security-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -116,10 +116,10 @@ describe('Oas3 security-defined', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get/security/0/some", "pointer": "#/paths/~1pets/get/security/0/some",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -128,11 +128,11 @@ describe('Oas3 security-defined', () => {
"message": "There is no \`some\` security scheme defined.", "message": "There is no \`some\` security scheme defined.",
"ruleId": "security-defined", "ruleId": "security-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1cats/get", "pointer": "#/paths/~1cats/get",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -141,7 +141,7 @@ describe('Oas3 security-defined', () => {
"message": "Every operation should have security defined on it or on the root level.", "message": "Every operation should have security defined on it or on the root level.",
"ruleId": "security-defined", "ruleId": "security-defined",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -170,6 +170,6 @@ describe('Oas3 security-defined', () => {
config: await makeConfig({ 'security-defined': 'error' }), config: await makeConfig({ 'security-defined': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -36,10 +36,10 @@ describe('Oas3 spec-strict-refs', () => {
config: await makeConfig({ 'spec-strict-refs': 'error' }), config: await makeConfig({ 'spec-strict-refs': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/info/$ref", "pointer": "#/info/$ref",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -48,11 +48,11 @@ describe('Oas3 spec-strict-refs', () => {
"message": "Field $ref is not expected here.", "message": "Field $ref is not expected here.",
"ruleId": "spec-strict-refs", "ruleId": "spec-strict-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties/$ref", "pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties/$ref",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -61,7 +61,7 @@ describe('Oas3 spec-strict-refs', () => {
"message": "Field $ref is not expected here.", "message": "Field $ref is not expected here.",
"ruleId": "spec-strict-refs", "ruleId": "spec-strict-refs",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -29,11 +29,11 @@ describe('Oas3 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -42,12 +42,12 @@ describe('Oas3 spec', () => {
"message": "The field \`info\` must be present on this level.", "message": "The field \`info\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/get/parameters/0", "pointer": "#/paths/~1test/get/parameters/0",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -56,7 +56,7 @@ describe('Oas3 spec', () => {
"message": "Must contain at least one of the following fields: schema, content.", "message": "Must contain at least one of the following fields: schema, content.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -89,11 +89,11 @@ describe('Oas3 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -102,12 +102,12 @@ describe('Oas3 spec', () => {
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -116,15 +116,15 @@ describe('Oas3 spec', () => {
"message": "The field \`info\` must be present on this level.", "message": "The field \`info\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": Object { "from": {
"pointer": "#/components/schemas/TestSchema/allOf/0", "pointer": "#/components/schemas/TestSchema/allOf/0",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/TestRequestBody/content", "pointer": "#/components/requestBodies/TestRequestBody/content",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -133,7 +133,7 @@ describe('Oas3 spec', () => {
"message": "Property \`content\` is not expected here.", "message": "Property \`content\` is not expected here.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -161,11 +161,11 @@ describe('Oas3 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -174,12 +174,12 @@ describe('Oas3 spec', () => {
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -188,11 +188,11 @@ describe('Oas3 spec', () => {
"message": "The field \`info\` must be present on this level.", "message": "The field \`info\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable", "pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -201,7 +201,7 @@ describe('Oas3 spec', () => {
"message": "The \`type\` field must be defined when the \`nullable\` field is used.", "message": "The \`type\` field must be defined when the \`nullable\` field is used.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -235,11 +235,11 @@ describe('Oas3 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -248,12 +248,12 @@ describe('Oas3 spec', () => {
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -262,11 +262,11 @@ describe('Oas3 spec', () => {
"message": "The field \`info\` must be present on this level.", "message": "The field \`info\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable", "pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -275,12 +275,12 @@ describe('Oas3 spec', () => {
"message": "The \`type\` field must be defined when the \`nullable\` field is used.", "message": "The \`type\` field must be defined when the \`nullable\` field is used.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/schemas", "pointer": "#/components/requestBodies/schemas",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -289,12 +289,12 @@ describe('Oas3 spec', () => {
"message": "The field \`content\` must be present on this level.", "message": "The field \`content\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/schemas/TestSchema", "pointer": "#/components/requestBodies/schemas/TestSchema",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -303,7 +303,7 @@ describe('Oas3 spec', () => {
"message": "Property \`TestSchema\` is not expected here.", "message": "Property \`TestSchema\` is not expected here.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -326,11 +326,11 @@ describe('Oas3 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -339,12 +339,12 @@ describe('Oas3 spec', () => {
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -353,7 +353,7 @@ describe('Oas3 spec', () => {
"message": "The field \`info\` must be present on this level.", "message": "The field \`info\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -388,20 +388,20 @@ describe('Oas3.1 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/TestSchema/type", "pointer": "#/components/schemas/TestSchema/type",
"reportOnKey": false, "reportOnKey": false,
"source": "", "source": "",
}, },
], ],
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".", "message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -436,20 +436,20 @@ describe('Oas3.1 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/TestSchema/type/1", "pointer": "#/components/schemas/TestSchema/type/1",
"reportOnKey": false, "reportOnKey": false,
"source": "", "source": "",
}, },
], ],
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".", "message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -490,20 +490,20 @@ describe('Oas3.1 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/WrongType/type", "pointer": "#/components/schemas/WrongType/type",
"reportOnKey": false, "reportOnKey": false,
"source": "", "source": "",
}, },
], ],
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".", "message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [ "suggest": [
"object", "object",
"array", "array",
"string", "string",
@@ -513,19 +513,19 @@ describe('Oas3.1 spec', () => {
"null", "null",
], ],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/WrongArrayType/type/0", "pointer": "#/components/schemas/WrongArrayType/type/0",
"reportOnKey": false, "reportOnKey": false,
"source": "", "source": "",
}, },
], ],
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".", "message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [ "suggest": [
"object", "object",
"array", "array",
"string", "string",
@@ -561,11 +561,11 @@ describe('Oas3.1 spec', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -574,12 +574,12 @@ describe('Oas3.1 spec', () => {
"message": "Must contain at least one of the following fields: paths, components, webhooks.", "message": "Must contain at least one of the following fields: paths, components, webhooks.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info", "pointer": "#/info",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -588,12 +588,12 @@ describe('Oas3.1 spec', () => {
"message": "The field \`title\` must be present on this level.", "message": "The field \`title\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info", "pointer": "#/info",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -602,7 +602,7 @@ describe('Oas3.1 spec', () => {
"message": "The field \`version\` must be present on this level.", "message": "The field \`version\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -23,10 +23,10 @@ describe('Oas3 tag-description', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/tags/0/description", "pointer": "#/tags/0/description",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -35,7 +35,7 @@ describe('Oas3 tag-description', () => {
"message": "Tag object should contain \`description\` field.", "message": "Tag object should contain \`description\` field.",
"ruleId": "tag-description", "ruleId": "tag-description",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -60,6 +60,6 @@ describe('Oas3 tag-description', () => {
config: await makeConfig({ 'tag-description': 'error' }), config: await makeConfig({ 'tag-description': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -23,10 +23,10 @@ describe('Oas3 tags-alphabetical', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/tags/0", "pointer": "#/tags/0",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -35,7 +35,7 @@ describe('Oas3 tags-alphabetical', () => {
"message": "The \`tags\` array should be in alphabetical order.", "message": "The \`tags\` array should be in alphabetical order.",
"ruleId": "tags-alphabetical", "ruleId": "tags-alphabetical",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -59,7 +59,7 @@ describe('Oas3 tags-alphabetical', () => {
config: await makeConfig({ 'tags-alphabetical': 'error' }), config: await makeConfig({ 'tags-alphabetical': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should report on tags object if not sorted alphabetically not ignoring case', async () => { it('should report on tags object if not sorted alphabetically not ignoring case', async () => {
@@ -81,10 +81,10 @@ describe('Oas3 tags-alphabetical', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/tags/0", "pointer": "#/tags/0",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -93,7 +93,7 @@ describe('Oas3 tags-alphabetical', () => {
"message": "The \`tags\` array should be in alphabetical order.", "message": "The \`tags\` array should be in alphabetical order.",
"ruleId": "tags-alphabetical", "ruleId": "tags-alphabetical",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -117,6 +117,6 @@ describe('Oas3 tags-alphabetical', () => {
config: await makeConfig({ 'tags-alphabetical': { severity: 'error', ignoreCase: true } }), config: await makeConfig({ 'tags-alphabetical': { severity: 'error', ignoreCase: true } }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -58,39 +58,39 @@ describe('Oas3 assertions', () => {
it('should return the right visitor structure', () => { it('should return the right visitor structure', () => {
const visitors = Assertions(opts as any); const visitors = Assertions(opts as any);
expect(visitors).toMatchInlineSnapshot(` expect(visitors).toMatchInlineSnapshot(`
Array [ [
Object { {
"Operation": Object { "Operation": {
"enter": [Function], "enter": [Function],
}, },
}, },
Object { {
"Operation": Object { "Operation": {
"PathItem": Object { "PathItem": {
"enter": [Function], "enter": [Function],
}, },
"skip": [Function], "skip": [Function],
}, },
}, },
Object { {
"Operation": Object { "Operation": {
"PathItem": Object { "PathItem": {
"enter": [Function], "enter": [Function],
}, },
"skip": [Function], "skip": [Function],
}, },
}, },
Object { {
"Bar": Object { "Bar": {
"Baz": Object { "Baz": {
"Foo": Object { "Foo": {
"enter": [Function], "enter": [Function],
}, },
}, },
}, },
}, },
Object { {
"any": Object { "any": {
"enter": [Function], "enter": [Function],
}, },
}, },

View File

@@ -59,11 +59,11 @@ describe('Oas3 assertions', () => {
); );
expect(visitors).toMatchInlineSnapshot(` expect(visitors).toMatchInlineSnapshot(`
Object { {
"Foo": Object { "Foo": {
"Bar": Object { "Bar": {
"Roof": Object { "Roof": {
"Bar": Object { "Bar": {
"enter": [Function], "enter": [Function],
}, },
"skip": [Function], "skip": [Function],
@@ -100,10 +100,10 @@ describe('Oas3 assertions', () => {
); );
expect(visitors).toMatchInlineSnapshot(` expect(visitors).toMatchInlineSnapshot(`
Object { {
"Operation": Object { "Operation": {
"Responses": Object { "Responses": {
"MediaTypesMap": Object { "MediaTypesMap": {
"enter": [Function], "enter": [Function],
}, },
"skip": [Function], "skip": [Function],

View File

@@ -25,10 +25,10 @@ describe('oas2 boolean-parameter-prefixes', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/parameters/0/name", "pointer": "#/paths/~1test/parameters/0/name",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -37,7 +37,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.", "message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
"ruleId": "boolean-parameter-prefixes", "ruleId": "boolean-parameter-prefixes",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -76,7 +76,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }), config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on boolean param with custom prefix', async () => { it('should not report on boolean param with custom prefix', async () => {
@@ -105,6 +105,6 @@ describe('oas2 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -36,10 +36,10 @@ describe('Oas2 response-contains-header', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/201/headers", "pointer": "#/paths/~1accounts~1{accountId}/get/responses/201/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -66,14 +66,14 @@ describe('Oas2 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"Content-Length\\" header.", "message": "Response object must contain a "Content-Length" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/404/headers", "pointer": "#/paths/~1accounts~1{accountId}/get/responses/404/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -100,10 +100,10 @@ describe('Oas2 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"Content-Length\\" header.", "message": "Response object must contain a "Content-Length" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -142,7 +142,7 @@ describe('Oas2 response-contains-header', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report a response object when there is no `names` section defined', async () => { it('should not report a response object when there is no `names` section defined', async () => {
@@ -169,6 +169,6 @@ describe('Oas2 response-contains-header', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -42,10 +42,10 @@ describe('Oas2 response-contains-property', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/200/schema/properties", "pointer": "#/paths/~1accounts~1{accountId}/get/responses/200/schema/properties",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -78,10 +78,10 @@ describe('Oas2 response-contains-property', () => {
}, },
}, },
], ],
"message": "Response object must contain a top-level \\"id\\" property.", "message": "Response object must contain a top-level "id" property.",
"ruleId": "response-contains-property", "ruleId": "response-contains-property",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -123,7 +123,7 @@ describe('Oas2 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report a response object when there is no `names` section defined', async () => { it('should not report a response object when there is no `names` section defined', async () => {
@@ -150,6 +150,6 @@ describe('Oas2 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -22,8 +22,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/title", "location": "#/info/title",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -52,8 +52,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/description", "location": "#/info/description",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -82,8 +82,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/termsOfService", "location": "#/info/termsOfService",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -115,7 +115,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if in the Contact Object in URL field is not string', async () => { it('should report if in the Contact Object in URL field is not string', async () => {
@@ -142,8 +142,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/contact/url", "location": "#/info/contact/url",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -175,8 +175,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/contact/email", "location": "#/info/contact/email",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -206,7 +206,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if the License Object missing field Name', async () => { it('should report if the License Object missing field Name', async () => {
@@ -231,8 +231,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/license", "location": "#/info/license",
"message": "The field \`name\` must be present on this level.", "message": "The field \`name\` must be present on this level.",
}, },
@@ -263,8 +263,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/license/url", "location": "#/info/license/url",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -293,7 +293,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if the Version field is not provided', async () => { it('should report if the Version field is not provided', async () => {
@@ -315,8 +315,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info", "location": "#/info",
"message": "The field \`version\` must be present on this level.", "message": "The field \`version\` must be present on this level.",
}, },
@@ -344,8 +344,8 @@ describe('OpenAPI Schema 2.0', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/version", "location": "#/info/version",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },

View File

@@ -21,7 +21,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid PUT operation object', async () => { it('should not report of a valid PUT operation object', async () => {
@@ -48,7 +48,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid Post operation object', async () => { it('should not report of a valid Post operation object', async () => {
@@ -82,7 +82,7 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid delete operation object', async () => { it('should not report of a valid delete operation object', async () => {
@@ -118,6 +118,6 @@ describe('OpenAPI Schema 2.0', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -21,7 +21,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if Path object is empty ', async () => { it('should not report if Path object is empty ', async () => {
@@ -38,7 +38,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if Path object is not present ', async () => { it('should report if Path object is not present ', async () => {
@@ -54,8 +54,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/", "location": "#/",
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
}, },
@@ -77,7 +77,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
//Check: no error //Check: no error
@@ -101,8 +101,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/paths/ping", "location": "#/paths/ping",
"message": "Property \`ping\` is not expected here.", "message": "Property \`ping\` is not expected here.",
}, },
@@ -134,7 +134,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
'paths-identical': 'error', 'paths-identical': 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report valid matching URLs', async () => { it('should not report valid matching URLs', async () => {
@@ -161,7 +161,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report in case of ambiguous matching ', async () => { it('should not report in case of ambiguous matching ', async () => {
@@ -188,7 +188,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if Path Item is empty ', async () => { it('should not report if Path Item is empty ', async () => {
@@ -206,7 +206,7 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid Parameter Object', async () => { it('should not report of a valid Parameter Object', async () => {
@@ -240,6 +240,6 @@ describe('OpenAPI Schema', () => {
await lintDoc(source, { await lintDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -30,6 +30,6 @@ describe('Referenceable scalars', () => {
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -42,7 +42,9 @@ import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-
import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length'; import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length';
import { SpecStrictRefs } from '../common/spec-strict-refs'; import { SpecStrictRefs } from '../common/spec-strict-refs';
export const rules = { import type { Oas2RuleSet } from 'core/src/oas-types';
export const rules: Oas2RuleSet<'built-in'> = {
spec: Spec as Oas2Rule, spec: Spec as Oas2Rule,
'no-invalid-schema-examples': NoInvalidSchemaExamples, 'no-invalid-schema-examples': NoInvalidSchemaExamples,
'no-invalid-parameter-examples': NoInvalidParameterExamples, 'no-invalid-parameter-examples': NoInvalidParameterExamples,

View File

@@ -26,10 +26,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test/parameters/0/name", "pointer": "#/paths/~1test/parameters/0/name",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -38,7 +38,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.", "message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
"ruleId": "boolean-parameter-prefixes", "ruleId": "boolean-parameter-prefixes",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -77,7 +77,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }), config: await makeConfig({ 'boolean-parameter-prefixes': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on boolean param with custom prefix', async () => { it('should not report on boolean param with custom prefix', async () => {
@@ -106,6 +106,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -40,10 +40,10 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
@@ -54,7 +54,7 @@ describe('Oas3 component-name-unique', () => {
- /test.yaml#/components/schemas/SomeSchema", - /test.yaml#/components/schemas/SomeSchema",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -95,24 +95,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at: "message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
- /foobar.yaml#/components/schemas/SomeSchema - /foobar.yaml#/components/schemas/SomeSchema
- /SomeSchema.yaml", - /SomeSchema.yaml",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should not report on multiple schemas with different names', async () => { it('should not report on multiple schemas with different names', async () => {
@@ -150,7 +150,7 @@ describe('Oas3 component-name-unique', () => {
additionalDocuments additionalDocuments
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []'); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });
@@ -198,24 +198,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at: "message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
- /foobar.yaml#/components/parameters/ParameterOne - /foobar.yaml#/components/parameters/ParameterOne
- /test.yaml#/components/parameters/ParameterOne", - /test.yaml#/components/parameters/ParameterOne",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should report on multiple parameters with same component name - filename', async () => { it('should report on multiple parameters with same component name - filename', async () => {
@@ -257,24 +257,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at: "message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
- /foobar.yaml#/components/parameters/ParameterOne - /foobar.yaml#/components/parameters/ParameterOne
- /ParameterOne.yaml", - /ParameterOne.yaml",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should not report on multiple parameters with different component names', async () => { it('should not report on multiple parameters with different component names', async () => {
@@ -319,7 +319,7 @@ describe('Oas3 component-name-unique', () => {
additionalDocuments additionalDocuments
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []'); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });
@@ -374,24 +374,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at: "message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
- /foobar.yaml#/components/responses/SuccessResponse - /foobar.yaml#/components/responses/SuccessResponse
- /test.yaml#/components/responses/SuccessResponse", - /test.yaml#/components/responses/SuccessResponse",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should report on multiple responses with same component name - filename', async () => { it('should report on multiple responses with same component name - filename', async () => {
@@ -440,24 +440,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at: "message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
- /foobar.yaml#/components/responses/SuccessResponse - /foobar.yaml#/components/responses/SuccessResponse
- /SuccessResponse.yaml", - /SuccessResponse.yaml",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should not report on multiple responses with different component names', async () => { it('should not report on multiple responses with different component names', async () => {
@@ -509,7 +509,7 @@ describe('Oas3 component-name-unique', () => {
additionalDocuments additionalDocuments
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []'); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });
@@ -561,24 +561,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at: "message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
- /foobar.yaml#/components/requestBodies/MyRequestBody - /foobar.yaml#/components/requestBodies/MyRequestBody
- /test.yaml#/components/requestBodies/MyRequestBody", - /test.yaml#/components/requestBodies/MyRequestBody",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should report on multiple responses with same component name - filename', async () => { it('should report on multiple responses with same component name - filename', async () => {
@@ -628,24 +628,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at: "message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
- /foobar.yaml#/components/requestBodies/MyRequestBody - /foobar.yaml#/components/requestBodies/MyRequestBody
- /MyRequestBody.yaml", - /MyRequestBody.yaml",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should not report on multiple responses with different component names', async () => { it('should not report on multiple responses with different component names', async () => {
@@ -694,7 +694,7 @@ describe('Oas3 component-name-unique', () => {
additionalDocuments additionalDocuments
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []'); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });
@@ -757,39 +757,39 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at: "message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
- /foobar.yaml#/components/requestBodies/MyRequestBody - /foobar.yaml#/components/requestBodies/MyRequestBody
- /test.yaml#/components/requestBodies/MyRequestBody", - /test.yaml#/components/requestBodies/MyRequestBody",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at: "message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
- /foobar.yaml#/components/schemas/SomeSchema - /foobar.yaml#/components/schemas/SomeSchema
- /test.yaml#/components/schemas/SomeSchema", - /test.yaml#/components/schemas/SomeSchema",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
it('should not report if severity is off for specific component type', async () => { it('should not report if severity is off for specific component type', async () => {
@@ -800,24 +800,24 @@ describe('Oas3 component-name-unique', () => {
); );
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": false, "reportOnKey": false,
"source": "/foobar.yaml", "source": "/foobar.yaml",
}, },
], ],
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at: "message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
- /foobar.yaml#/components/requestBodies/MyRequestBody - /foobar.yaml#/components/requestBodies/MyRequestBody
- /test.yaml#/components/requestBodies/MyRequestBody", - /test.yaml#/components/requestBodies/MyRequestBody",
"ruleId": "component-name-unique", "ruleId": "component-name-unique",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
}); });
}); });
}); });

View File

@@ -28,10 +28,10 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers", "pointer": "#/servers",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -40,11 +40,11 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
"message": "Server variable with \`enum\` must be a non-empty array.", "message": "Server variable with \`enum\` must be a non-empty array.",
"ruleId": "no-server-variables-empty-enum", "ruleId": "no-server-variables-empty-enum",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers", "pointer": "#/servers",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -53,7 +53,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
"message": "Server variable define \`enum\` and \`default\`. \`enum\` must include default value", "message": "Server variable define \`enum\` and \`default\`. \`enum\` must include default value",
"ruleId": "no-server-variables-empty-enum", "ruleId": "no-server-variables-empty-enum",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -82,10 +82,10 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers", "pointer": "#/servers",
"reportOnKey": true, "reportOnKey": true,
"source": "", "source": "",
@@ -94,7 +94,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
"message": "Server variable with \`enum\` must be a non-empty array.", "message": "Server variable with \`enum\` must be a non-empty array.",
"ruleId": "no-server-variables-empty-enum", "ruleId": "no-server-variables-empty-enum",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -120,7 +120,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }), config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('oas3-no-server-variables-empty-enum: should be success because variable is empty object', async () => { it('oas3-no-server-variables-empty-enum: should be success because variable is empty object', async () => {
@@ -144,7 +144,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }), config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => { it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => {
@@ -171,7 +171,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }), config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => { it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => {
@@ -200,6 +200,6 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }), config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -24,10 +24,10 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/examples/some/value", "pointer": "#/components/examples/some/value",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -36,7 +36,7 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
"message": "Example object can have either \`value\` or \`externalValue\` fields.", "message": "Example object can have either \`value\` or \`externalValue\` fields.",
"ruleId": "no-example-value-and-externalValue", "ruleId": "no-example-value-and-externalValue",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -60,6 +60,6 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
config: await makeConfig({ 'no-example-value-and-externalValue': 'error' }), config: await makeConfig({ 'no-example-value-and-externalValue': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -37,14 +37,14 @@ describe('no-invalid-media-type-examples', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": Object { "from": {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/a", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/a",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -53,15 +53,15 @@ describe('no-invalid-media-type-examples', () => {
"message": "Example value must conform to the schema: \`a\` property type must be string.", "message": "Example value must conform to the schema: \`a\` property type must be string.",
"ruleId": "no-invalid-media-type-examples", "ruleId": "no-invalid-media-type-examples",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": Object { "from": {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/b", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/b",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -70,7 +70,7 @@ describe('no-invalid-media-type-examples', () => {
"message": "Example value must conform to the schema: \`b\` property type must be number.", "message": "Example value must conform to the schema: \`b\` property type must be number.",
"ruleId": "no-invalid-media-type-examples", "ruleId": "no-invalid-media-type-examples",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -115,14 +115,14 @@ describe('no-invalid-media-type-examples', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": Object { "from": {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/c", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/c",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -131,7 +131,7 @@ describe('no-invalid-media-type-examples', () => {
"message": "Example value must conform to the schema: must NOT have unevaluated properties \`c\`.", "message": "Example value must conform to the schema: must NOT have unevaluated properties \`c\`.",
"ruleId": "no-invalid-media-type-examples", "ruleId": "no-invalid-media-type-examples",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -174,7 +174,7 @@ describe('no-invalid-media-type-examples', () => {
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report on valid example with allowAdditionalProperties and allOf and $ref', async () => { it('should not report on valid example with allowAdditionalProperties and allOf and $ref', async () => {
@@ -223,7 +223,7 @@ describe('no-invalid-media-type-examples', () => {
}), }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not on invalid examples', async () => { it('should not on invalid examples', async () => {
@@ -274,14 +274,14 @@ describe('no-invalid-media-type-examples', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": Object { "from": {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/components/examples/test/value/a", "pointer": "#/components/examples/test/value/a",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -290,7 +290,7 @@ describe('no-invalid-media-type-examples', () => {
"message": "Example value must conform to the schema: \`a\` property type must be string.", "message": "Example value must conform to the schema: \`a\` property type must be string.",
"ruleId": "no-invalid-media-type-examples", "ruleId": "no-invalid-media-type-examples",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -321,7 +321,7 @@ describe('no-invalid-media-type-examples', () => {
config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }), config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if no schema', async () => { it('should not report if no schema', async () => {
@@ -353,7 +353,7 @@ describe('no-invalid-media-type-examples', () => {
config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }), config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should work with cross-file $ref', async () => { it('should work with cross-file $ref', async () => {
@@ -388,7 +388,7 @@ describe('no-invalid-media-type-examples', () => {
config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }), config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not throw for ajv throw', async () => { it('should not throw for ajv throw', async () => {
@@ -417,23 +417,23 @@ describe('no-invalid-media-type-examples', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": Object { "from": {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/schema", "pointer": "#/paths/~1pet/get/responses/200/content/application~1json/schema",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Example validation errored: \\"nullable\\" cannot be used without \\"type\\".", "message": "Example validation errored: "nullable" cannot be used without "type".",
"ruleId": "no-invalid-media-type-examples", "ruleId": "no-invalid-media-type-examples",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -468,6 +468,6 @@ describe('no-invalid-media-type-examples', () => {
config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }), config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -21,10 +21,10 @@ describe('Oas3 oas3-no-server-example.com', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers/0/url", "pointer": "#/servers/0/url",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -33,7 +33,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
"message": "Server \`url\` should not point to example.com or localhost.", "message": "Server \`url\` should not point to example.com or localhost.",
"ruleId": "no-server-example.com", "ruleId": "no-server-example.com",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -55,7 +55,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
config: await makeConfig({ 'no-server-example.com': 'error' }), config: await makeConfig({ 'no-server-example.com': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('oas3-no-server-example.com: should report on server object with "foo.example.com" url', async () => { it('oas3-no-server-example.com: should report on server object with "foo.example.com" url', async () => {
@@ -75,10 +75,10 @@ describe('Oas3 oas3-no-server-example.com', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers/0/url", "pointer": "#/servers/0/url",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -87,7 +87,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
"message": "Server \`url\` should not point to example.com or localhost.", "message": "Server \`url\` should not point to example.com or localhost.",
"ruleId": "no-server-example.com", "ruleId": "no-server-example.com",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -21,10 +21,10 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/servers/0/url", "pointer": "#/servers/0/url",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -33,7 +33,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
"message": "Server \`url\` should not have a trailing slash.", "message": "Server \`url\` should not have a trailing slash.",
"ruleId": "no-server-trailing-slash", "ruleId": "no-server-trailing-slash",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -55,7 +55,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
config: await makeConfig({ 'no-server-trailing-slash': 'error' }), config: await makeConfig({ 'no-server-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('oas3-no-server-trailing-slash: should not report on server object with no trailing slash if the url is root', async () => { it('oas3-no-server-trailing-slash: should not report on server object with no trailing slash if the url is root', async () => {
@@ -74,6 +74,6 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
config: await makeConfig({ 'no-server-trailing-slash': 'error' }), config: await makeConfig({ 'no-server-trailing-slash': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -46,84 +46,84 @@ describe('Oas3 no-unused-components', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/unused", "pointer": "#/components/parameters/unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"unused\\" is never used.", "message": "Component: "unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/Unused", "pointer": "#/components/schemas/Unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"Unused\\" is never used.", "message": "Component: "Unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/responses/unused", "pointer": "#/components/responses/unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"unused\\" is never used.", "message": "Component: "unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/examples/unused", "pointer": "#/components/examples/unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"unused\\" is never used.", "message": "Component: "unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/requestBodies/unused", "pointer": "#/components/requestBodies/unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"unused\\" is never used.", "message": "Component: "unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/headers/unused", "pointer": "#/components/headers/unused",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
], ],
"message": "Component: \\"unused\\" is never used.", "message": "Component: "unused" is never used.",
"ruleId": "no-unused-components", "ruleId": "no-unused-components",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -35,10 +35,10 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }), config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get/responses/400", "pointer": "#/paths/~1pets/get/responses/400",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -47,7 +47,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
"message": "Response \`4xx\` must have content-type \`application/problem+json\`.", "message": "Response \`4xx\` must have content-type \`application/problem+json\`.",
"ruleId": "operation-4xx-problem-details-rfc7807", "ruleId": "operation-4xx-problem-details-rfc7807",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -82,10 +82,10 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }), config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema/properties/type", "pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema/properties/type",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -94,7 +94,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
"message": "SchemaProperties object should contain \`type\` field.", "message": "SchemaProperties object should contain \`type\` field.",
"ruleId": "operation-4xx-problem-details-rfc7807", "ruleId": "operation-4xx-problem-details-rfc7807",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -125,10 +125,10 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }), config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema", "pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -137,7 +137,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
"message": "MediaType object should contain \`schema\` field.", "message": "MediaType object should contain \`schema\` field.",
"ruleId": "operation-4xx-problem-details-rfc7807", "ruleId": "operation-4xx-problem-details-rfc7807",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -34,10 +34,10 @@ describe('Oas3 response-contains-header', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/200/headers", "pointer": "#/paths/~1store~1subscribe/post/responses/200/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -61,10 +61,10 @@ describe('Oas3 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"Content-Length\\" header.", "message": "Response object must contain a "Content-Length" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -117,10 +117,10 @@ describe('Oas3 response-contains-header', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/200/headers", "pointer": "#/paths/~1store~1subscribe/post/responses/200/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -159,14 +159,14 @@ describe('Oas3 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"x-request-id\\" header.", "message": "Response object must contain a "x-request-id" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/400/headers", "pointer": "#/paths/~1store~1subscribe/post/responses/400/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -205,10 +205,10 @@ describe('Oas3 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"Content-Length\\" header.", "message": "Response object must contain a "Content-Length" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -268,7 +268,7 @@ describe('Oas3 response-contains-header', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report response object containing header name upper cased', async () => { it('should not report response object containing header name upper cased', async () => {
@@ -300,7 +300,7 @@ describe('Oas3 response-contains-header', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report response object containing header name in the rule upper cased', async () => { it('should not report response object containing header name in the rule upper cased', async () => {
@@ -332,7 +332,7 @@ describe('Oas3 response-contains-header', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should report even if the response is null', async () => { it('should report even if the response is null', async () => {
@@ -360,10 +360,10 @@ describe('Oas3 response-contains-header', () => {
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1test~1/put/responses/200/headers", "pointer": "#/paths/~1test~1/put/responses/200/headers",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -378,10 +378,10 @@ describe('Oas3 response-contains-header', () => {
}, },
}, },
], ],
"message": "Response object must contain a \\"X-Test-Header\\" header.", "message": "Response object must contain a "X-Test-Header" header.",
"ruleId": "response-contains-header", "ruleId": "response-contains-header",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -34,10 +34,10 @@ describe('Oas3 response-contains-property', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties", "pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -62,10 +62,10 @@ describe('Oas3 response-contains-property', () => {
}, },
}, },
], ],
"message": "Response object must contain a top-level \\"id\\" property.", "message": "Response object must contain a top-level "id" property.",
"ruleId": "response-contains-property", "ruleId": "response-contains-property",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -110,10 +110,10 @@ describe('Oas3 response-contains-property', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties", "pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -147,14 +147,14 @@ describe('Oas3 response-contains-property', () => {
}, },
}, },
], ],
"message": "Response object must contain a top-level \\"id\\" property.", "message": "Response object must contain a top-level "id" property.",
"ruleId": "response-contains-property", "ruleId": "response-contains-property",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/400/content/application~1json/schema/properties", "pointer": "#/paths/~1store~1subscribe/post/responses/400/content/application~1json/schema/properties",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -188,10 +188,10 @@ describe('Oas3 response-contains-property', () => {
}, },
}, },
], ],
"message": "Response object must contain a top-level \\"error\\" property.", "message": "Response object must contain a top-level "error" property.",
"ruleId": "response-contains-property", "ruleId": "response-contains-property",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -237,7 +237,7 @@ describe('Oas3 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report a response object when schema type is not object', async () => { it('should not report a response object when schema type is not object', async () => {
@@ -265,7 +265,7 @@ describe('Oas3 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report response objects when there is no `names` field specified', async () => { it('should not report response objects when there is no `names` field specified', async () => {
@@ -305,7 +305,7 @@ describe('Oas3 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report response objects for 204 status code', async () => { it('should not report response objects for 204 status code', async () => {
@@ -337,7 +337,7 @@ describe('Oas3 response-contains-property', () => {
}, },
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should report response objects when there are no properties', async () => { it('should report response objects when there are no properties', async () => {
@@ -367,10 +367,10 @@ describe('Oas3 response-contains-property', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/paths/~1store~1subscribe/post/responses/200/content/application~1json/schema/properties", "pointer": "#/paths/~1store~1subscribe/post/responses/200/content/application~1json/schema/properties",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -392,10 +392,10 @@ describe('Oas3 response-contains-property', () => {
}, },
}, },
], ],
"message": "Response object must contain a top-level \\"id\\" property.", "message": "Response object must contain a top-level "id" property.",
"ruleId": "response-contains-property", "ruleId": "response-contains-property",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -36,10 +36,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/my Param", "pointer": "#/components/parameters/my Param",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -68,14 +68,14 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}, },
}, },
], ],
"message": "The map key in parameters \\"my Param\\" does not match the regular expression \\"^[a-zA-Z0-9\\\\.\\\\-_]+$\\"", "message": "The map key in parameters "my Param" does not match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"",
"ruleId": "spec-components-invalid-map-name", "ruleId": "spec-components-invalid-map-name",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/schemas/first schema", "pointer": "#/components/schemas/first schema",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -104,14 +104,14 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}, },
}, },
], ],
"message": "The map key in schemas \\"first schema\\" does not match the regular expression \\"^[a-zA-Z0-9\\\\.\\\\-_]+$\\"", "message": "The map key in schemas "first schema" does not match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"",
"ruleId": "spec-components-invalid-map-name", "ruleId": "spec-components-invalid-map-name",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/responses/400 status", "pointer": "#/components/responses/400 status",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -140,14 +140,14 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}, },
}, },
], ],
"message": "The map key in responses \\"400 status\\" does not match the regular expression \\"^[a-zA-Z0-9\\\\.\\\\-_]+$\\"", "message": "The map key in responses "400 status" does not match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"",
"ruleId": "spec-components-invalid-map-name", "ruleId": "spec-components-invalid-map-name",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/examples/invalid identifier", "pointer": "#/components/examples/invalid identifier",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -176,10 +176,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}, },
}, },
], ],
"message": "The map key in examples \\"invalid identifier\\" does not match the regular expression \\"^[a-zA-Z0-9\\\\.\\\\-_]+$\\"", "message": "The map key in examples "invalid identifier" does not match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"",
"ruleId": "spec-components-invalid-map-name", "ruleId": "spec-components-invalid-map-name",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -212,7 +212,7 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}), }),
}); });
expect(results).toMatchInlineSnapshot(`Array []`); expect(results).toMatchInlineSnapshot(`[]`);
}); });
it('should not report invalid keys inside nested examples', async () => { it('should not report invalid keys inside nested examples', async () => {
@@ -240,10 +240,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}); });
expect(results).toMatchInlineSnapshot(` expect(results).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/components/parameters/my Param", "pointer": "#/components/parameters/my Param",
"reportOnKey": true, "reportOnKey": true,
"source": Source { "source": Source {
@@ -265,10 +265,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
}, },
}, },
], ],
"message": "The map key in parameters \\"my Param\\" does not match the regular expression \\"^[a-zA-Z0-9\\\\.\\\\-_]+$\\"", "message": "The map key in parameters "my Param" does not match the regular expression "^[a-zA-Z0-9\\.\\-_]+$"",
"ruleId": "spec-components-invalid-map-name", "ruleId": "spec-components-invalid-map-name",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -37,5 +37,5 @@ it('should not fail on valid callbacks object', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });

View File

@@ -25,8 +25,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/title", "location": "#/info/title",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -58,8 +58,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/description", "location": "#/info/description",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -91,8 +91,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/termsOfService", "location": "#/info/termsOfService",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -127,7 +127,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if in the Contact Object in URL field is not string', async () => { it('should report if in the Contact Object in URL field is not string', async () => {
@@ -157,8 +157,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/contact/url", "location": "#/info/contact/url",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -193,8 +193,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/contact/email", "location": "#/info/contact/email",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -227,7 +227,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if the License Object missing field Name', async () => { it('should report if the License Object missing field Name', async () => {
@@ -255,8 +255,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/license", "location": "#/info/license",
"message": "The field \`name\` must be present on this level.", "message": "The field \`name\` must be present on this level.",
}, },
@@ -290,8 +290,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/license/url", "location": "#/info/license/url",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -323,7 +323,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if the Version field is not provided', async () => { it('should report if the Version field is not provided', async () => {
@@ -348,8 +348,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info", "location": "#/info",
"message": "The field \`version\` must be present on this level.", "message": "The field \`version\` must be present on this level.",
}, },
@@ -380,8 +380,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/info/version", "location": "#/info/version",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },

View File

@@ -24,7 +24,7 @@ it('should not report if summary field is valid', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if summary field is not string ', async () => { it('should report if summary field is not string ', async () => {
@@ -51,8 +51,8 @@ it('should report if summary field is not string ', async () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/paths/~1ping/summary", "location": "#/paths/~1ping/summary",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -83,7 +83,7 @@ it('should not report if description field is valid', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if description field is not string', async () => { it('should report if description field is not string', async () => {
@@ -110,8 +110,8 @@ it('should report if description field is not string', async () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/paths/~1ping/description", "location": "#/paths/~1ping/description",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -141,7 +141,7 @@ it('should not report of a valid GET operation object', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid PUT operation object', async () => { it('should not report of a valid PUT operation object', async () => {
@@ -171,7 +171,7 @@ it('should not report of a valid PUT operation object', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid Post operation object', async () => { it('should not report of a valid Post operation object', async () => {
@@ -209,7 +209,7 @@ it('should not report of a valid Post operation object', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid delete operation object', async () => { it('should not report of a valid delete operation object', async () => {
@@ -249,5 +249,5 @@ it('should not report of a valid delete operation object', async () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });

View File

@@ -24,7 +24,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if Path object is empty ', async () => { it('should not report if Path object is empty ', async () => {
@@ -44,7 +44,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if Path object is not present ', async () => { it('should report if Path object is not present ', async () => {
@@ -63,8 +63,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/", "location": "#/",
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
}, },
@@ -89,7 +89,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
//Check: no error //Check: no error
@@ -116,8 +116,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/paths/ping", "location": "#/paths/ping",
"message": "Property \`ping\` is not expected here.", "message": "Property \`ping\` is not expected here.",
}, },
@@ -153,8 +153,8 @@ describe('OpenAPI Schema', () => {
'no-identical-paths': 'error', 'no-identical-paths': 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/paths/~1pets~1{name}", "location": "#/paths/~1pets~1{name}",
"message": "The path already exists which differs only by path parameter name(s): \`/pets/{petId}\` and \`/pets/{name}\`.", "message": "The path already exists which differs only by path parameter name(s): \`/pets/{petId}\` and \`/pets/{name}\`.",
}, },
@@ -189,7 +189,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report in case of ambiguous matching ', async () => { it('should not report in case of ambiguous matching ', async () => {
@@ -219,7 +219,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if Path Item is empty ', async () => { it('should not report if Path Item is empty ', async () => {
@@ -240,7 +240,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report of a valid Parameter Object', async () => { it('should not report of a valid Parameter Object', async () => {
@@ -279,6 +279,6 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -35,7 +35,7 @@ describe('Referenceable scalars', () => {
}) })
), ),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
it('should not report invalid $ref on example with doNotResolveExamples', async () => { it('should not report invalid $ref on example with doNotResolveExamples', async () => {
@@ -72,6 +72,6 @@ describe('Referenceable scalars', () => {
}) })
), ),
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -25,7 +25,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report on empty server URL', async () => { it('should report on empty server URL', async () => {
@@ -51,8 +51,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/url", "location": "#/servers/0/url",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -83,8 +83,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0", "location": "#/servers/0",
"message": "The field \`url\` must be present on this level.", "message": "The field \`url\` must be present on this level.",
}, },
@@ -116,8 +116,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/description", "location": "#/servers/0/description",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -147,7 +147,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if fields type in servers are not array', async () => { it('should report if fields type in servers are not array', async () => {
@@ -173,8 +173,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers", "location": "#/servers",
"message": "Expected type \`ServerList\` (array) but got \`object\`", "message": "Expected type \`ServerList\` (array) but got \`object\`",
}, },
@@ -209,7 +209,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if variables are used for a server configuration', async () => { it('should not report if variables are used for a server configuration', async () => {
@@ -244,7 +244,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should report if array in enum is empty', async () => { it('should report if array in enum is empty', async () => {
@@ -279,8 +279,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/variables/port/enum", "location": "#/servers/0/variables/port/enum",
"message": "Expected type \`array\` but got \`null\`.", "message": "Expected type \`array\` but got \`null\`.",
}, },
@@ -319,8 +319,8 @@ describe('OpenAPI Schema', () => {
'no-undefined-server-variable': 'error', 'no-undefined-server-variable': 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/url", "location": "#/servers/0/url",
"message": "The \`basePath\` variable is not defined in the \`variables\` objects.", "message": "The \`basePath\` variable is not defined in the \`variables\` objects.",
}, },
@@ -359,12 +359,12 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/variables/username", "location": "#/servers/0/variables/username",
"message": "The field \`default\` must be present on this level.", "message": "The field \`default\` must be present on this level.",
}, },
Object { {
"location": "#/servers/0/variables/port", "location": "#/servers/0/variables/port",
"message": "The field \`default\` must be present on this level.", "message": "The field \`default\` must be present on this level.",
}, },
@@ -405,8 +405,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/variables/username/default", "location": "#/servers/0/variables/username/default",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -448,8 +448,8 @@ describe('OpenAPI Schema', () => {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Array [ [
Object { {
"location": "#/servers/0/variables/username/description", "location": "#/servers/0/variables/username/description",
"message": "Expected type \`string\` but got \`null\`.", "message": "Expected type \`string\` but got \`null\`.",
}, },
@@ -476,7 +476,7 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
it('should not report if servers property is an empty array', async () => { it('should not report if servers property is an empty array', async () => {
@@ -500,6 +500,6 @@ describe('OpenAPI Schema', () => {
await validateDoc(source, { await validateDoc(source, {
spec: 'error', spec: 'error',
}) })
).toMatchInlineSnapshot(`Array []`); ).toMatchInlineSnapshot(`[]`);
}); });
}); });

View File

@@ -45,11 +45,11 @@ describe('Oas3 Structural visitor basic', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/contact/url", "pointer": "#/info/contact/url",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -58,12 +58,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`string\` but got \`array\`.", "message": "Expected type \`string\` but got \`array\`.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/contact/email", "pointer": "#/info/contact/email",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -72,12 +72,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`string\` but got \`boolean\`.", "message": "Expected type \`string\` but got \`boolean\`.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/license", "pointer": "#/info/license",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -86,15 +86,15 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`License\` (object) but got \`string\`", "message": "Expected type \`License\` (object) but got \`string\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": Object { "from": {
"pointer": "#/servers/0/url", "pointer": "#/servers/0/url",
"source": "foobar.yaml", "source": "foobar.yaml",
}, },
"location": Array [ "location": [
Object { {
"pointer": "#/servers/0/variables/a", "pointer": "#/servers/0/variables/a",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -103,12 +103,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "The \`a\` variable is not used in the server's \`url\` field.", "message": "The \`a\` variable is not used in the server's \`url\` field.",
"ruleId": "no-undefined-server-variable", "ruleId": "no-undefined-server-variable",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/servers/0/variables/a/enum/0", "pointer": "#/servers/0/variables/a/enum/0",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -117,12 +117,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`string\` but got \`integer\`.", "message": "Expected type \`string\` but got \`integer\`.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/tags/0", "pointer": "#/tags/0",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -131,12 +131,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`Tag\` (object) but got \`number\`", "message": "Expected type \`Tag\` (object) but got \`number\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/tags/1", "pointer": "#/tags/1",
"reportOnKey": false, "reportOnKey": false,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -145,7 +145,7 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Expected type \`Tag\` (object) but got \`string\`", "message": "Expected type \`Tag\` (object) but got \`string\`",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -179,11 +179,11 @@ describe('Oas3 Structural visitor basic', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/components1", "pointer": "#/components1",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -192,13 +192,13 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Property \`components1\` is not expected here.", "message": "Property \`components1\` is not expected here.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [ "suggest": [
"components", "components",
], ],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/openapi", "pointer": "#/openapi",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -207,12 +207,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Servers must be present.", "message": "Servers must be present.",
"ruleId": "no-empty-servers", "ruleId": "no-empty-servers",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info/contact/test", "pointer": "#/info/contact/test",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -221,7 +221,7 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Property \`test\` is not expected here.", "message": "Property \`test\` is not expected here.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);
@@ -250,11 +250,11 @@ describe('Oas3 Structural visitor basic', () => {
}); });
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
Array [ [
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/", "pointer": "#/",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -263,11 +263,11 @@ describe('Oas3 Structural visitor basic', () => {
"message": "The field \`paths\` must be present on this level.", "message": "The field \`paths\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"location": Array [ "location": [
Object { {
"pointer": "#/openapi", "pointer": "#/openapi",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -276,12 +276,12 @@ describe('Oas3 Structural visitor basic', () => {
"message": "Servers must be present.", "message": "Servers must be present.",
"ruleId": "no-empty-servers", "ruleId": "no-empty-servers",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
Object { {
"from": undefined, "from": undefined,
"location": Array [ "location": [
Object { {
"pointer": "#/info", "pointer": "#/info",
"reportOnKey": true, "reportOnKey": true,
"source": "foobar.yaml", "source": "foobar.yaml",
@@ -290,7 +290,7 @@ describe('Oas3 Structural visitor basic', () => {
"message": "The field \`title\` must be present on this level.", "message": "The field \`title\` must be present on this level.",
"ruleId": "spec", "ruleId": "spec",
"severity": "error", "severity": "error",
"suggest": Array [], "suggest": [],
}, },
] ]
`); `);

View File

@@ -53,7 +53,7 @@ import { RequiredStringPropertyMissingMinLength } from '../common/required-strin
import { SpecStrictRefs } from '../common/spec-strict-refs'; import { SpecStrictRefs } from '../common/spec-strict-refs';
import { ComponentNameUnique } from './component-name-unique'; import { ComponentNameUnique } from './component-name-unique';
export const rules = { export const rules: Oas3RuleSet<'built-in'> = {
spec: Spec, spec: Spec,
'info-contact': InfoContact, 'info-contact': InfoContact,
'info-license': InfoLicense, 'info-license': InfoLicense,
@@ -64,7 +64,6 @@ export const rules = {
assertions: Assertions, assertions: Assertions,
'operation-operationId-unique': OperationIdUnique, 'operation-operationId-unique': OperationIdUnique,
'operation-parameters-unique': OperationParametersUnique, 'operation-parameters-unique': OperationParametersUnique,
'path-parameters-defined': PathParamsDefined,
'operation-tag-defined': OperationTagDefined, 'operation-tag-defined': OperationTagDefined,
'no-example-value-and-externalValue': NoExampleValueAndExternalValue, 'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
'no-enum-type-mismatch': NoEnumTypeMismatch, 'no-enum-type-mismatch': NoEnumTypeMismatch,
@@ -81,6 +80,7 @@ export const rules = {
'operation-description': OperationDescription, 'operation-description': OperationDescription,
'no-unused-components': NoUnusedComponents, 'no-unused-components': NoUnusedComponents,
'path-not-include-query': PathNotIncludeQuery, 'path-not-include-query': PathNotIncludeQuery,
'path-parameters-defined': PathParamsDefined,
'path-params-defined': PathParamsDefined, 'path-params-defined': PathParamsDefined,
'parameter-description': ParameterDescription, 'parameter-description': ParameterDescription,
'operation-singular-tag': OperationSingularTag, 'operation-singular-tag': OperationSingularTag,
@@ -108,6 +108,6 @@ export const rules = {
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength, 'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
'spec-strict-refs': SpecStrictRefs, 'spec-strict-refs': SpecStrictRefs,
'component-name-unique': ComponentNameUnique, 'component-name-unique': ComponentNameUnique,
} as Oas3RuleSet; };
export const preprocessors = {}; export const preprocessors = {};

View File

@@ -4,64 +4,96 @@ import { NodeType, listOf } from '.';
import { Oas3_1Types } from './oas3_1'; import { Oas3_1Types } from './oas3_1';
import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils'; import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils';
const builtInRulesList = [ const builtInCommonRules = [
'spec', 'spec',
'info-contact', 'info-contact',
'info-license', 'operation-operationId',
'tag-description',
'tags-alphabetical',
] as const;
export type BuiltInCommonRuleId = typeof builtInCommonRules[number];
const builtInCommonOASRules = [
'info-license-url', 'info-license-url',
'info-license',
'no-ambiguous-paths',
'no-enum-type-mismatch',
'no-http-verbs-in-paths',
'no-identical-paths',
'no-invalid-parameter-examples',
'no-invalid-schema-examples',
'no-path-trailing-slash',
'operation-2xx-response', 'operation-2xx-response',
'operation-4xx-response', 'operation-4xx-response',
'operation-4xx-problem-details-rfc7807',
'assertions',
'operation-operationId-unique',
'operation-parameters-unique',
'path-parameters-defined',
'operation-tag-defined',
'no-example-value-and-externalValue',
'no-enum-type-mismatch',
'no-path-trailing-slash',
'no-empty-servers',
'path-declaration-must-exist',
'operation-operationId-url-safe',
'operation-operationId',
'operation-summary',
'tags-alphabetical',
'no-server-example.com',
'no-server-trailing-slash',
'tag-description',
'operation-description', 'operation-description',
'no-unused-components', 'operation-operationId-unique',
'operation-operationId-url-safe',
'operation-parameters-unique',
'operation-singular-tag',
'operation-summary',
'operation-tag-defined',
'parameter-description',
'path-declaration-must-exist',
'path-excludes-patterns',
'path-http-verbs-order',
'path-not-include-query', 'path-not-include-query',
'path-params-defined', 'path-params-defined',
'parameter-description', 'path-parameters-defined',
'operation-singular-tag',
'security-defined',
'no-unresolved-refs',
'paths-kebab-case',
'boolean-parameter-prefixes',
'path-http-verbs-order',
'no-invalid-media-type-examples',
'no-identical-paths',
'no-ambiguous-paths',
'no-undefined-server-variable',
'no-server-variables-empty-enum',
'no-http-verbs-in-paths',
'path-excludes-patterns',
'request-mime-type',
'response-mime-type',
'path-segment-plural', 'path-segment-plural',
'no-invalid-schema-examples', 'paths-kebab-case',
'no-invalid-parameter-examples',
'response-contains-header',
'response-contains-property',
'scalar-property-missing-example',
'spec-components-invalid-map-name',
'required-string-property-missing-min-length', 'required-string-property-missing-min-length',
'response-contains-header',
'scalar-property-missing-example',
'security-defined',
'spec-strict-refs', 'spec-strict-refs',
'no-unresolved-refs',
] as const;
export type BuiltInCommonOASRuleId = typeof builtInCommonOASRules[number];
const builtInOAS2Rules = [
'boolean-parameter-prefixes',
'request-mime-type',
'response-contains-property',
'response-mime-type',
] as const;
export type BuiltInOAS2RuleId = typeof builtInOAS2Rules[number];
const builtInOAS3Rules = [
'boolean-parameter-prefixes',
'component-name-unique', 'component-name-unique',
'channels-kebab-case', 'no-empty-servers',
'no-channel-trailing-slash', 'no-example-value-and-externalValue',
]; 'no-invalid-media-type-examples',
'no-server-example.com',
'no-server-trailing-slash',
'no-server-variables-empty-enum',
'no-undefined-server-variable',
'no-unused-components',
'operation-4xx-problem-details-rfc7807',
'request-mime-type',
'response-contains-property',
'response-mime-type',
'spec-components-invalid-map-name',
] as const;
export type BuiltInOAS3RuleId = typeof builtInOAS3Rules[number];
const builtInAsync2Rules = ['channels-kebab-case', 'no-channel-trailing-slash'] as const;
export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
const builtInRules = [
...builtInCommonRules,
...builtInCommonOASRules,
...builtInOAS2Rules,
...builtInOAS3Rules,
...builtInAsync2Rules,
] as const;
type BuiltInRuleId = typeof builtInRules[number];
const nodeTypesList = [ const nodeTypesList = [
'any', 'any',
@@ -138,14 +170,17 @@ const ConfigStyleguide: NodeType = {
oas2Rules: 'Rules', oas2Rules: 'Rules',
oas3_0Rules: 'Rules', oas3_0Rules: 'Rules',
oas3_1Rules: 'Rules', oas3_1Rules: 'Rules',
async2Rules: 'Rules',
preprocessors: { type: 'object' }, preprocessors: { type: 'object' },
oas2Preprocessors: { type: 'object' }, oas2Preprocessors: { type: 'object' },
oas3_0Preprocessors: { type: 'object' }, oas3_0Preprocessors: { type: 'object' },
oas3_1Preprocessors: { type: 'object' }, oas3_1Preprocessors: { type: 'object' },
async2Preprocessors: { type: 'object' },
decorators: { type: 'object' }, decorators: { type: 'object' },
oas2Decorators: { type: 'object' }, oas2Decorators: { type: 'object' },
oas3_0Decorators: { type: 'object' }, oas3_0Decorators: { type: 'object' },
oas3_1Decorators: { type: 'object' }, oas3_1Decorators: { type: 'object' },
async2Decorators: { type: 'object' },
}, },
}; };
@@ -243,7 +278,7 @@ const Rules: NodeType = {
} else if (key.startsWith('assert/')) { } else if (key.startsWith('assert/')) {
// keep the old assert/ prefix as an alias // keep the old assert/ prefix as an alias
return 'Assert'; return 'Assert';
} else if (builtInRulesList.includes(key) || isCustomRuleId(key)) { } else if (builtInRules.includes(key as BuiltInRuleId) || isCustomRuleId(key)) {
if (typeof value === 'string') { if (typeof value === 'string') {
return { enum: ['error', 'warn', 'off'] }; return { enum: ['error', 'warn', 'off'] };
} else { } else {

View File

@@ -73,11 +73,11 @@ type VisitObject<T> = {
skip?: SkipFunction<T>; skip?: SkipFunction<T>;
}; };
type NestedVisitObject<T, P> = VisitObject<T> & NestedVisitor<P>; export type NestedVisitObject<T, P> = VisitObject<T> & NestedVisitor<P>;
type VisitFunctionOrObject<T> = VisitFunction<T> | VisitObject<T>; type VisitFunctionOrObject<T> = VisitFunction<T> | VisitObject<T>;
type VisitorNode<T> = { export type VisitorNode<T> = {
ruleId: string; ruleId: string;
severity: ProblemSeverity; severity: ProblemSeverity;
context: VisitorLevelContext | VisitorSkippedLevelContext; context: VisitorLevelContext | VisitorSkippedLevelContext;
@@ -113,7 +113,7 @@ export type VisitorSkippedLevelContext = {
seen: Set<any>; seen: Set<any>;
}; };
type NormalizeVisitor<Fn> = Fn extends VisitFunction<infer T> ? VisitorNode<T> : never; export type NormalizeVisitor<Fn> = Fn extends VisitFunction<infer T> ? VisitorNode<T> : never;
export type BaseVisitor = { export type BaseVisitor = {
any?: any?:

View File

@@ -4,6 +4,9 @@ import type {
NormalizedOasVisitors, NormalizedOasVisitors,
VisitorSkippedLevelContext, VisitorSkippedLevelContext,
VisitFunction, VisitFunction,
BaseVisitor,
NormalizeVisitor,
VisitorNode,
} from './visitors'; } from './visitors';
import type { ResolvedRefMap, Document } from './resolve'; import type { ResolvedRefMap, Document } from './resolve';
import type { NormalizedNodeType } from './types'; import type { NormalizedNodeType } from './types';
@@ -15,13 +18,23 @@ import { ResolveError, YamlParseError, Source, makeRefId } from './resolve';
import { SpecVersion } from './oas-types'; import { SpecVersion } from './oas-types';
import { isNamedType, SpecExtension } from './types'; import { isNamedType, SpecExtension } from './types';
type NonUndefined = string | number | boolean | symbol | bigint | object | Record<string, any>; export type NonUndefined =
| string
| number
| boolean
| symbol
| bigint
| object
| Record<string, any>;
export type ResolveResult<T extends NonUndefined> = export type ResolveResult<T extends NonUndefined> =
| { node: T; location: Location; error?: ResolveError | YamlParseError } | { node: T; location: Location; error?: ResolveError | YamlParseError }
| { node: undefined; location: undefined; error?: ResolveError | YamlParseError }; | { node: undefined; location: undefined; error?: ResolveError | YamlParseError };
export type ResolveFn = <T>(node: Referenced<T>, from?: string) => ResolveResult<T>; export type ResolveFn = <T extends NonUndefined>(
node: Referenced<T>,
from?: string
) => ResolveResult<T>;
export type UserContext = { export type UserContext = {
report(problem: Problem): void; report(problem: Problem): void;
@@ -85,7 +98,7 @@ export type WalkContext = {
}; };
function collectParents(ctx: VisitorLevelContext) { function collectParents(ctx: VisitorLevelContext) {
const parents: Record<string, any> = {}; const parents: Record<string, unknown> = {};
while (ctx.parent) { while (ctx.parent) {
parents[ctx.parent.type.name] = ctx.parent.activatedOn?.value.node; parents[ctx.parent.type.name] = ctx.parent.activatedOn?.value.node;
ctx = ctx.parent; ctx = ctx.parent;
@@ -104,7 +117,7 @@ function collectParentsLocations(ctx: VisitorLevelContext) {
return locations; return locations;
} }
export function walkDocument<T>(opts: { export function walkDocument<T extends BaseVisitor>(opts: {
document: Document; document: Document;
rootType: NormalizedNodeType; rootType: NormalizedNodeType;
normalizedVisitors: NormalizedOasVisitors<T>; normalizedVisitors: NormalizedOasVisitors<T>;
@@ -112,7 +125,7 @@ export function walkDocument<T>(opts: {
ctx: WalkContext; ctx: WalkContext;
}) { }) {
const { document, rootType, normalizedVisitors, resolvedRefMap, ctx } = opts; const { document, rootType, normalizedVisitors, resolvedRefMap, ctx } = opts;
const seenNodesPerType: Record<string, Set<any>> = {}; const seenNodesPerType: Record<string, Set<unknown>> = {};
const ignoredNodes = new Set<string>(); const ignoredNodes = new Set<string>();
walkNode(document.parsed, rootType, new Location(document.source, '#/'), undefined, ''); walkNode(document.parsed, rootType, new Location(document.source, '#/'), undefined, '');
@@ -185,7 +198,7 @@ export function walkDocument<T>(opts: {
const anyEnterVisitors = normalizedVisitors.any.enter; const anyEnterVisitors = normalizedVisitors.any.enter;
const currentEnterVisitors = anyEnterVisitors.concat( const currentEnterVisitors = anyEnterVisitors.concat(
normalizedVisitors[type.name]?.enter || [] (normalizedVisitors[type.name]?.enter as NormalizeVisitor<VisitorNode<unknown>[]>) || []
); );
const activatedContexts: Array<VisitorSkippedLevelContext | VisitorLevelContext> = []; const activatedContexts: Array<VisitorSkippedLevelContext | VisitorLevelContext> = [];
@@ -328,7 +341,7 @@ export function walkDocument<T>(opts: {
if (context.isSkippedLevel) { if (context.isSkippedLevel) {
context.seen.delete(resolvedNode); context.seen.delete(resolvedNode);
} else { } else {
context.activatedOn = popStack(context.activatedOn) as any; context.activatedOn = popStack(context.activatedOn);
if (context.parent) { if (context.parent) {
let ctx: VisitorLevelContext | null = context.parent; let ctx: VisitorLevelContext | null = context.parent;
while (ctx) { while (ctx) {
@@ -378,9 +391,9 @@ export function walkDocument<T>(opts: {
// returns true ignores all the next visitors on the specific node // returns true ignores all the next visitors on the specific node
function visitWithContext( function visitWithContext(
visit: VisitFunction<any>, visit: VisitFunction<unknown>,
resolvedNode: any, resolvedNode: unknown,
node: any, node: unknown,
context: VisitorLevelContext, context: VisitorLevelContext,
ruleId: string, ruleId: string,
severity: ProblemSeverity severity: ProblemSeverity