mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
chore: update typescript to v5 and synchronise predefined rulesets through strict typing (#1308)
This commit is contained in:
@@ -21,6 +21,7 @@ rules:
|
||||
'@typescript-eslint/no-empty-function': off
|
||||
'@typescript-eslint/no-inferrable-types': off
|
||||
'@typescript-eslint/ban-types': warn
|
||||
'@typescript-eslint/no-explicit-any': warn # TODO: make it error!
|
||||
no-prototype-builtins: off
|
||||
no-useless-escape: warn
|
||||
ignorePatterns:
|
||||
|
||||
1
.github/workflows/tests.yaml
vendored
1
.github/workflows/tests.yaml
vendored
@@ -29,7 +29,6 @@ jobs:
|
||||
env:
|
||||
CI: true
|
||||
|
||||
# FIXME: fix this so the `cli` package includes the corresponding `core`
|
||||
cli-package-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
[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.
|
||||
|
||||
@@ -111,7 +125,7 @@ Operation must have at least one \`4XX\` response.
|
||||
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}\`.
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
[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}\`.
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
[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.
|
||||
|
||||
@@ -155,7 +197,7 @@ Error was generated by the path-segment-plural rule.
|
||||
|
||||
/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.
|
||||
|
||||
|
||||
|
||||
8289
package-lock.json
generated
8289
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -63,18 +63,19 @@
|
||||
"@types/mark.js": "^8.11.5",
|
||||
"@types/marked": "^4.0.3",
|
||||
"@types/node": "^17.0.31",
|
||||
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
||||
"@typescript-eslint/parser": "^5.33.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
||||
"@typescript-eslint/parser": "^6.8.0",
|
||||
"eslint": "^8.22.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest": "^29.0.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"null-loader": "^4.0.0",
|
||||
"outdent": "^0.7.1",
|
||||
"prettier": "^2.1.2",
|
||||
"slackify-markdown": "^4.3.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-loader": "^8.0.2",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "4.3.3",
|
||||
"typescript": "^5.2.2",
|
||||
"webpack": "^5.76.0",
|
||||
"webpack-cli": "^4.10.0"
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@
|
||||
"@types/react-dom": "^17.0.0 || ^18.2.7",
|
||||
"@types/semver": "^7.5.0",
|
||||
"@types/yargs": "17.0.5",
|
||||
"typescript": "^4.0.3"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ export default async (url: string, options = {}) => {
|
||||
controller.abort();
|
||||
}, 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 });
|
||||
clearTimeout(timeout);
|
||||
return res;
|
||||
|
||||
@@ -52,6 +52,6 @@
|
||||
"@types/minimatch": "^3.0.5",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@types/pluralize": "^0.0.29",
|
||||
"typescript": "^4.0.5"
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ describe('lint', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/license",
|
||||
"reportOnKey": false,
|
||||
"source": "/test/spec.yaml",
|
||||
@@ -40,7 +40,7 @@ describe('lint', () => {
|
||||
"message": "Expected type \`License\` (object) but got \`string\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -56,11 +56,11 @@ describe('lint', () => {
|
||||
|
||||
expect(replaceSourceWithRef(results, path.join(__dirname, 'fixtures/lint/')))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/license",
|
||||
"reportOnKey": false,
|
||||
"source": "openapi.yaml",
|
||||
@@ -69,7 +69,7 @@ describe('lint', () => {
|
||||
"message": "Expected type \`License\` (object) but got \`string\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -125,11 +125,11 @@ describe('lint', () => {
|
||||
const results = await lintConfig({ document });
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/eme",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -138,17 +138,17 @@ describe('lint', () => {
|
||||
"message": "Property \`eme\` is not expected here.",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [
|
||||
"suggest": [
|
||||
"theme",
|
||||
"env",
|
||||
"seo",
|
||||
"sso",
|
||||
],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/openapi",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -157,12 +157,12 @@ describe('lint', () => {
|
||||
"message": "Property \`openapi\` is not expected here.",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/apis",
|
||||
"reportOnKey": false,
|
||||
"source": "",
|
||||
@@ -171,7 +171,7 @@ describe('lint', () => {
|
||||
"message": "Expected type \`ConfigApis\` (object) but got \`string\`",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -191,11 +191,11 @@ describe('lint', () => {
|
||||
const results = await lintConfig({ document });
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/api",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -204,7 +204,7 @@ describe('lint', () => {
|
||||
"message": "Property \`api\` is not expected here.",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [
|
||||
"suggest": [
|
||||
"apis",
|
||||
"seo",
|
||||
"sso",
|
||||
@@ -231,11 +231,11 @@ describe('lint', () => {
|
||||
const results = await lintConfig({ document });
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/referenceDocs",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -244,7 +244,7 @@ describe('lint', () => {
|
||||
"message": "Property \`referenceDocs\` is not expected here.",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -266,11 +266,11 @@ describe('lint', () => {
|
||||
const results = await lintConfig({ document });
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/apis/main/plugins",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -279,7 +279,7 @@ describe('lint', () => {
|
||||
"message": "Property \`plugins\` is not expected here.",
|
||||
"ruleId": "configuration spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -323,7 +323,7 @@ describe('lint', () => {
|
||||
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', () => {
|
||||
@@ -402,7 +402,7 @@ describe('lint', () => {
|
||||
config: await makeConfig({ spec: 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should ignore error because ignore file passed', async () => {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { normalizeVisitors, VisitorLevelContext } from '../visitors';
|
||||
import {
|
||||
BaseVisitor,
|
||||
NestedVisitObject,
|
||||
normalizeVisitors,
|
||||
RuleInstanceConfig,
|
||||
VisitorLevelContext,
|
||||
} from '../visitors';
|
||||
import { Oas3RuleSet } from '../oas-types';
|
||||
import { Oas3Types } from '../types/oas3';
|
||||
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.Schema.enter).toHaveLength(1);
|
||||
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.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.PathItem.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.Parameter.enter).toHaveLength(2);
|
||||
expect(normalized.Parameter.enter[0].visit).toStrictEqual(operationParam);
|
||||
|
||||
@@ -9,8 +9,8 @@ describe('ref-utils', () => {
|
||||
it(`should unescape refs with '/'`, () => {
|
||||
const reference = 'somefile.yaml#/components/schemas/scope~1domain-schema';
|
||||
expect(parseRef(reference)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"pointer": Array [
|
||||
{
|
||||
"pointer": [
|
||||
"components",
|
||||
"schemas",
|
||||
"scope/domain-schema",
|
||||
@@ -23,8 +23,8 @@ describe('ref-utils', () => {
|
||||
it(`should unescape refs with '~'`, () => {
|
||||
const reference = 'somefile.yaml#/components/schemas/complex~0name';
|
||||
expect(parseRef(reference)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"pointer": Array [
|
||||
{
|
||||
"pointer": [
|
||||
"components",
|
||||
"schemas",
|
||||
"complex~name",
|
||||
@@ -37,8 +37,8 @@ describe('ref-utils', () => {
|
||||
it(`should unescape complex urlencoded paths`, () => {
|
||||
const referene = 'somefile.yaml#/components/schemas/scope%2Fcomplex~name';
|
||||
expect(parseRef(referene)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"pointer": Array [
|
||||
{
|
||||
"pointer": [
|
||||
"components",
|
||||
"schemas",
|
||||
"scope/complex~name",
|
||||
@@ -93,7 +93,7 @@ describe('ref-utils', () => {
|
||||
config: new StyleguideConfig({}),
|
||||
});
|
||||
|
||||
expect(result).toMatchInlineSnapshot(`Array []`);
|
||||
expect(result).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
describe('refBaseName', () => {
|
||||
|
||||
@@ -48,25 +48,25 @@ describe('Resolve http-headers', () => {
|
||||
|
||||
expect(fetchMock).toBeCalledTimes(3);
|
||||
expect(fetchMock.mock.calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Array [
|
||||
[
|
||||
[
|
||||
"https://example.com/test.yaml",
|
||||
Object {
|
||||
"headers": Object {
|
||||
{
|
||||
"headers": {
|
||||
"X_TEST": "123",
|
||||
},
|
||||
},
|
||||
],
|
||||
Array [
|
||||
[
|
||||
"https://sample.com/test.yaml",
|
||||
Object {
|
||||
"headers": Object {},
|
||||
{
|
||||
"headers": {},
|
||||
},
|
||||
],
|
||||
Array [
|
||||
[
|
||||
"https://sample.com/test/a/test.yaml",
|
||||
Object {
|
||||
"headers": Object {
|
||||
{
|
||||
"headers": {
|
||||
"X_TEST": "321",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('collect refs', () => {
|
||||
expect(Array.from(resolvedRefs.keys())).toMatchInlineSnapshot(
|
||||
[`foobar.yaml::#/defs/info`],
|
||||
`
|
||||
Array [
|
||||
[
|
||||
"foobar.yaml::#/defs/info",
|
||||
]
|
||||
`
|
||||
@@ -198,7 +198,7 @@ describe('collect refs', () => {
|
||||
.map((ref) => ref.substring(cwd.length + 1))
|
||||
.sort()
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"openapi-with-back.yaml::./schemas/type-a.yaml#/",
|
||||
"openapi-with-back.yaml::./schemas/type-b.yaml#/",
|
||||
"schemas/type-a.yaml::../openapi-with-back.yaml#/components/schemas/TypeB",
|
||||
@@ -214,19 +214,19 @@ describe('collect refs', () => {
|
||||
return getKey(firstEl).localeCompare(getKey(secondEl));
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"allOf": Array [
|
||||
Object {
|
||||
"properties": Object {
|
||||
"integration_type": Object {
|
||||
[
|
||||
{
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"integration_type": {
|
||||
"$ref": "../openapi-with-back.yaml#/components/schemas/TypeB",
|
||||
},
|
||||
"name": Object {
|
||||
"name": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"required": Array [
|
||||
"required": [
|
||||
"name",
|
||||
"integration_type",
|
||||
],
|
||||
@@ -234,8 +234,8 @@ describe('collect refs', () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"enum": Array [
|
||||
{
|
||||
"enum": [
|
||||
"webhook",
|
||||
"api_key",
|
||||
"sftp",
|
||||
@@ -243,8 +243,8 @@ describe('collect refs', () => {
|
||||
],
|
||||
"type": "string",
|
||||
},
|
||||
Object {
|
||||
"enum": Array [
|
||||
{
|
||||
"enum": [
|
||||
"webhook",
|
||||
"api_key",
|
||||
"sftp",
|
||||
@@ -270,7 +270,7 @@ describe('collect refs', () => {
|
||||
expect(resolvedRefs).toBeDefined();
|
||||
expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"openapi.yaml::#/components/schemas/Local",
|
||||
"openapi.yaml::#/components/schemas/Local/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(`
|
||||
Array [
|
||||
Object {
|
||||
"properties": Object {
|
||||
"localCircular": Object {
|
||||
[
|
||||
{
|
||||
"properties": {
|
||||
"localCircular": {
|
||||
"$ref": "#/components/schemas/Local",
|
||||
},
|
||||
"number": Object {
|
||||
"number": {
|
||||
"type": "number",
|
||||
},
|
||||
"string": Object {
|
||||
"string": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"type": "string",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"type": "string",
|
||||
},
|
||||
Object {
|
||||
"properties": Object {
|
||||
"external": Object {
|
||||
{
|
||||
"properties": {
|
||||
"external": {
|
||||
"$ref": "./External2.yaml",
|
||||
},
|
||||
"number": Object {
|
||||
"number": {
|
||||
"type": "number",
|
||||
},
|
||||
"string": Object {
|
||||
"string": {
|
||||
"type": "string",
|
||||
},
|
||||
"unknown": Object {
|
||||
"unknown": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
"type": "object",
|
||||
},
|
||||
Object {
|
||||
"properties": Object {
|
||||
"circularParent": Object {
|
||||
{
|
||||
"properties": {
|
||||
"circularParent": {
|
||||
"$ref": "./External.yaml#/properties",
|
||||
},
|
||||
},
|
||||
"type": "object",
|
||||
},
|
||||
Object {
|
||||
"external": Object {
|
||||
{
|
||||
"external": {
|
||||
"$ref": "./External2.yaml",
|
||||
},
|
||||
"number": Object {
|
||||
"number": {
|
||||
"type": "number",
|
||||
},
|
||||
"string": Object {
|
||||
"string": {
|
||||
"type": "string",
|
||||
},
|
||||
"unknown": Object {
|
||||
"unknown": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
@@ -366,12 +366,12 @@ describe('collect refs', () => {
|
||||
// expect(resolvedRefs.size).toEqual(2);
|
||||
expect(Array.from(resolvedRefs.keys()).map((ref) => ref.substring(cwd.length + 1)))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"openapi-with-md-description.yaml::./description.md",
|
||||
]
|
||||
`);
|
||||
expect(Array.from(resolvedRefs.values()).map((val) => val.node)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"# Hello World
|
||||
|
||||
Lorem ipsum
|
||||
|
||||
@@ -188,7 +188,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter param path-param",
|
||||
"leave param path-param",
|
||||
"enter operation: get",
|
||||
@@ -268,7 +268,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter param path-param",
|
||||
"leave param path-param",
|
||||
"enter operation: get",
|
||||
@@ -349,7 +349,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter operation: get",
|
||||
"enter operation get > param shared-a",
|
||||
"enter param shared-a",
|
||||
@@ -421,7 +421,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter path pet > param path-param",
|
||||
"enter path pet > param shared-a",
|
||||
"enter path pet > param get_b",
|
||||
@@ -493,7 +493,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter path pet > param path-param",
|
||||
"enter operation get > param shared-a",
|
||||
"enter operation get > param get_b",
|
||||
@@ -560,7 +560,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter path pet > param path-param",
|
||||
"leave path pet > param path-param",
|
||||
"enter path pet > op get",
|
||||
@@ -614,7 +614,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter schema shared_a",
|
||||
"enter schema nested",
|
||||
]
|
||||
@@ -670,7 +670,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter param a > schema shared_a",
|
||||
"enter param b > schema shared_a",
|
||||
]
|
||||
@@ -712,7 +712,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter operation get",
|
||||
"leave operation get",
|
||||
]
|
||||
@@ -767,7 +767,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter operation get > param shared-a",
|
||||
"enter operation get > param get_b",
|
||||
"enter operation get > param get_c",
|
||||
@@ -853,7 +853,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter path pet > param path-param",
|
||||
"leave path pet > param path-param",
|
||||
"enter operation get > param shared-a",
|
||||
@@ -932,7 +932,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter nested schema inline-top > inline-top",
|
||||
"enter nested schema inline-top > inline-nested",
|
||||
"enter nested schema inline-nested > inline-nested-nested",
|
||||
@@ -1004,7 +1004,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
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_a with target shared-a",
|
||||
@@ -1048,7 +1048,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter schema a: string",
|
||||
"enter schema b: number",
|
||||
]
|
||||
@@ -1113,7 +1113,7 @@ describe('walk order', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter Root",
|
||||
"enter Paths",
|
||||
"enter PathItem",
|
||||
@@ -1202,10 +1202,10 @@ describe('context.report', () => {
|
||||
|
||||
expect(results).toHaveLength(3);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/parameters/0",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -1214,11 +1214,11 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: get_a",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/parameters/1",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -1227,11 +1227,11 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: get_b",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/shared_a",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -1240,7 +1240,7 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: shared_a",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -1282,10 +1282,10 @@ describe('context.report', () => {
|
||||
|
||||
expect(results).toHaveLength(4);
|
||||
expect(replaceSourceWithRef(results, cwd)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/path-param",
|
||||
"reportOnKey": false,
|
||||
"source": "openapi-with-external-refs.yaml",
|
||||
@@ -1294,11 +1294,11 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: path_param",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/param-a",
|
||||
"reportOnKey": false,
|
||||
"source": "openapi-with-external-refs.yaml",
|
||||
@@ -1307,11 +1307,11 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: param_a",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "param-c.yaml",
|
||||
@@ -1320,11 +1320,11 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: param_c",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "param-b.yaml",
|
||||
@@ -1333,7 +1333,7 @@ describe('context.report', () => {
|
||||
"message": "Parameter name shouldn't contain '_: param_b",
|
||||
"ruleId": "test/test",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -1350,7 +1350,7 @@ describe('context.resolve', () => {
|
||||
expect(schema.properties.a.$ref).toBeDefined();
|
||||
const { location, node } = resolve(schema.properties.a);
|
||||
expect(node).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
{
|
||||
"type": "string",
|
||||
}
|
||||
`);
|
||||
@@ -1460,7 +1460,7 @@ describe('type extensions', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter Root",
|
||||
"enter XWebHooks",
|
||||
"enter hook test",
|
||||
@@ -1532,7 +1532,7 @@ describe('ignoreNextRules', () => {
|
||||
});
|
||||
|
||||
expect(calls).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
[
|
||||
"enter and skip operation get",
|
||||
"leave skipped operation get",
|
||||
"enter and not skip operation put",
|
||||
|
||||
@@ -1,51 +1,70 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`resolveConfig should ignore minimal from the root and read local file 1`] = `
|
||||
Object {
|
||||
"decorators": Object {},
|
||||
{
|
||||
"decorators": {},
|
||||
"doNotResolveExamples": undefined,
|
||||
"oas2Decorators": Object {},
|
||||
"oas2Preprocessors": Object {},
|
||||
"oas2Rules": Object {},
|
||||
"oas3_0Decorators": Object {},
|
||||
"oas3_0Preprocessors": Object {},
|
||||
"oas3_0Rules": Object {
|
||||
"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",
|
||||
"oas2Decorators": {},
|
||||
"oas2Preprocessors": {},
|
||||
"oas2Rules": {
|
||||
"boolean-parameter-prefixes": "error",
|
||||
"request-mime-type": "off",
|
||||
"response-contains-property": "off",
|
||||
"response-mime-type": "off",
|
||||
},
|
||||
"oas3_1Decorators": Object {},
|
||||
"oas3_1Preprocessors": Object {},
|
||||
"oas3_1Rules": Object {
|
||||
"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 {
|
||||
"oas3_0Decorators": {},
|
||||
"oas3_0Preprocessors": {},
|
||||
"oas3_0Rules": {
|
||||
"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",
|
||||
},
|
||||
"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-license": "warn",
|
||||
"info-license-url": "warn",
|
||||
"local/operation-id-not-test": "error",
|
||||
"no-ambiguous-paths": "warn",
|
||||
"no-enum-type-mismatch": "error",
|
||||
"no-http-verbs-in-paths": "off",
|
||||
"no-identical-paths": "error",
|
||||
"no-invalid-media-type-examples": "error",
|
||||
"no-invalid-parameter-examples": "off",
|
||||
"no-invalid-schema-examples": "off",
|
||||
"no-path-trailing-slash": "error",
|
||||
"no-unresolved-refs": "error",
|
||||
"operation-2xx-response": "warn",
|
||||
@@ -60,10 +79,16 @@ Object {
|
||||
"operation-tag-defined": "off",
|
||||
"parameter-description": "off",
|
||||
"path-declaration-must-exist": "error",
|
||||
"path-excludes-patterns": "off",
|
||||
"path-http-verbs-order": "error",
|
||||
"path-not-include-query": "error",
|
||||
"path-parameters-defined": "error",
|
||||
"path-params-defined": "off",
|
||||
"path-segment-plural": "off",
|
||||
"paths-kebab-case": "off",
|
||||
"required-string-property-missing-min-length": "off",
|
||||
"response-contains-header": "off",
|
||||
"scalar-property-missing-example": "off",
|
||||
"security-defined": "error",
|
||||
"spec": "error",
|
||||
"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`] = `
|
||||
Object {
|
||||
"decorators": Object {},
|
||||
{
|
||||
"decorators": {},
|
||||
"doNotResolveExamples": undefined,
|
||||
"oas2Decorators": Object {},
|
||||
"oas2Preprocessors": Object {},
|
||||
"oas2Rules": Object {},
|
||||
"oas3_0Decorators": Object {},
|
||||
"oas3_0Preprocessors": Object {},
|
||||
"oas3_0Rules": Object {
|
||||
"oas2Decorators": {},
|
||||
"oas2Preprocessors": {},
|
||||
"oas2Rules": {
|
||||
"boolean-parameter-prefixes": "error",
|
||||
"request-mime-type": "off",
|
||||
"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-example-value-and-externalValue": "error",
|
||||
"no-invalid-media-type-examples": "warn",
|
||||
@@ -91,11 +123,17 @@ Object {
|
||||
"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": Object {},
|
||||
"oas3_1Preprocessors": Object {},
|
||||
"oas3_1Rules": Object {
|
||||
"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": "warn",
|
||||
@@ -104,39 +142,45 @@ Object {
|
||||
"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": Object {},
|
||||
"preprocessors": {},
|
||||
"recommendedFallback": undefined,
|
||||
"rules": Object {
|
||||
"assertions": Array [
|
||||
Object {
|
||||
"rules": {
|
||||
"assertions": [
|
||||
{
|
||||
"assertionId": "rule/path-item-get-defined",
|
||||
"defined": true,
|
||||
"message": "Every path item must have a GET operation.",
|
||||
"property": "get",
|
||||
"subject": "PathItem",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"assertionId": "rule/tag-description",
|
||||
"message": "Tag description must be at least 13 characters and end with a full stop.",
|
||||
"minLength": 13,
|
||||
"pattern": "/\\\\.$/",
|
||||
"pattern": "/\\.$/",
|
||||
"property": "description",
|
||||
"severity": "error",
|
||||
"subject": "Tag",
|
||||
},
|
||||
],
|
||||
"boolean-parameter-prefixes": "error",
|
||||
"component-name-unique": "off",
|
||||
"info-contact": "off",
|
||||
"info-license": "warn",
|
||||
"info-license-url": "warn",
|
||||
"local/operation-id-not-test": "error",
|
||||
"no-ambiguous-paths": "warn",
|
||||
"no-enum-type-mismatch": "error",
|
||||
"no-http-verbs-in-paths": "off",
|
||||
"no-identical-paths": "error",
|
||||
"no-invalid-media-type-examples": "warn",
|
||||
"no-invalid-parameter-examples": "off",
|
||||
"no-invalid-schema-examples": "off",
|
||||
"no-path-trailing-slash": "error",
|
||||
"no-unresolved-refs": "error",
|
||||
"operation-2xx-response": "error",
|
||||
@@ -151,9 +195,16 @@ Object {
|
||||
"operation-tag-defined": "off",
|
||||
"parameter-description": "off",
|
||||
"path-declaration-must-exist": "error",
|
||||
"path-excludes-patterns": "off",
|
||||
"path-http-verbs-order": "off",
|
||||
"path-not-include-query": "error",
|
||||
"path-parameters-defined": "error",
|
||||
"path-params-defined": "off",
|
||||
"path-segment-plural": "off",
|
||||
"paths-kebab-case": "off",
|
||||
"required-string-property-missing-min-length": "off",
|
||||
"response-contains-header": "off",
|
||||
"scalar-property-missing-example": "off",
|
||||
"security-defined": "error",
|
||||
"spec": "error",
|
||||
"spec-strict-refs": "off",
|
||||
|
||||
@@ -5,160 +5,160 @@ StyleguideConfig {
|
||||
"_usedRules": Set {},
|
||||
"_usedVersions": Set {},
|
||||
"configFile": undefined,
|
||||
"decorators": Object {
|
||||
"async2": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"decorators": {
|
||||
"async2": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas2": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas2": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas3_0": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas3_1": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
},
|
||||
"doNotResolveExamples": false,
|
||||
"extendPaths": Array [],
|
||||
"ignore": Object {
|
||||
"https://some-path.yaml": Object {
|
||||
"extendPaths": [],
|
||||
"ignore": {
|
||||
"https://some-path.yaml": {
|
||||
"no-unused-components": Set {
|
||||
"#/components/schemas/Foo",
|
||||
},
|
||||
},
|
||||
"some-path/openapi.yaml": Object {
|
||||
"some-path/openapi.yaml": {
|
||||
"no-unused-components": Set {
|
||||
"#/components/schemas/Foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
"pluginPaths": Array [],
|
||||
"plugins": Array [],
|
||||
"preprocessors": Object {
|
||||
"async2": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"pluginPaths": [],
|
||||
"plugins": [],
|
||||
"preprocessors": {
|
||||
"async2": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas2": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas2": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas3_0": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"oas3_1": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
},
|
||||
"rawConfig": Object {
|
||||
"rawConfig": {
|
||||
"_usedRules": Set {},
|
||||
"_usedVersions": Set {},
|
||||
"configFile": "redocly.yaml",
|
||||
"decorators": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"decorators": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"doNotResolveExamples": false,
|
||||
"ignore": Object {},
|
||||
"plugins": Array [],
|
||||
"preprocessors": Object {
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"ignore": {},
|
||||
"plugins": [],
|
||||
"preprocessors": {
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"rawConfig": Object {
|
||||
"plugins": Array [],
|
||||
"rules": Object {
|
||||
"rawConfig": {
|
||||
"plugins": [],
|
||||
"rules": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"recommendedFallback": false,
|
||||
"rules": Object {
|
||||
"oas2": Object {
|
||||
"rules": {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
},
|
||||
"recommendedFallback": false,
|
||||
"rules": Object {
|
||||
"async2": Object {
|
||||
"oas2": Object {
|
||||
"rules": {
|
||||
"async2": {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"oas2": Object {
|
||||
"oas2": Object {
|
||||
"oas2": {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas2": Object {
|
||||
"oas3_0": {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas2": Object {
|
||||
"oas3_1": {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
|
||||
@@ -69,95 +69,95 @@ describe('getMergedConfig', () => {
|
||||
it('should get styleguide defined in "apis" section', () => {
|
||||
expect(getMergedConfig(testConfig, 'test@v1')).toMatchInlineSnapshot(`
|
||||
Config {
|
||||
"apis": Object {
|
||||
"test@v1": Object {
|
||||
"apis": {
|
||||
"test@v1": {
|
||||
"root": "resources/pets.yaml",
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"configFile": "redocly.yaml",
|
||||
"files": Array [],
|
||||
"files": [],
|
||||
"organization": "redocly-test",
|
||||
"rawConfig": Object {
|
||||
"apis": Object {
|
||||
"test@v1": Object {
|
||||
"rawConfig": {
|
||||
"apis": {
|
||||
"test@v1": {
|
||||
"root": "resources/pets.yaml",
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"files": Array [],
|
||||
"files": [],
|
||||
"organization": "redocly-test",
|
||||
"styleguide": Object {
|
||||
"extendPaths": Array [],
|
||||
"pluginPaths": Array [],
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"extendPaths": [],
|
||||
"pluginPaths": [],
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
"telemetry": "on",
|
||||
"theme": Object {},
|
||||
"theme": {},
|
||||
},
|
||||
"region": undefined,
|
||||
"resolve": Object {
|
||||
"http": Object {
|
||||
"resolve": {
|
||||
"http": {
|
||||
"customFetch": undefined,
|
||||
"headers": Array [],
|
||||
"headers": [],
|
||||
},
|
||||
},
|
||||
"styleguide": StyleguideConfig {
|
||||
"_usedRules": Set {},
|
||||
"_usedVersions": Set {},
|
||||
"configFile": "redocly.yaml",
|
||||
"decorators": Object {
|
||||
"async2": Object {},
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"decorators": {
|
||||
"async2": {},
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"doNotResolveExamples": false,
|
||||
"extendPaths": Array [],
|
||||
"ignore": Object {},
|
||||
"pluginPaths": Array [],
|
||||
"plugins": Array [],
|
||||
"preprocessors": Object {
|
||||
"async2": Object {},
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"extendPaths": [],
|
||||
"ignore": {},
|
||||
"pluginPaths": [],
|
||||
"plugins": [],
|
||||
"preprocessors": {
|
||||
"async2": {},
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"rawConfig": Object {
|
||||
"extendPaths": Array [],
|
||||
"pluginPaths": Array [],
|
||||
"rules": Object {
|
||||
"rawConfig": {
|
||||
"extendPaths": [],
|
||||
"pluginPaths": [],
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
"recommendedFallback": false,
|
||||
"rules": Object {
|
||||
"async2": Object {
|
||||
"rules": {
|
||||
"async2": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
"oas2": Object {
|
||||
"oas2": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
},
|
||||
"telemetry": "on",
|
||||
"theme": Object {},
|
||||
"theme": {},
|
||||
}
|
||||
`);
|
||||
});
|
||||
@@ -172,103 +172,103 @@ describe('getMergedConfig', () => {
|
||||
it('should handle wrong alias - return the same styleguide, empty features', () => {
|
||||
expect(getMergedConfig(testConfig, 'wrong-alias')).toMatchInlineSnapshot(`
|
||||
Config {
|
||||
"apis": Object {
|
||||
"test@v1": Object {
|
||||
"apis": {
|
||||
"test@v1": {
|
||||
"root": "resources/pets.yaml",
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"configFile": "redocly.yaml",
|
||||
"files": Array [],
|
||||
"files": [],
|
||||
"organization": "redocly-test",
|
||||
"rawConfig": Object {
|
||||
"apis": Object {
|
||||
"test@v1": Object {
|
||||
"rawConfig": {
|
||||
"apis": {
|
||||
"test@v1": {
|
||||
"root": "resources/pets.yaml",
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-summary": "warn",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"files": Array [],
|
||||
"files": [],
|
||||
"organization": "redocly-test",
|
||||
"styleguide": Object {
|
||||
"extendPaths": Array [],
|
||||
"pluginPaths": Array [],
|
||||
"plugins": Array [],
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"extendPaths": [],
|
||||
"pluginPaths": [],
|
||||
"plugins": [],
|
||||
"rules": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"telemetry": "on",
|
||||
"theme": Object {},
|
||||
"theme": {},
|
||||
},
|
||||
"region": undefined,
|
||||
"resolve": Object {
|
||||
"http": Object {
|
||||
"resolve": {
|
||||
"http": {
|
||||
"customFetch": undefined,
|
||||
"headers": Array [],
|
||||
"headers": [],
|
||||
},
|
||||
},
|
||||
"styleguide": StyleguideConfig {
|
||||
"_usedRules": Set {},
|
||||
"_usedVersions": Set {},
|
||||
"configFile": "redocly.yaml",
|
||||
"decorators": Object {
|
||||
"async2": Object {},
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"decorators": {
|
||||
"async2": {},
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"doNotResolveExamples": false,
|
||||
"extendPaths": Array [],
|
||||
"ignore": Object {},
|
||||
"pluginPaths": Array [],
|
||||
"plugins": Array [],
|
||||
"preprocessors": Object {
|
||||
"async2": Object {},
|
||||
"oas2": Object {},
|
||||
"oas3_0": Object {},
|
||||
"oas3_1": Object {},
|
||||
"extendPaths": [],
|
||||
"ignore": {},
|
||||
"pluginPaths": [],
|
||||
"plugins": [],
|
||||
"preprocessors": {
|
||||
"async2": {},
|
||||
"oas2": {},
|
||||
"oas3_0": {},
|
||||
"oas3_1": {},
|
||||
},
|
||||
"rawConfig": Object {
|
||||
"extendPaths": Array [],
|
||||
"pluginPaths": Array [],
|
||||
"plugins": Array [],
|
||||
"rules": Object {
|
||||
"rawConfig": {
|
||||
"extendPaths": [],
|
||||
"pluginPaths": [],
|
||||
"plugins": [],
|
||||
"rules": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
"recommendedFallback": false,
|
||||
"rules": Object {
|
||||
"async2": Object {
|
||||
"rules": {
|
||||
"async2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas2": Object {
|
||||
"oas2": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_0": Object {
|
||||
"oas3_0": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
"oas3_1": Object {
|
||||
"oas3_1": {
|
||||
"no-empty-servers": "error",
|
||||
"operation-summary": "error",
|
||||
},
|
||||
},
|
||||
},
|
||||
"telemetry": "on",
|
||||
"theme": Object {},
|
||||
"theme": {},
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
@@ -172,17 +172,21 @@ function verifyExtendedConfig(
|
||||
const recommendedRules = defaultPlugin?.configs?.[extendsRuleSet];
|
||||
expect(recommendedRules).toBeDefined();
|
||||
|
||||
verifyOasRules(config.styleguide.rules.oas2, overridesRules, recommendedRules?.rules || {});
|
||||
verifyOasRules(
|
||||
config.styleguide.rules.oas3_0,
|
||||
config.styleguide.rules.oas2,
|
||||
overridesRules,
|
||||
Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_0Rules)
|
||||
);
|
||||
verifyOasRules(
|
||||
config.styleguide.rules.oas3_1,
|
||||
overridesRules,
|
||||
Object.assign({}, recommendedRules?.rules, recommendedRules?.oas3_1Rules)
|
||||
{ ...recommendedRules?.rules, ...recommendedRules?.oas2Rules } || {}
|
||||
);
|
||||
|
||||
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(
|
||||
|
||||
@@ -78,25 +78,25 @@ describe('transformConfig', () => {
|
||||
makeTestRawConfig('styleguide', 'styleguide')
|
||||
);
|
||||
expect(transformedRawConfig).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"apis": Object {
|
||||
"test@v1": Object {
|
||||
{
|
||||
"apis": {
|
||||
"test@v1": {
|
||||
"root": "root.yaml",
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-2xx-response": "error",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-4xx-response": "warn",
|
||||
},
|
||||
},
|
||||
"theme": Object {
|
||||
"mockServer": Object {},
|
||||
"openapi": Object {},
|
||||
"theme": {
|
||||
"mockServer": {},
|
||||
"openapi": {},
|
||||
},
|
||||
}
|
||||
`);
|
||||
@@ -111,20 +111,20 @@ describe('transformConfig', () => {
|
||||
testRawConfig.apis = undefined;
|
||||
testRawConfig.apiDefinitions = { legacyApiDefinition: 'file.yaml' };
|
||||
expect(utils.transformConfig(testRawConfig)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"apis": Object {
|
||||
"legacyApiDefinition": Object {
|
||||
{
|
||||
"apis": {
|
||||
"legacyApiDefinition": {
|
||||
"root": "file.yaml",
|
||||
},
|
||||
},
|
||||
"styleguide": Object {
|
||||
"rules": Object {
|
||||
"styleguide": {
|
||||
"rules": {
|
||||
"operation-4xx-response": "warn",
|
||||
},
|
||||
},
|
||||
"theme": Object {
|
||||
"mockServer": Object {},
|
||||
"openapi": Object {},
|
||||
"theme": {
|
||||
"mockServer": {},
|
||||
"openapi": {},
|
||||
},
|
||||
}
|
||||
`);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PluginStyleguideConfig } from './types';
|
||||
|
||||
export default {
|
||||
const all: PluginStyleguideConfig<'built-in'> = {
|
||||
rules: {
|
||||
'info-contact': 'error',
|
||||
'info-license': 'error',
|
||||
@@ -28,13 +28,24 @@ export default {
|
||||
'operation-singular-tag': 'error',
|
||||
'no-unresolved-refs': 'error',
|
||||
'no-enum-type-mismatch': 'error',
|
||||
'boolean-parameter-prefixes': 'error',
|
||||
'paths-kebab-case': 'error',
|
||||
'no-http-verbs-in-paths': 'error',
|
||||
'path-excludes-patterns': {
|
||||
severity: 'error',
|
||||
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': {
|
||||
severity: 'error',
|
||||
allowedValues: ['application/json'],
|
||||
@@ -43,12 +54,7 @@ export default {
|
||||
severity: 'error',
|
||||
allowedValues: ['application/json'],
|
||||
},
|
||||
spec: 'error',
|
||||
'no-invalid-schema-examples': 'error',
|
||||
'no-invalid-parameter-examples': 'error',
|
||||
'scalar-property-missing-example': 'error',
|
||||
'spec-strict-refs': 'error',
|
||||
'component-name-unique': 'error',
|
||||
'response-contains-property': 'error',
|
||||
},
|
||||
oas3_0Rules: {
|
||||
'no-invalid-media-type-examples': 'error',
|
||||
@@ -60,8 +66,21 @@ export default {
|
||||
'no-undefined-server-variable': 'error',
|
||||
'no-server-variables-empty-enum': '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: {
|
||||
'no-invalid-media-type-examples': 'error',
|
||||
'no-server-example.com': 'error',
|
||||
'no-server-trailing-slash': 'error',
|
||||
'no-empty-servers': 'error',
|
||||
@@ -70,5 +89,23 @@ export default {
|
||||
'no-undefined-server-variable': 'error',
|
||||
'no-server-variables-empty-enum': '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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PluginStyleguideConfig } from './types';
|
||||
|
||||
export default {
|
||||
const minimal: PluginStyleguideConfig<'built-in'> = {
|
||||
rules: {
|
||||
'info-contact': 'off',
|
||||
'info-license': 'off',
|
||||
@@ -27,11 +27,25 @@ export default {
|
||||
'operation-singular-tag': 'off',
|
||||
'no-unresolved-refs': 'error',
|
||||
'no-enum-type-mismatch': 'warn',
|
||||
'boolean-parameter-prefixes': 'off',
|
||||
'paths-kebab-case': 'off',
|
||||
spec: 'error',
|
||||
'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: {
|
||||
'no-invalid-media-type-examples': {
|
||||
@@ -46,6 +60,12 @@ export default {
|
||||
'no-undefined-server-variable': 'warn',
|
||||
'no-server-variables-empty-enum': 'error',
|
||||
'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: {
|
||||
'no-invalid-media-type-examples': 'warn',
|
||||
@@ -57,5 +77,17 @@ export default {
|
||||
'no-undefined-server-variable': 'warn',
|
||||
'no-server-variables-empty-enum': 'error',
|
||||
'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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PluginStyleguideConfig } from './types';
|
||||
|
||||
export default {
|
||||
const recommended: PluginStyleguideConfig<'built-in'> = {
|
||||
rules: {
|
||||
'info-contact': 'off',
|
||||
'info-license': 'warn',
|
||||
@@ -27,11 +27,25 @@ export default {
|
||||
'operation-singular-tag': 'off',
|
||||
'no-unresolved-refs': 'error',
|
||||
'no-enum-type-mismatch': 'error',
|
||||
'boolean-parameter-prefixes': 'off',
|
||||
'paths-kebab-case': 'off',
|
||||
spec: 'error',
|
||||
'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: {
|
||||
'no-invalid-media-type-examples': {
|
||||
@@ -46,6 +60,12 @@ export default {
|
||||
'no-undefined-server-variable': 'error',
|
||||
'no-server-variables-empty-enum': '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: {
|
||||
'no-invalid-media-type-examples': 'warn',
|
||||
@@ -57,5 +77,17 @@ export default {
|
||||
'no-undefined-server-variable': 'error',
|
||||
'no-server-variables-empty-enum': '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;
|
||||
|
||||
@@ -11,11 +11,19 @@ import type {
|
||||
Async2PreprocessorsSet,
|
||||
Async2DecoratorsSet,
|
||||
Async2RuleSet,
|
||||
RuleMap,
|
||||
} from '../oas-types';
|
||||
|
||||
import type { NodeType } from '../types';
|
||||
import { Location } from '../ref-utils';
|
||||
import type { SkipFunctionContext } from '../visitors';
|
||||
import {
|
||||
BuiltInAsync2RuleId,
|
||||
BuiltInCommonOASRuleId,
|
||||
BuiltInCommonRuleId,
|
||||
BuiltInOAS2RuleId,
|
||||
BuiltInOAS3RuleId,
|
||||
} from '../types/redocly-yaml';
|
||||
|
||||
export type RuleSeverity = ProblemSeverity | 'off';
|
||||
|
||||
@@ -37,17 +45,17 @@ export type PreprocessorConfig =
|
||||
|
||||
export type DecoratorConfig = PreprocessorConfig;
|
||||
|
||||
export type StyleguideRawConfig = {
|
||||
export type StyleguideRawConfig<T = undefined> = {
|
||||
plugins?: (string | Plugin)[];
|
||||
extends?: string[];
|
||||
doNotResolveExamples?: boolean;
|
||||
recommendedFallback?: boolean;
|
||||
|
||||
rules?: Record<string, RuleConfig>;
|
||||
oas2Rules?: Record<string, RuleConfig>;
|
||||
oas3_0Rules?: Record<string, RuleConfig>;
|
||||
oas3_1Rules?: Record<string, RuleConfig>;
|
||||
async2Rules?: Record<string, RuleConfig>;
|
||||
rules?: RuleMap<BuiltInCommonRuleId | BuiltInCommonOASRuleId, RuleConfig, T>;
|
||||
oas2Rules?: RuleMap<BuiltInOAS2RuleId, RuleConfig, T>;
|
||||
oas3_0Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
||||
oas3_1Rules?: RuleMap<BuiltInOAS3RuleId, RuleConfig, T>;
|
||||
async2Rules?: RuleMap<BuiltInAsync2RuleId, RuleConfig, T>;
|
||||
|
||||
preprocessors?: Record<string, PreprocessorConfig>;
|
||||
oas2Preprocessors?: Record<string, PreprocessorConfig>;
|
||||
@@ -118,7 +126,10 @@ export type Plugin = {
|
||||
assertions?: AssertionsConfig;
|
||||
};
|
||||
|
||||
export type PluginStyleguideConfig = Omit<StyleguideRawConfig, 'plugins' | 'extends'>;
|
||||
export type PluginStyleguideConfig<T = undefined> = Omit<
|
||||
StyleguideRawConfig<T>,
|
||||
'plugins' | 'extends'
|
||||
>;
|
||||
|
||||
export type ResolveHeader =
|
||||
| {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Oas3Decorator } from '../../visitors';
|
||||
import { Oas3Operation, Oas3RequestBody, Oas3Response } from '../../typings/openapi';
|
||||
import { yamlAndJsonSyncReader } from '../../utils';
|
||||
import { isRef } from '../../ref-utils';
|
||||
import { ResolveFn, UserContext } from '../../walk';
|
||||
import { NonUndefined, ResolveFn, UserContext } from '../../walk';
|
||||
|
||||
export const MediaTypeExamplesOverride: Oas3Decorator = ({ operationIds }) => {
|
||||
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)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ProblemSeverity, WalkContext, walkDocument } from './walk';
|
||||
import { StyleguideConfig, Config, initRules, defaultPlugin, resolvePlugins } from './config';
|
||||
import { normalizeTypes } from './types';
|
||||
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 { Spec } from './rules/common/spec';
|
||||
|
||||
@@ -65,8 +65,8 @@ export async function lintDocument(opts: {
|
||||
visitorsData: {},
|
||||
};
|
||||
|
||||
const preprocessors = initRules(rules as any, config, 'preprocessors', specVersion);
|
||||
const regularRules = initRules(rules as Oas3RuleSet[], config, 'rules', specVersion);
|
||||
const preprocessors = initRules(rules, config, 'preprocessors', specVersion);
|
||||
const regularRules = initRules(rules, config, 'rules', specVersion);
|
||||
|
||||
let resolvedRefMap = await resolveDocument({
|
||||
rootDocument: document,
|
||||
|
||||
@@ -10,6 +10,13 @@ import { Oas2Types } from './types/oas2';
|
||||
import { Oas3Types } from './types/oas3';
|
||||
import { Oas3_1Types } from './types/oas3_1';
|
||||
import { AsyncApi2Types } from './types/asyncapi';
|
||||
import {
|
||||
BuiltInAsync2RuleId,
|
||||
BuiltInCommonOASRuleId,
|
||||
BuiltInCommonRuleId,
|
||||
BuiltInOAS2RuleId,
|
||||
BuiltInOAS3RuleId,
|
||||
} from './types/redocly-yaml';
|
||||
|
||||
export type RuleSet<T> = Record<string, T>;
|
||||
|
||||
@@ -33,9 +40,25 @@ const typesMap = {
|
||||
[SpecVersion.Async2]: AsyncApi2Types,
|
||||
};
|
||||
|
||||
export type Oas3RuleSet = Record<string, Oas3Rule>;
|
||||
export type Oas2RuleSet = Record<string, Oas2Rule>;
|
||||
export type Async2RuleSet = Record<string, Async2Rule>;
|
||||
export type RuleMap<Key extends string, RuleConfig, T> = Record<
|
||||
T extends 'built-in' ? Key : string,
|
||||
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 Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
||||
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|
||||
|
||||
@@ -27,10 +27,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/requestBody",
|
||||
"reportOnKey": false,
|
||||
"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'",
|
||||
"ruleId": "no-unresolved-refs",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -67,36 +67,36 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": undefined,
|
||||
"reportOnKey": false,
|
||||
"source": "fixtures/invalid-yaml.yaml",
|
||||
"start": Object {
|
||||
"start": {
|
||||
"col": 1,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/requestBody",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -148,10 +148,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/requestBody",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -160,7 +160,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
"message": "Can't resolve $ref",
|
||||
"ruleId": "no-unresolved-refs",
|
||||
"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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -252,6 +252,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results, __dirname)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,10 +27,10 @@ describe('Async2 channels-kebab-case', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/channels/NOT_A_KEBAB",
|
||||
"reportOnKey": true,
|
||||
"source": "asyncapi.yaml",
|
||||
@@ -39,7 +39,7 @@ describe('Async2 channels-kebab-case', () => {
|
||||
"message": "\`NOT_A_KEBAB\` does not use kebab-case.",
|
||||
"ruleId": "channels-kebab-case",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -68,10 +68,10 @@ describe('Async2 channels-kebab-case', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/channels/snake_kebab",
|
||||
"reportOnKey": true,
|
||||
"source": "asyncapi.yaml",
|
||||
@@ -80,7 +80,7 @@ describe('Async2 channels-kebab-case', () => {
|
||||
"message": "\`snake_kebab\` does not use kebab-case.",
|
||||
"ruleId": "channels-kebab-case",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -110,7 +110,7 @@ describe('Async2 channels-kebab-case', () => {
|
||||
'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 () => {
|
||||
@@ -136,6 +136,6 @@ describe('Async2 channels-kebab-case', () => {
|
||||
'paths-kebab-case': 'error',
|
||||
}),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,10 +27,10 @@ describe('no-channel-trailing-slash', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/channels/~1trailing~1",
|
||||
"reportOnKey": true,
|
||||
"source": "asyncapi.yaml",
|
||||
@@ -39,7 +39,7 @@ describe('no-channel-trailing-slash', () => {
|
||||
"message": "\`/trailing/\` should not have a trailing slash.",
|
||||
"ruleId": "no-channel-trailing-slash",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -67,7 +67,7 @@ describe('no-channel-trailing-slash', () => {
|
||||
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 () => {
|
||||
@@ -92,6 +92,6 @@ describe('no-channel-trailing-slash', () => {
|
||||
config: await makeConfig({ 'no-channel-trailing-slash': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,8 +7,9 @@ import { TagDescription } from '../common/tag-description';
|
||||
import { TagsAlphabetical } from '../common/tags-alphabetical';
|
||||
import { ChannelsKebabCase } from './channels-kebab-case';
|
||||
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,
|
||||
assertions: Assertions,
|
||||
'info-contact': InfoContact,
|
||||
|
||||
@@ -21,10 +21,10 @@ describe('Oas3 info-license', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -33,7 +33,7 @@ describe('Oas3 info-license', () => {
|
||||
"message": "Info object should contain \`license\` field.",
|
||||
"ruleId": "info-license",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -57,6 +57,6 @@ describe('Oas3 info-license', () => {
|
||||
config: await makeConfig({ 'info-license': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,10 +22,10 @@ describe('Oas3 license-url', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/license/url",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -34,7 +34,7 @@ describe('Oas3 license-url', () => {
|
||||
"message": "License object should contain \`url\` field.",
|
||||
"ruleId": "info-license-url",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -58,6 +58,6 @@ describe('Oas3 license-url', () => {
|
||||
config: await makeConfig({ 'info-license-url': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,10 +50,10 @@ describe('no-ambiguous-paths', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1{id}~1ambiguous",
|
||||
"reportOnKey": true,
|
||||
"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\`.",
|
||||
"ruleId": "no-ambiguous-paths",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1ambiguous~1{id}",
|
||||
"reportOnKey": true,
|
||||
"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}\`.",
|
||||
"ruleId": "no-ambiguous-paths",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1{entity}~1{id}~1last",
|
||||
"reportOnKey": true,
|
||||
"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\`.",
|
||||
"ruleId": "no-ambiguous-paths",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('Oas3 typed enum', () => {
|
||||
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 () => {
|
||||
@@ -65,7 +65,7 @@ describe('Oas3 typed enum', () => {
|
||||
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 () => {
|
||||
@@ -96,19 +96,19 @@ describe('Oas3 typed enum', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -144,10 +144,10 @@ describe('Oas3 typed enum', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema/enum/1",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -156,7 +156,7 @@ describe('Oas3 typed enum', () => {
|
||||
"message": "Enum value \`string\` must be of allowed types: \`integer,array\`.",
|
||||
"ruleId": "no-enum-type-mismatch",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -189,11 +189,11 @@ describe('Oas3 typed enum', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -202,7 +202,7 @@ describe('Oas3 typed enum', () => {
|
||||
"message": "Expected type \`Schema\` (object) but got \`null\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -38,10 +38,10 @@ describe('no-identical-paths', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1good~1{hash}",
|
||||
"reportOnKey": true,
|
||||
"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}\`.",
|
||||
"ruleId": "no-identical-paths",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('no-path-trailing-slash', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1bad~1",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -35,7 +35,7 @@ describe('no-path-trailing-slash', () => {
|
||||
"message": "\`/bad/\` should not have a trailing slash.",
|
||||
"ruleId": "no-path-trailing-slash",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -64,10 +64,10 @@ describe('no-path-trailing-slash', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1bad~1",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -76,7 +76,7 @@ describe('no-path-trailing-slash', () => {
|
||||
"message": "\`/bad/\` should not have a trailing slash.",
|
||||
"ruleId": "no-path-trailing-slash",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -100,7 +100,7 @@ describe('no-path-trailing-slash', () => {
|
||||
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 () => {
|
||||
@@ -121,6 +121,6 @@ describe('no-path-trailing-slash', () => {
|
||||
config: await makeConfig({ 'no-path-trailing-slash': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,10 +25,10 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -37,7 +37,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
"message": "Operation must have at least one \`2XX\` response.",
|
||||
"ruleId": "operation-2xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -63,7 +63,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
config: await makeConfig({ 'operation-2xx-response': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report for present default', async () => {
|
||||
@@ -86,7 +86,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
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 () => {
|
||||
@@ -108,10 +108,10 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test~1/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -120,7 +120,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
"message": "Operation must have at least one \`2XX\` response.",
|
||||
"ruleId": "operation-2xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -149,10 +149,10 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/webhooks/~1test~1/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -161,7 +161,7 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
"message": "Operation must have at least one \`2XX\` response.",
|
||||
"ruleId": "operation-2xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -187,6 +187,6 @@ describe('Oas3 operation-2xx-response', () => {
|
||||
config: await makeConfig({ 'operation-2xx-response': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,10 +25,10 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -37,7 +37,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"message": "Operation must have at least one \`4XX\` response.",
|
||||
"ruleId": "operation-4xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -63,7 +63,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
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 () => {
|
||||
@@ -86,7 +86,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
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 () => {
|
||||
@@ -110,10 +110,10 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test~1/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -122,7 +122,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"message": "Operation must have at least one \`4XX\` response.",
|
||||
"ruleId": "operation-4xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -147,10 +147,10 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test~1/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -159,7 +159,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"message": "Operation must have at least one \`2XX\` response.",
|
||||
"ruleId": "operation-2xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -188,10 +188,10 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/webhooks/~1test~1/put/responses",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -200,7 +200,7 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
"message": "Operation must have at least one \`4XX\` response.",
|
||||
"ruleId": "operation-4xx-response",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -226,6 +226,6 @@ describe('Oas3 operation-4xx-response', () => {
|
||||
config: await makeConfig({ 'operation-4xx-response': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,10 +30,10 @@ describe('Oas3 operation-operationId-unique', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test2/post/test2",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -42,7 +42,7 @@ describe('Oas3 operation-operationId-unique', () => {
|
||||
"message": "Every operation must have a unique \`operationId\`.",
|
||||
"ruleId": "operation-operationId-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -71,6 +71,6 @@ describe('Oas3 operation-operationId-unique', () => {
|
||||
config: await makeConfig({ 'peration-operationId-unique': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,10 +25,10 @@ describe('Oas3 operation-operationId-url-safe', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/operationId",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -37,7 +37,7 @@ describe('Oas3 operation-operationId-url-safe', () => {
|
||||
"message": "Operation \`operationId\` should not have URL invalid characters.",
|
||||
"ruleId": "operation-operationId-url-safe",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -26,10 +26,10 @@ describe('Oas3 operation-parameters-unique', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/parameters/1",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -39,7 +39,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
||||
Repeats of \`in:query\` + \`name:a\`.",
|
||||
"ruleId": "operation-parameters-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -68,7 +68,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
||||
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 () => {
|
||||
@@ -99,10 +99,10 @@ describe('Oas3 operation-parameters-unique', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/parameters/2",
|
||||
"reportOnKey": false,
|
||||
"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\`.",
|
||||
"ruleId": "operation-parameters-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -147,10 +147,10 @@ describe('Oas3 operation-parameters-unique', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/put/parameters/2",
|
||||
"reportOnKey": false,
|
||||
"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\`.",
|
||||
"ruleId": "operation-parameters-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -28,10 +28,10 @@ describe('Oas3 operation-singular-tag', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/get/tags",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -40,7 +40,7 @@ describe('Oas3 operation-singular-tag', () => {
|
||||
"message": "Operation \`tags\` object should have only one tag.",
|
||||
"ruleId": "operation-singular-tag",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -67,6 +67,6 @@ describe('Oas3 operation-singular-tag', () => {
|
||||
config: await makeConfig({ 'operation-singular-tag': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,10 +27,10 @@ describe('Common path-http-verbs-order', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/post",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -39,11 +39,11 @@ describe('Common path-http-verbs-order', () => {
|
||||
"message": "Operation http verbs must be ordered.",
|
||||
"ruleId": "path-http-verbs-order",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some/get",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -52,7 +52,7 @@ describe('Common path-http-verbs-order', () => {
|
||||
"message": "Operation http verbs must be ordered.",
|
||||
"ruleId": "path-http-verbs-order",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -90,6 +90,6 @@ describe('Common path-http-verbs-order', () => {
|
||||
config: await makeConfig({ 'path-http-verbs-order': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('Oas3 path-not-include-query', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some?input",
|
||||
"reportOnKey": true,
|
||||
"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\`.",
|
||||
"ruleId": "path-not-include-query",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -59,6 +59,6 @@ describe('Oas3 path-not-include-query', () => {
|
||||
config: await makeConfig({ 'path-not-include-query': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('Oas3 path-params-defined', () => {
|
||||
config: await makeConfig({ 'path-params-defined': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report on undefined param params', async () => {
|
||||
@@ -56,10 +56,10 @@ describe('Oas3 path-params-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets~1{a}~1{b}/get/parameters",
|
||||
"reportOnKey": true,
|
||||
"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}\`.",
|
||||
"ruleId": "path-params-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -100,10 +100,10 @@ describe('Oas3 path-params-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets~1{a}/parameters/1/name",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -112,11 +112,11 @@ describe('Oas3 path-params-defined', () => {
|
||||
"message": "Path parameter \`d\` is not used in the path \`/pets/{a}\`.",
|
||||
"ruleId": "path-params-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets~1{a}/get/parameters/0/name",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -125,7 +125,7 @@ describe('Oas3 path-params-defined', () => {
|
||||
"message": "Path parameter \`c\` is not used in the path \`/pets/{a}\`.",
|
||||
"ruleId": "path-params-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -154,10 +154,10 @@ describe('Oas3 path-params-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets~1{a}/post/parameters",
|
||||
"reportOnKey": true,
|
||||
"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}\`.",
|
||||
"ruleId": "path-params-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -197,6 +197,6 @@ describe('Oas3 path-params-defined', () => {
|
||||
config: await makeConfig({ 'path-params-defined': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,10 +26,10 @@ describe('Oas3 paths-kebab-case', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1someTest",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -38,7 +38,7 @@ describe('Oas3 paths-kebab-case', () => {
|
||||
"message": "\`/someTest\` does not use kebab-case.",
|
||||
"ruleId": "paths-kebab-case",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -65,10 +65,10 @@ describe('Oas3 paths-kebab-case', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1some_test",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -77,7 +77,7 @@ describe('Oas3 paths-kebab-case', () => {
|
||||
"message": "\`/some_test\` does not use kebab-case.",
|
||||
"ruleId": "paths-kebab-case",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -103,6 +103,6 @@ describe('Oas3 paths-kebab-case', () => {
|
||||
'no-path-trailing-slash': 'off',
|
||||
}),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,19 +28,19 @@ describe('Oas3 scalar-property-missing-example', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/User/properties/email",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Scalar property should have \\"example\\" defined.",
|
||||
"message": "Scalar property should have "example" defined.",
|
||||
"ruleId": "scalar-property-missing-example",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -72,19 +72,19 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/User/properties/email",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -114,7 +114,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
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 () => {
|
||||
@@ -143,7 +143,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
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 () => {
|
||||
@@ -177,7 +177,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
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 () => {
|
||||
@@ -202,7 +202,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
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 () => {
|
||||
@@ -233,7 +233,7 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
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 () => {
|
||||
@@ -259,6 +259,6 @@ describe('Oas3.1 scalar-property-missing-example', () => {
|
||||
config: await makeConfig({ 'scalar-property-missing-example': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('Oas3 security-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get/security/0/some",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -35,7 +35,7 @@ describe('Oas3 security-defined', () => {
|
||||
"message": "There is no \`some\` security scheme defined.",
|
||||
"ruleId": "security-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -56,7 +56,7 @@ describe('Oas3 security-defined', () => {
|
||||
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 () => {
|
||||
@@ -77,10 +77,10 @@ describe('Oas3 security-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get",
|
||||
"reportOnKey": true,
|
||||
"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.",
|
||||
"ruleId": "security-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -116,10 +116,10 @@ describe('Oas3 security-defined', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get/security/0/some",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -128,11 +128,11 @@ describe('Oas3 security-defined', () => {
|
||||
"message": "There is no \`some\` security scheme defined.",
|
||||
"ruleId": "security-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1cats/get",
|
||||
"reportOnKey": true,
|
||||
"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.",
|
||||
"ruleId": "security-defined",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -170,6 +170,6 @@ describe('Oas3 security-defined', () => {
|
||||
config: await makeConfig({ 'security-defined': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,10 +36,10 @@ describe('Oas3 spec-strict-refs', () => {
|
||||
config: await makeConfig({ 'spec-strict-refs': 'error' }),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/$ref",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -48,11 +48,11 @@ describe('Oas3 spec-strict-refs', () => {
|
||||
"message": "Field $ref is not expected here.",
|
||||
"ruleId": "spec-strict-refs",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties/$ref",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -61,7 +61,7 @@ describe('Oas3 spec-strict-refs', () => {
|
||||
"message": "Field $ref is not expected here.",
|
||||
"ruleId": "spec-strict-refs",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -29,11 +29,11 @@ describe('Oas3 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -42,12 +42,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`info\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/get/parameters/0",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -56,7 +56,7 @@ describe('Oas3 spec', () => {
|
||||
"message": "Must contain at least one of the following fields: schema, content.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -89,11 +89,11 @@ describe('Oas3 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -102,12 +102,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -116,15 +116,15 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`info\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"from": Object {
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/components/schemas/TestSchema/allOf/0",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/TestRequestBody/content",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -133,7 +133,7 @@ describe('Oas3 spec', () => {
|
||||
"message": "Property \`content\` is not expected here.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -161,11 +161,11 @@ describe('Oas3 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -174,12 +174,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -188,11 +188,11 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`info\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -201,7 +201,7 @@ describe('Oas3 spec', () => {
|
||||
"message": "The \`type\` field must be defined when the \`nullable\` field is used.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -235,11 +235,11 @@ describe('Oas3 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -248,12 +248,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -262,11 +262,11 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`info\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/TestRequestBody/content/application~1json/schema/nullable",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -275,12 +275,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The \`type\` field must be defined when the \`nullable\` field is used.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/schemas",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -289,12 +289,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`content\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/schemas/TestSchema",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -303,7 +303,7 @@ describe('Oas3 spec', () => {
|
||||
"message": "Property \`TestSchema\` is not expected here.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -326,11 +326,11 @@ describe('Oas3 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -339,12 +339,12 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -353,7 +353,7 @@ describe('Oas3 spec', () => {
|
||||
"message": "The field \`info\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -388,20 +388,20 @@ describe('Oas3.1 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/TestSchema/type",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -436,20 +436,20 @@ describe('Oas3.1 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/TestSchema/type/1",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -490,20 +490,20 @@ describe('Oas3.1 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/WrongType/type",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [
|
||||
"suggest": [
|
||||
"object",
|
||||
"array",
|
||||
"string",
|
||||
@@ -513,19 +513,19 @@ describe('Oas3.1 spec', () => {
|
||||
"null",
|
||||
],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/WrongArrayType/type/0",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [
|
||||
"suggest": [
|
||||
"object",
|
||||
"array",
|
||||
"string",
|
||||
@@ -561,11 +561,11 @@ describe('Oas3.1 spec', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -574,12 +574,12 @@ describe('Oas3.1 spec', () => {
|
||||
"message": "Must contain at least one of the following fields: paths, components, webhooks.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -588,12 +588,12 @@ describe('Oas3.1 spec', () => {
|
||||
"message": "The field \`title\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -602,7 +602,7 @@ describe('Oas3.1 spec', () => {
|
||||
"message": "The field \`version\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('Oas3 tag-description', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/tags/0/description",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -35,7 +35,7 @@ describe('Oas3 tag-description', () => {
|
||||
"message": "Tag object should contain \`description\` field.",
|
||||
"ruleId": "tag-description",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -60,6 +60,6 @@ describe('Oas3 tag-description', () => {
|
||||
config: await makeConfig({ 'tag-description': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/tags/0",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -35,7 +35,7 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
"message": "The \`tags\` array should be in alphabetical order.",
|
||||
"ruleId": "tags-alphabetical",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -59,7 +59,7 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
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 () => {
|
||||
@@ -81,10 +81,10 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/tags/0",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -93,7 +93,7 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
"message": "The \`tags\` array should be in alphabetical order.",
|
||||
"ruleId": "tags-alphabetical",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -117,6 +117,6 @@ describe('Oas3 tags-alphabetical', () => {
|
||||
config: await makeConfig({ 'tags-alphabetical': { severity: 'error', ignoreCase: true } }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,39 +58,39 @@ describe('Oas3 assertions', () => {
|
||||
it('should return the right visitor structure', () => {
|
||||
const visitors = Assertions(opts as any);
|
||||
expect(visitors).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"Operation": Object {
|
||||
[
|
||||
{
|
||||
"Operation": {
|
||||
"enter": [Function],
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"Operation": Object {
|
||||
"PathItem": Object {
|
||||
{
|
||||
"Operation": {
|
||||
"PathItem": {
|
||||
"enter": [Function],
|
||||
},
|
||||
"skip": [Function],
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"Operation": Object {
|
||||
"PathItem": Object {
|
||||
{
|
||||
"Operation": {
|
||||
"PathItem": {
|
||||
"enter": [Function],
|
||||
},
|
||||
"skip": [Function],
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"Bar": Object {
|
||||
"Baz": Object {
|
||||
"Foo": Object {
|
||||
{
|
||||
"Bar": {
|
||||
"Baz": {
|
||||
"Foo": {
|
||||
"enter": [Function],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"any": Object {
|
||||
{
|
||||
"any": {
|
||||
"enter": [Function],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -59,11 +59,11 @@ describe('Oas3 assertions', () => {
|
||||
);
|
||||
|
||||
expect(visitors).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"Foo": Object {
|
||||
"Bar": Object {
|
||||
"Roof": Object {
|
||||
"Bar": Object {
|
||||
{
|
||||
"Foo": {
|
||||
"Bar": {
|
||||
"Roof": {
|
||||
"Bar": {
|
||||
"enter": [Function],
|
||||
},
|
||||
"skip": [Function],
|
||||
@@ -100,10 +100,10 @@ describe('Oas3 assertions', () => {
|
||||
);
|
||||
|
||||
expect(visitors).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"Operation": Object {
|
||||
"Responses": Object {
|
||||
"MediaTypesMap": Object {
|
||||
{
|
||||
"Operation": {
|
||||
"Responses": {
|
||||
"MediaTypesMap": {
|
||||
"enter": [Function],
|
||||
},
|
||||
"skip": [Function],
|
||||
|
||||
@@ -25,10 +25,10 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/parameters/0/name",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -37,7 +37,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
||||
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
|
||||
"ruleId": "boolean-parameter-prefixes",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -76,7 +76,7 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
||||
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 () => {
|
||||
@@ -105,6 +105,6 @@ describe('oas2 boolean-parameter-prefixes', () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,10 +36,10 @@ describe('Oas2 response-contains-header', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/201/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/404/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -169,6 +169,6 @@ describe('Oas2 response-contains-header', () => {
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`Array []`);
|
||||
expect(results).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,10 +42,10 @@ describe('Oas2 response-contains-property', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1accounts~1{accountId}/get/responses/200/schema/properties",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -150,6 +150,6 @@ describe('Oas2 response-contains-property', () => {
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`Array []`);
|
||||
expect(results).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,8 +22,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/title",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -52,8 +52,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/description",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -82,8 +82,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/termsOfService",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -115,7 +115,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/contact/url",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -175,8 +175,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/contact/email",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -206,7 +206,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if the License Object missing field Name', async () => {
|
||||
@@ -231,8 +231,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/license",
|
||||
"message": "The field \`name\` must be present on this level.",
|
||||
},
|
||||
@@ -263,8 +263,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/license/url",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -293,7 +293,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if the Version field is not provided', async () => {
|
||||
@@ -315,8 +315,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info",
|
||||
"message": "The field \`version\` must be present on this level.",
|
||||
},
|
||||
@@ -344,8 +344,8 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/version",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report of a valid PUT operation object', async () => {
|
||||
@@ -48,7 +48,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report of a valid Post operation object', async () => {
|
||||
@@ -82,7 +82,7 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report of a valid delete operation object', async () => {
|
||||
@@ -118,6 +118,6 @@ describe('OpenAPI Schema 2.0', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if Path object is empty ', async () => {
|
||||
@@ -38,7 +38,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if Path object is not present ', async () => {
|
||||
@@ -54,8 +54,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/",
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
},
|
||||
@@ -77,7 +77,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
//Check: no error
|
||||
@@ -101,8 +101,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/paths/ping",
|
||||
"message": "Property \`ping\` is not expected here.",
|
||||
},
|
||||
@@ -134,7 +134,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
'paths-identical': 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report valid matching URLs', async () => {
|
||||
@@ -161,7 +161,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report in case of ambiguous matching ', async () => {
|
||||
@@ -188,7 +188,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if Path Item is empty ', async () => {
|
||||
@@ -206,7 +206,7 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report of a valid Parameter Object', async () => {
|
||||
@@ -240,6 +240,6 @@ describe('OpenAPI Schema', () => {
|
||||
await lintDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,6 +30,6 @@ describe('Referenceable scalars', () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,7 +42,9 @@ import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-
|
||||
import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length';
|
||||
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,
|
||||
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
||||
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
||||
|
||||
@@ -26,10 +26,10 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test/parameters/0/name",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -38,7 +38,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
"message": "Boolean parameter \`a\` should have \`is\` or \`has\` prefix.",
|
||||
"ruleId": "boolean-parameter-prefixes",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -77,7 +77,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
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 () => {
|
||||
@@ -106,6 +106,6 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,10 +40,10 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
@@ -54,7 +54,7 @@ describe('Oas3 component-name-unique', () => {
|
||||
- /test.yaml#/components/schemas/SomeSchema",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -95,24 +95,24 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/schemas/SomeSchema
|
||||
- /SomeSchema.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/schemas/SomeSchema
|
||||
- /SomeSchema.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('should not report on multiple schemas with different names', async () => {
|
||||
@@ -150,7 +150,7 @@ describe('Oas3 component-name-unique', () => {
|
||||
additionalDocuments
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []');
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -198,24 +198,24 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/parameters/ParameterOne
|
||||
- /test.yaml#/components/parameters/ParameterOne",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/parameters/ParameterOne
|
||||
- /test.yaml#/components/parameters/ParameterOne",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
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(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/parameters/ParameterOne
|
||||
- /ParameterOne.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'parameters/ParameterOne' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/parameters/ParameterOne
|
||||
- /ParameterOne.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('should not report on multiple parameters with different component names', async () => {
|
||||
@@ -319,7 +319,7 @@ describe('Oas3 component-name-unique', () => {
|
||||
additionalDocuments
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []');
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -374,24 +374,24 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/responses/SuccessResponse
|
||||
- /test.yaml#/components/responses/SuccessResponse",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/responses/SuccessResponse
|
||||
- /test.yaml#/components/responses/SuccessResponse",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
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(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/responses/SuccessResponse
|
||||
- /SuccessResponse.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'responses/SuccessResponse' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/responses/SuccessResponse
|
||||
- /SuccessResponse.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('should not report on multiple responses with different component names', async () => {
|
||||
@@ -509,7 +509,7 @@ describe('Oas3 component-name-unique', () => {
|
||||
additionalDocuments
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []');
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -561,24 +561,24 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
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(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /MyRequestBody.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /MyRequestBody.yaml",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
it('should not report on multiple responses with different component names', async () => {
|
||||
@@ -694,7 +694,7 @@ describe('Oas3 component-name-unique', () => {
|
||||
additionalDocuments
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot('Array []');
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -757,39 +757,39 @@ describe('Oas3 component-name-unique', () => {
|
||||
);
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/schemas/SomeSchema
|
||||
- /test.yaml#/components/schemas/SomeSchema",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'schemas/SomeSchema' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/schemas/SomeSchema
|
||||
- /test.yaml#/components/schemas/SomeSchema",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
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(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": false,
|
||||
"source": "/foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component 'requestBodies/MyRequestBody' is not unique. It is defined at:
|
||||
- /foobar.yaml#/components/requestBodies/MyRequestBody
|
||||
- /test.yaml#/components/requestBodies/MyRequestBody",
|
||||
"ruleId": "component-name-unique",
|
||||
"severity": "error",
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,10 +28,10 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -40,11 +40,11 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
"message": "Server variable with \`enum\` must be a non-empty array.",
|
||||
"ruleId": "no-server-variables-empty-enum",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"ruleId": "no-server-variables-empty-enum",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -82,10 +82,10 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers",
|
||||
"reportOnKey": true,
|
||||
"source": "",
|
||||
@@ -94,7 +94,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
"message": "Server variable with \`enum\` must be a non-empty array.",
|
||||
"ruleId": "no-server-variables-empty-enum",
|
||||
"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' }),
|
||||
});
|
||||
|
||||
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 () => {
|
||||
@@ -144,7 +144,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
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 () => {
|
||||
@@ -171,7 +171,7 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
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 () => {
|
||||
@@ -200,6 +200,6 @@ describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
||||
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,10 +24,10 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/examples/some/value",
|
||||
"reportOnKey": true,
|
||||
"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.",
|
||||
"ruleId": "no-example-value-and-externalValue",
|
||||
"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' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,14 +37,14 @@ describe('no-invalid-media-type-examples', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"from": Object {
|
||||
[
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/a",
|
||||
"reportOnKey": false,
|
||||
"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.",
|
||||
"ruleId": "no-invalid-media-type-examples",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"from": Object {
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/b",
|
||||
"reportOnKey": false,
|
||||
"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.",
|
||||
"ruleId": "no-invalid-media-type-examples",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -115,14 +115,14 @@ describe('no-invalid-media-type-examples', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"from": Object {
|
||||
[
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/example/c",
|
||||
"reportOnKey": true,
|
||||
"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\`.",
|
||||
"ruleId": "no-invalid-media-type-examples",
|
||||
"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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -274,14 +274,14 @@ describe('no-invalid-media-type-examples', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"from": Object {
|
||||
[
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/examples/test/value/a",
|
||||
"reportOnKey": false,
|
||||
"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.",
|
||||
"ruleId": "no-invalid-media-type-examples",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -321,7 +321,7 @@ describe('no-invalid-media-type-examples', () => {
|
||||
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 () => {
|
||||
@@ -353,7 +353,7 @@ describe('no-invalid-media-type-examples', () => {
|
||||
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 () => {
|
||||
@@ -388,7 +388,7 @@ describe('no-invalid-media-type-examples', () => {
|
||||
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 () => {
|
||||
@@ -417,23 +417,23 @@ describe('no-invalid-media-type-examples', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"from": Object {
|
||||
[
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pet/get/responses/200/content/application~1json/schema",
|
||||
"reportOnKey": false,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -468,6 +468,6 @@ describe('no-invalid-media-type-examples', () => {
|
||||
config: await makeConfig({ 'no-invalid-media-type-examples': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,10 +21,10 @@ describe('Oas3 oas3-no-server-example.com', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers/0/url",
|
||||
"reportOnKey": false,
|
||||
"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.",
|
||||
"ruleId": "no-server-example.com",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -55,7 +55,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
|
||||
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 () => {
|
||||
@@ -75,10 +75,10 @@ describe('Oas3 oas3-no-server-example.com', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers/0/url",
|
||||
"reportOnKey": false,
|
||||
"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.",
|
||||
"ruleId": "no-server-example.com",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -21,10 +21,10 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers/0/url",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -33,7 +33,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
||||
"message": "Server \`url\` should not have a trailing slash.",
|
||||
"ruleId": "no-server-trailing-slash",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -55,7 +55,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
||||
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 () => {
|
||||
@@ -74,6 +74,6 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
||||
config: await makeConfig({ 'no-server-trailing-slash': 'error' }),
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,84 +46,84 @@ describe('Oas3 no-unused-components', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"unused\\" is never used.",
|
||||
"message": "Component: "unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/Unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"Unused\\" is never used.",
|
||||
"message": "Component: "Unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/responses/unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"unused\\" is never used.",
|
||||
"message": "Component: "unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/examples/unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"unused\\" is never used.",
|
||||
"message": "Component: "unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/requestBodies/unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"unused\\" is never used.",
|
||||
"message": "Component: "unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/headers/unused",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
],
|
||||
"message": "Component: \\"unused\\" is never used.",
|
||||
"message": "Component: "unused" is never used.",
|
||||
"ruleId": "no-unused-components",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -35,10 +35,10 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
|
||||
config: await makeConfig({ 'operation-4xx-problem-details-rfc7807': 'error' }),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get/responses/400",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -47,7 +47,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
|
||||
"message": "Response \`4xx\` must have content-type \`application/problem+json\`.",
|
||||
"ruleId": "operation-4xx-problem-details-rfc7807",
|
||||
"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' }),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema/properties/type",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -94,7 +94,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
|
||||
"message": "SchemaProperties object should contain \`type\` field.",
|
||||
"ruleId": "operation-4xx-problem-details-rfc7807",
|
||||
"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' }),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1pets/get/responses/400/content/application~1problem+json/schema",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -137,7 +137,7 @@ describe('Oas3 operation-4xx-problem-details-rfc7807', () => {
|
||||
"message": "MediaType object should contain \`schema\` field.",
|
||||
"ruleId": "operation-4xx-problem-details-rfc7807",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -34,10 +34,10 @@ describe('Oas3 response-contains-header', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/200/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -117,10 +117,10 @@ describe('Oas3 response-contains-header', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/200/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/400/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -360,10 +360,10 @@ describe('Oas3 response-contains-header', () => {
|
||||
});
|
||||
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1test~1/put/responses/200/headers",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -34,10 +34,10 @@ describe('Oas3 response-contains-property', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -110,10 +110,10 @@ describe('Oas3 response-contains-property', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/201/content/application~1json/schema/properties",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/400/content/application~1json/schema/properties",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -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 () => {
|
||||
@@ -367,10 +367,10 @@ describe('Oas3 response-contains-property', () => {
|
||||
}),
|
||||
});
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/paths/~1store~1subscribe/post/responses/200/content/application~1json/schema/properties",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -36,10 +36,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
|
||||
});
|
||||
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/my Param",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/schemas/first schema",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/responses/400 status",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/examples/invalid identifier",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"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 () => {
|
||||
@@ -240,10 +240,10 @@ describe('Oas3 spec-components-invalid-map-name', () => {
|
||||
});
|
||||
|
||||
expect(results).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components/parameters/my Param",
|
||||
"reportOnKey": true,
|
||||
"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",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -37,5 +37,5 @@ it('should not fail on valid callbacks object', async () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
@@ -25,8 +25,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/title",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -58,8 +58,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/description",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -91,8 +91,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/termsOfService",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -127,7 +127,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if in the Contact Object in URL field is not string', async () => {
|
||||
@@ -157,8 +157,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/contact/url",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -193,8 +193,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/contact/email",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -227,7 +227,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if the License Object missing field Name', async () => {
|
||||
@@ -255,8 +255,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/license",
|
||||
"message": "The field \`name\` must be present on this level.",
|
||||
},
|
||||
@@ -290,8 +290,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/license/url",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -323,7 +323,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if the Version field is not provided', async () => {
|
||||
@@ -348,8 +348,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info",
|
||||
"message": "The field \`version\` must be present on this level.",
|
||||
},
|
||||
@@ -380,8 +380,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/info/version",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ it('should not report if summary field is valid', async () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/paths/~1ping/summary",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -83,7 +83,7 @@ it('should not report if description field is valid', async () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/paths/~1ping/description",
|
||||
"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, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
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, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if Path object is empty ', async () => {
|
||||
@@ -44,7 +44,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if Path object is not present ', async () => {
|
||||
@@ -63,8 +63,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/",
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
},
|
||||
@@ -89,7 +89,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
//Check: no error
|
||||
@@ -116,8 +116,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/paths/ping",
|
||||
"message": "Property \`ping\` is not expected here.",
|
||||
},
|
||||
@@ -153,8 +153,8 @@ describe('OpenAPI Schema', () => {
|
||||
'no-identical-paths': 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/paths/~1pets~1{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, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report in case of ambiguous matching ', async () => {
|
||||
@@ -219,7 +219,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if Path Item is empty ', async () => {
|
||||
@@ -240,7 +240,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report of a valid Parameter Object', async () => {
|
||||
@@ -279,6 +279,6 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 () => {
|
||||
@@ -72,6 +72,6 @@ describe('Referenceable scalars', () => {
|
||||
})
|
||||
),
|
||||
});
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report on empty server URL', async () => {
|
||||
@@ -51,8 +51,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/url",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -83,8 +83,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0",
|
||||
"message": "The field \`url\` must be present on this level.",
|
||||
},
|
||||
@@ -116,8 +116,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/description",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -147,7 +147,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if fields type in servers are not array', async () => {
|
||||
@@ -173,8 +173,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers",
|
||||
"message": "Expected type \`ServerList\` (array) but got \`object\`",
|
||||
},
|
||||
@@ -209,7 +209,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if variables are used for a server configuration', async () => {
|
||||
@@ -244,7 +244,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should report if array in enum is empty', async () => {
|
||||
@@ -279,8 +279,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/variables/port/enum",
|
||||
"message": "Expected type \`array\` but got \`null\`.",
|
||||
},
|
||||
@@ -319,8 +319,8 @@ describe('OpenAPI Schema', () => {
|
||||
'no-undefined-server-variable': 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/url",
|
||||
"message": "The \`basePath\` variable is not defined in the \`variables\` objects.",
|
||||
},
|
||||
@@ -359,12 +359,12 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/variables/username",
|
||||
"message": "The field \`default\` must be present on this level.",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"location": "#/servers/0/variables/port",
|
||||
"message": "The field \`default\` must be present on this level.",
|
||||
},
|
||||
@@ -405,8 +405,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/variables/username/default",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -448,8 +448,8 @@ describe('OpenAPI Schema', () => {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"location": "#/servers/0/variables/username/description",
|
||||
"message": "Expected type \`string\` but got \`null\`.",
|
||||
},
|
||||
@@ -476,7 +476,7 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
|
||||
it('should not report if servers property is an empty array', async () => {
|
||||
@@ -500,6 +500,6 @@ describe('OpenAPI Schema', () => {
|
||||
await validateDoc(source, {
|
||||
spec: 'error',
|
||||
})
|
||||
).toMatchInlineSnapshot(`Array []`);
|
||||
).toMatchInlineSnapshot(`[]`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,11 +45,11 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/contact/url",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -58,12 +58,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`string\` but got \`array\`.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/contact/email",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -72,12 +72,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`string\` but got \`boolean\`.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/license",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -86,15 +86,15 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`License\` (object) but got \`string\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"from": Object {
|
||||
{
|
||||
"from": {
|
||||
"pointer": "#/servers/0/url",
|
||||
"source": "foobar.yaml",
|
||||
},
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers/0/variables/a",
|
||||
"reportOnKey": true,
|
||||
"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.",
|
||||
"ruleId": "no-undefined-server-variable",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/servers/0/variables/a/enum/0",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -117,12 +117,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`string\` but got \`integer\`.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/tags/0",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -131,12 +131,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`Tag\` (object) but got \`number\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/tags/1",
|
||||
"reportOnKey": false,
|
||||
"source": "foobar.yaml",
|
||||
@@ -145,7 +145,7 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Expected type \`Tag\` (object) but got \`string\`",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -179,11 +179,11 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/components1",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -192,13 +192,13 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Property \`components1\` is not expected here.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [
|
||||
"suggest": [
|
||||
"components",
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/openapi",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -207,12 +207,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Servers must be present.",
|
||||
"ruleId": "no-empty-servers",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info/contact/test",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -221,7 +221,7 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Property \`test\` is not expected here.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -250,11 +250,11 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
});
|
||||
|
||||
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -263,11 +263,11 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "The field \`paths\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
"location": Array [
|
||||
Object {
|
||||
{
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/openapi",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -276,12 +276,12 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "Servers must be present.",
|
||||
"ruleId": "no-empty-servers",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"from": undefined,
|
||||
"location": Array [
|
||||
Object {
|
||||
"location": [
|
||||
{
|
||||
"pointer": "#/info",
|
||||
"reportOnKey": true,
|
||||
"source": "foobar.yaml",
|
||||
@@ -290,7 +290,7 @@ describe('Oas3 Structural visitor basic', () => {
|
||||
"message": "The field \`title\` must be present on this level.",
|
||||
"ruleId": "spec",
|
||||
"severity": "error",
|
||||
"suggest": Array [],
|
||||
"suggest": [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -53,7 +53,7 @@ import { RequiredStringPropertyMissingMinLength } from '../common/required-strin
|
||||
import { SpecStrictRefs } from '../common/spec-strict-refs';
|
||||
import { ComponentNameUnique } from './component-name-unique';
|
||||
|
||||
export const rules = {
|
||||
export const rules: Oas3RuleSet<'built-in'> = {
|
||||
spec: Spec,
|
||||
'info-contact': InfoContact,
|
||||
'info-license': InfoLicense,
|
||||
@@ -64,7 +64,6 @@ export const rules = {
|
||||
assertions: Assertions,
|
||||
'operation-operationId-unique': OperationIdUnique,
|
||||
'operation-parameters-unique': OperationParametersUnique,
|
||||
'path-parameters-defined': PathParamsDefined,
|
||||
'operation-tag-defined': OperationTagDefined,
|
||||
'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
|
||||
'no-enum-type-mismatch': NoEnumTypeMismatch,
|
||||
@@ -81,6 +80,7 @@ export const rules = {
|
||||
'operation-description': OperationDescription,
|
||||
'no-unused-components': NoUnusedComponents,
|
||||
'path-not-include-query': PathNotIncludeQuery,
|
||||
'path-parameters-defined': PathParamsDefined,
|
||||
'path-params-defined': PathParamsDefined,
|
||||
'parameter-description': ParameterDescription,
|
||||
'operation-singular-tag': OperationSingularTag,
|
||||
@@ -108,6 +108,6 @@ export const rules = {
|
||||
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
||||
'spec-strict-refs': SpecStrictRefs,
|
||||
'component-name-unique': ComponentNameUnique,
|
||||
} as Oas3RuleSet;
|
||||
};
|
||||
|
||||
export const preprocessors = {};
|
||||
|
||||
@@ -4,64 +4,96 @@ import { NodeType, listOf } from '.';
|
||||
import { Oas3_1Types } from './oas3_1';
|
||||
import { omitObjectProps, pickObjectProps, isCustomRuleId } from '../utils';
|
||||
|
||||
const builtInRulesList = [
|
||||
const builtInCommonRules = [
|
||||
'spec',
|
||||
'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',
|
||||
'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-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',
|
||||
'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-params-defined',
|
||||
'parameter-description',
|
||||
'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-parameters-defined',
|
||||
'path-segment-plural',
|
||||
'no-invalid-schema-examples',
|
||||
'no-invalid-parameter-examples',
|
||||
'response-contains-header',
|
||||
'response-contains-property',
|
||||
'scalar-property-missing-example',
|
||||
'spec-components-invalid-map-name',
|
||||
'paths-kebab-case',
|
||||
'required-string-property-missing-min-length',
|
||||
'response-contains-header',
|
||||
'scalar-property-missing-example',
|
||||
'security-defined',
|
||||
'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',
|
||||
'channels-kebab-case',
|
||||
'no-channel-trailing-slash',
|
||||
];
|
||||
'no-empty-servers',
|
||||
'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 = [
|
||||
'any',
|
||||
@@ -138,14 +170,17 @@ const ConfigStyleguide: NodeType = {
|
||||
oas2Rules: 'Rules',
|
||||
oas3_0Rules: 'Rules',
|
||||
oas3_1Rules: 'Rules',
|
||||
async2Rules: 'Rules',
|
||||
preprocessors: { type: 'object' },
|
||||
oas2Preprocessors: { type: 'object' },
|
||||
oas3_0Preprocessors: { type: 'object' },
|
||||
oas3_1Preprocessors: { type: 'object' },
|
||||
async2Preprocessors: { type: 'object' },
|
||||
decorators: { type: 'object' },
|
||||
oas2Decorators: { type: 'object' },
|
||||
oas3_0Decorators: { type: 'object' },
|
||||
oas3_1Decorators: { type: 'object' },
|
||||
async2Decorators: { type: 'object' },
|
||||
},
|
||||
};
|
||||
|
||||
@@ -243,7 +278,7 @@ const Rules: NodeType = {
|
||||
} else if (key.startsWith('assert/')) {
|
||||
// keep the old assert/ prefix as an alias
|
||||
return 'Assert';
|
||||
} else if (builtInRulesList.includes(key) || isCustomRuleId(key)) {
|
||||
} else if (builtInRules.includes(key as BuiltInRuleId) || isCustomRuleId(key)) {
|
||||
if (typeof value === 'string') {
|
||||
return { enum: ['error', 'warn', 'off'] };
|
||||
} else {
|
||||
|
||||
@@ -73,11 +73,11 @@ type VisitObject<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 VisitorNode<T> = {
|
||||
export type VisitorNode<T> = {
|
||||
ruleId: string;
|
||||
severity: ProblemSeverity;
|
||||
context: VisitorLevelContext | VisitorSkippedLevelContext;
|
||||
@@ -113,7 +113,7 @@ export type VisitorSkippedLevelContext = {
|
||||
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 = {
|
||||
any?:
|
||||
|
||||
@@ -4,6 +4,9 @@ import type {
|
||||
NormalizedOasVisitors,
|
||||
VisitorSkippedLevelContext,
|
||||
VisitFunction,
|
||||
BaseVisitor,
|
||||
NormalizeVisitor,
|
||||
VisitorNode,
|
||||
} from './visitors';
|
||||
import type { ResolvedRefMap, Document } from './resolve';
|
||||
import type { NormalizedNodeType } from './types';
|
||||
@@ -15,13 +18,23 @@ import { ResolveError, YamlParseError, Source, makeRefId } from './resolve';
|
||||
import { SpecVersion } from './oas-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> =
|
||||
| { node: T; location: Location; 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 = {
|
||||
report(problem: Problem): void;
|
||||
@@ -85,7 +98,7 @@ export type WalkContext = {
|
||||
};
|
||||
|
||||
function collectParents(ctx: VisitorLevelContext) {
|
||||
const parents: Record<string, any> = {};
|
||||
const parents: Record<string, unknown> = {};
|
||||
while (ctx.parent) {
|
||||
parents[ctx.parent.type.name] = ctx.parent.activatedOn?.value.node;
|
||||
ctx = ctx.parent;
|
||||
@@ -104,7 +117,7 @@ function collectParentsLocations(ctx: VisitorLevelContext) {
|
||||
return locations;
|
||||
}
|
||||
|
||||
export function walkDocument<T>(opts: {
|
||||
export function walkDocument<T extends BaseVisitor>(opts: {
|
||||
document: Document;
|
||||
rootType: NormalizedNodeType;
|
||||
normalizedVisitors: NormalizedOasVisitors<T>;
|
||||
@@ -112,7 +125,7 @@ export function walkDocument<T>(opts: {
|
||||
ctx: WalkContext;
|
||||
}) {
|
||||
const { document, rootType, normalizedVisitors, resolvedRefMap, ctx } = opts;
|
||||
const seenNodesPerType: Record<string, Set<any>> = {};
|
||||
const seenNodesPerType: Record<string, Set<unknown>> = {};
|
||||
const ignoredNodes = new Set<string>();
|
||||
|
||||
walkNode(document.parsed, rootType, new Location(document.source, '#/'), undefined, '');
|
||||
@@ -185,7 +198,7 @@ export function walkDocument<T>(opts: {
|
||||
|
||||
const anyEnterVisitors = normalizedVisitors.any.enter;
|
||||
const currentEnterVisitors = anyEnterVisitors.concat(
|
||||
normalizedVisitors[type.name]?.enter || []
|
||||
(normalizedVisitors[type.name]?.enter as NormalizeVisitor<VisitorNode<unknown>[]>) || []
|
||||
);
|
||||
|
||||
const activatedContexts: Array<VisitorSkippedLevelContext | VisitorLevelContext> = [];
|
||||
@@ -328,7 +341,7 @@ export function walkDocument<T>(opts: {
|
||||
if (context.isSkippedLevel) {
|
||||
context.seen.delete(resolvedNode);
|
||||
} else {
|
||||
context.activatedOn = popStack(context.activatedOn) as any;
|
||||
context.activatedOn = popStack(context.activatedOn);
|
||||
if (context.parent) {
|
||||
let ctx: VisitorLevelContext | null = context.parent;
|
||||
while (ctx) {
|
||||
@@ -378,9 +391,9 @@ export function walkDocument<T>(opts: {
|
||||
|
||||
// returns true ignores all the next visitors on the specific node
|
||||
function visitWithContext(
|
||||
visit: VisitFunction<any>,
|
||||
resolvedNode: any,
|
||||
node: any,
|
||||
visit: VisitFunction<unknown>,
|
||||
resolvedNode: unknown,
|
||||
node: unknown,
|
||||
context: VisitorLevelContext,
|
||||
ruleId: string,
|
||||
severity: ProblemSeverity
|
||||
|
||||
Reference in New Issue
Block a user