@redocly/openapi-core 1.0.0-beta.49 → 1.0.0-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/normalizeVisitors.test.ts +1 -1
- package/__tests__/utils.ts +1 -1
- package/__tests__/walk.test.ts +77 -4
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -1
- package/lib/benchmark/utils.d.ts +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +10 -10
- package/lib/config/builtIn.d.ts +2 -1
- package/lib/config/builtIn.js +9 -1
- package/lib/config/config.d.ts +5 -7
- package/lib/config/config.js +40 -100
- package/lib/config/load.d.ts +2 -0
- package/lib/config/load.js +65 -0
- package/lib/config/rules.d.ts +1 -1
- package/lib/format/codeframes.js +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.js +13 -11
- package/lib/lint.d.ts +6 -19
- package/lib/lint.js +13 -43
- package/lib/oas-types.d.ts +19 -0
- package/lib/oas-types.js +42 -0
- package/lib/resolve.d.ts +6 -2
- package/lib/resolve.js +18 -5
- package/lib/rules/ajv.d.ts +3 -3
- package/lib/rules/ajv.js +21 -18
- package/lib/rules/common/info-contact.js +2 -1
- package/lib/rules/common/info-description.js +2 -1
- package/lib/rules/common/info-license-url.js +2 -1
- package/lib/rules/common/license-url.js +2 -1
- package/lib/rules/common/no-ambiguous-paths.js +2 -1
- package/lib/rules/common/no-enum-type-mismatch.js +2 -1
- package/lib/rules/common/no-identical-paths.js +2 -1
- package/lib/rules/common/no-path-trailing-slash.js +2 -1
- package/lib/rules/common/operation-2xx-response.js +2 -1
- package/lib/rules/common/operation-description.js +2 -1
- package/lib/rules/common/operation-operationId-unique.js +2 -1
- package/lib/rules/common/operation-operationId-url-safe.js +2 -1
- package/lib/rules/common/operation-operationId.js +9 -4
- package/lib/rules/common/operation-parameters-unique.js +2 -1
- package/lib/rules/common/operation-security-defined.js +2 -1
- package/lib/rules/common/operation-singular-tag.js +2 -1
- package/lib/rules/common/operation-summary.js +2 -1
- package/lib/rules/common/operation-tag-defined.js +2 -1
- package/lib/rules/common/parameter-description.js +2 -1
- package/lib/rules/common/path-declaration-must-exist.js +2 -1
- package/lib/rules/common/path-http-verbs-order.js +2 -1
- package/lib/rules/common/path-not-include-query.js +2 -1
- package/lib/rules/common/path-params-defined.js +3 -2
- package/lib/rules/common/paths-kebab-case.js +2 -1
- package/lib/rules/common/registry-dependencies.js +2 -1
- package/lib/rules/common/spec.js +5 -2
- package/lib/rules/common/tag-description.js +2 -1
- package/lib/rules/common/tags-alphabetical.js +2 -1
- package/lib/rules/no-unresolved-refs.js +2 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +1 -1
- package/lib/rules/oas3/boolean-parameter-prefixes.js +2 -1
- package/lib/rules/oas3/index.d.ts +2 -1
- package/lib/rules/oas3/index.js +2 -2
- package/lib/rules/oas3/no-empty-servers.js +2 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.js +2 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +20 -10
- package/lib/rules/oas3/no-server-example.com.js +2 -1
- package/lib/rules/oas3/no-server-trailing-slash.js +2 -1
- package/lib/rules/oas3/no-servers-empty-enum.js +2 -1
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -1
- package/lib/rules/oas3/no-unused-components.js +2 -1
- package/lib/rules/other/stats.js +2 -1
- package/lib/types/oas2.js +1 -1
- package/lib/types/oas3.js +1 -1
- package/lib/types/oas3_1.js +1 -1
- package/lib/utils.d.ts +1 -1
- package/lib/visitors.d.ts +3 -1
- package/lib/visitors.js +4 -4
- package/lib/walk.d.ts +1 -1
- package/lib/walk.js +11 -2
- package/package.json +7 -7
- package/src/__tests__/lint.test.ts +44 -0
- package/src/benchmark/benches/recommended-oas3.bench.ts +2 -1
- package/src/benchmark/benchmark.js +3 -1
- package/src/benchmark/utils.ts +1 -1
- package/src/bundle.ts +2 -2
- package/src/config/__tests__/resolve-plugins.test.ts +1 -1
- package/src/config/builtIn.ts +11 -1
- package/src/config/config.ts +30 -78
- package/src/config/load.ts +60 -0
- package/src/config/rules.ts +1 -1
- package/src/format/codeframes.ts +1 -1
- package/src/index.ts +4 -3
- package/src/lint.ts +19 -56
- package/src/oas-types.ts +58 -0
- package/src/resolve.ts +17 -4
- package/src/rules/__tests__/config.ts +10 -0
- package/src/rules/__tests__/no-unresolved-refs.test.ts +9 -21
- package/src/rules/ajv.ts +27 -23
- package/src/rules/common/__tests__/info-description.test.ts +8 -16
- package/src/rules/common/__tests__/info-license.test.ts +3 -3
- package/src/rules/common/__tests__/license-url.test.ts +3 -3
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +50 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +2 -2
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +4 -4
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +2 -5
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +5 -17
- package/src/rules/common/__tests__/operation-security-defined.test.ts +3 -3
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +3 -3
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +3 -3
- package/src/rules/common/__tests__/path-not-include-query.test.ts +3 -3
- package/src/rules/common/__tests__/path-params-defined.test.ts +4 -4
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +3 -3
- package/src/rules/common/__tests__/tag-description.test.ts +3 -3
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +3 -3
- package/src/rules/common/operation-operationId.ts +7 -3
- package/src/rules/common/spec.ts +4 -1
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -6
- package/src/rules/oas2/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas2/index.ts +1 -10
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -10
- package/src/rules/oas3/__tests__/fixtures/common.yaml +11 -0
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +7 -7
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +3 -9
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +103 -29
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +2 -2
- package/src/rules/oas3/__tests__/spec/spec.test.ts +3 -1
- package/src/rules/oas3/__tests__/spec/utils.ts +2 -0
- package/src/rules/oas3/index.ts +3 -4
- package/src/rules/oas3/no-invalid-media-type-examples.ts +27 -19
- package/src/visitors.ts +12 -8
- package/src/walk.ts +24 -8
- package/tsconfig.tsbuildinfo +1 -3084
|
@@ -2,10 +2,10 @@ import path = require('path');
|
|
|
2
2
|
import { outdent } from 'outdent';
|
|
3
3
|
|
|
4
4
|
import { lintDocument } from '../../lint';
|
|
5
|
-
import { LintConfig } from '../..';
|
|
6
5
|
import { BaseResolver } from '../../resolve';
|
|
7
6
|
|
|
8
7
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../__tests__/utils';
|
|
8
|
+
import { makeConfig } from './config';
|
|
9
9
|
|
|
10
10
|
describe('oas3 boolean-parameter-prefixes', () => {
|
|
11
11
|
it('should report on unresolved $ref', async () => {
|
|
@@ -24,11 +24,8 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
24
24
|
const results = await lintDocument({
|
|
25
25
|
externalRefResolver: new BaseResolver(),
|
|
26
26
|
document,
|
|
27
|
-
config:
|
|
28
|
-
|
|
29
|
-
rules: {
|
|
30
|
-
'no-unresolved-refs': 'error',
|
|
31
|
-
},
|
|
27
|
+
config: makeConfig({
|
|
28
|
+
'no-unresolved-refs': 'error',
|
|
32
29
|
}),
|
|
33
30
|
});
|
|
34
31
|
|
|
@@ -67,11 +64,8 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
67
64
|
const results = await lintDocument({
|
|
68
65
|
externalRefResolver: new BaseResolver(),
|
|
69
66
|
document,
|
|
70
|
-
config:
|
|
71
|
-
|
|
72
|
-
rules: {
|
|
73
|
-
'no-unresolved-refs': 'error',
|
|
74
|
-
},
|
|
67
|
+
config: makeConfig({
|
|
68
|
+
'no-unresolved-refs': 'error',
|
|
75
69
|
}),
|
|
76
70
|
});
|
|
77
71
|
|
|
@@ -127,11 +121,8 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
127
121
|
const results = await lintDocument({
|
|
128
122
|
externalRefResolver: new BaseResolver(),
|
|
129
123
|
document,
|
|
130
|
-
config:
|
|
131
|
-
|
|
132
|
-
rules: {
|
|
133
|
-
'no-unresolved-refs': 'error',
|
|
134
|
-
},
|
|
124
|
+
config: makeConfig({
|
|
125
|
+
'no-unresolved-refs': 'error',
|
|
135
126
|
}),
|
|
136
127
|
});
|
|
137
128
|
|
|
@@ -154,11 +145,8 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
154
145
|
const results = await lintDocument({
|
|
155
146
|
externalRefResolver: new BaseResolver(),
|
|
156
147
|
document,
|
|
157
|
-
config:
|
|
158
|
-
|
|
159
|
-
rules: {
|
|
160
|
-
'no-unresolved-refs': 'error',
|
|
161
|
-
},
|
|
148
|
+
config: makeConfig({
|
|
149
|
+
'no-unresolved-refs': 'error',
|
|
162
150
|
}),
|
|
163
151
|
});
|
|
164
152
|
|
package/src/rules/ajv.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Ajv from '@redocly/ajv';
|
|
3
|
-
// import * as jsonSpecV4 from 'ajv/lib/refs/json-schema-draft-04.json';
|
|
4
|
-
// import { OasVersion } from '../validate';
|
|
1
|
+
import Ajv, { ValidateFunction, ErrorObject } from '@redocly/ajv';
|
|
5
2
|
import { Location, escapePointer } from '../ref-utils';
|
|
6
3
|
import { ResolveFn } from '../walk';
|
|
7
4
|
|
|
8
|
-
let ajvInstance: Ajv
|
|
5
|
+
let ajvInstance: Ajv | null = null;
|
|
9
6
|
|
|
10
7
|
export function releaseAjvInstance() {
|
|
11
8
|
ajvInstance = null;
|
|
@@ -14,20 +11,20 @@ export function releaseAjvInstance() {
|
|
|
14
11
|
function getAjv(resolve: ResolveFn<any>, disallowAdditionalProperties: boolean) {
|
|
15
12
|
if (!ajvInstance) {
|
|
16
13
|
ajvInstance = new Ajv({
|
|
17
|
-
schemaId: '
|
|
14
|
+
schemaId: '$id',
|
|
18
15
|
meta: true,
|
|
19
16
|
allErrors: true,
|
|
20
|
-
|
|
21
|
-
unknownFormats: 'ignore',
|
|
22
|
-
nullable: true,
|
|
23
|
-
missingRefs: 'ignore',
|
|
17
|
+
strictSchema: false,
|
|
24
18
|
inlineRefs: false,
|
|
25
19
|
validateSchema: false,
|
|
20
|
+
discriminator: true,
|
|
21
|
+
allowUnionTypes: true,
|
|
22
|
+
validateFormats: false, // TODO: fix it
|
|
26
23
|
defaultAdditionalProperties: !disallowAdditionalProperties,
|
|
27
|
-
loadSchemaSync(base: string, $ref: string
|
|
28
|
-
const resolvedRef = resolve({ $ref }, base.
|
|
24
|
+
loadSchemaSync(base: string, $ref: string) {
|
|
25
|
+
const resolvedRef = resolve({ $ref }, base.split('#')[0]);
|
|
29
26
|
if (!resolvedRef || !resolvedRef.location) return undefined;
|
|
30
|
-
return { id, ...resolvedRef.node };
|
|
27
|
+
return { $id: resolvedRef.location.absolutePointer, ...resolvedRef.node };
|
|
31
28
|
},
|
|
32
29
|
logger: false,
|
|
33
30
|
});
|
|
@@ -40,11 +37,11 @@ function getAjvValidator(
|
|
|
40
37
|
loc: Location,
|
|
41
38
|
resolve: ResolveFn<any>,
|
|
42
39
|
disallowAdditionalProperties: boolean,
|
|
43
|
-
):
|
|
40
|
+
): ValidateFunction | undefined {
|
|
44
41
|
const ajv = getAjv(resolve, disallowAdditionalProperties);
|
|
45
42
|
|
|
46
43
|
if (!ajv.getSchema(loc.absolutePointer)) {
|
|
47
|
-
ajv.addSchema({ id: loc.absolutePointer, ...schema }, loc.absolutePointer);
|
|
44
|
+
ajv.addSchema({ $id: loc.absolutePointer, ...schema }, loc.absolutePointer);
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
return ajv.getSchema(loc.absolutePointer);
|
|
@@ -54,23 +51,30 @@ export function validateJsonSchema(
|
|
|
54
51
|
data: any,
|
|
55
52
|
schema: any,
|
|
56
53
|
schemaLoc: Location,
|
|
57
|
-
|
|
54
|
+
instancePath: string,
|
|
58
55
|
resolve: ResolveFn<any>,
|
|
59
56
|
disallowAdditionalProperties: boolean,
|
|
60
|
-
): { valid: boolean; errors: (
|
|
57
|
+
): { valid: boolean; errors: (ErrorObject & { suggest?: string[] })[] } {
|
|
61
58
|
const validate = getAjvValidator(schema, schemaLoc, resolve, disallowAdditionalProperties);
|
|
62
59
|
if (!validate) return { valid: true, errors: [] }; // unresolved refs are reported
|
|
63
60
|
|
|
64
|
-
const valid = validate(data,
|
|
61
|
+
const valid = validate(data, {
|
|
62
|
+
instancePath,
|
|
63
|
+
parentData: { fake: {} },
|
|
64
|
+
parentDataProperty: 'fake',
|
|
65
|
+
rootData: {},
|
|
66
|
+
dynamicAnchors: {},
|
|
67
|
+
});
|
|
68
|
+
|
|
65
69
|
return {
|
|
66
70
|
valid: !!valid,
|
|
67
71
|
errors: (validate.errors || []).map(beatifyErrorMessage),
|
|
68
72
|
};
|
|
69
73
|
|
|
70
|
-
function beatifyErrorMessage(error:
|
|
74
|
+
function beatifyErrorMessage(error: ErrorObject) {
|
|
71
75
|
let message = error.message;
|
|
72
76
|
let suggest =
|
|
73
|
-
error.keyword === 'enum' ?
|
|
77
|
+
error.keyword === 'enum' ? error.params.allowedValues : undefined;
|
|
74
78
|
if (suggest) {
|
|
75
79
|
message += ` ${suggest.map((e: any) => `"${e}"`).join(', ')}`;
|
|
76
80
|
}
|
|
@@ -79,15 +83,15 @@ export function validateJsonSchema(
|
|
|
79
83
|
message = `type ${message}`;
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
const relativePath = error.
|
|
86
|
+
const relativePath = error.instancePath.substring(instancePath.length + 1);
|
|
83
87
|
const propName = relativePath.substring(relativePath.lastIndexOf('/') + 1);
|
|
84
88
|
if (propName) {
|
|
85
89
|
message = `\`${propName}\` property ${message}`;
|
|
86
90
|
}
|
|
87
91
|
if (error.keyword === 'additionalProperties') {
|
|
88
|
-
const property =
|
|
92
|
+
const property = error.params.additionalProperty;
|
|
89
93
|
message = `${message} \`${property}\``;
|
|
90
|
-
error.
|
|
94
|
+
error.instancePath += '/' + escapePointer(property);
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
return {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { LintConfig } from '../../../config/config';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
6
|
+
import { makeConfig } from '../../__tests__/config';
|
|
7
|
+
|
|
7
8
|
describe('Oas3 info-description', () => {
|
|
8
9
|
it('should report on info with no description', async () => {
|
|
9
10
|
const document = parseYamlToDocument(
|
|
@@ -18,11 +19,8 @@ describe('Oas3 info-description', () => {
|
|
|
18
19
|
const results = await lintDocument({
|
|
19
20
|
externalRefResolver: new BaseResolver(),
|
|
20
21
|
document,
|
|
21
|
-
config:
|
|
22
|
-
|
|
23
|
-
rules: {
|
|
24
|
-
'info-description': 'error',
|
|
25
|
-
},
|
|
22
|
+
config: makeConfig({
|
|
23
|
+
'info-description': 'error',
|
|
26
24
|
}),
|
|
27
25
|
});
|
|
28
26
|
|
|
@@ -59,11 +57,8 @@ describe('Oas3 info-description', () => {
|
|
|
59
57
|
const results = await lintDocument({
|
|
60
58
|
externalRefResolver: new BaseResolver(),
|
|
61
59
|
document,
|
|
62
|
-
config:
|
|
63
|
-
|
|
64
|
-
rules: {
|
|
65
|
-
'info-description': 'error',
|
|
66
|
-
},
|
|
60
|
+
config: makeConfig({
|
|
61
|
+
'info-description': 'error',
|
|
67
62
|
}),
|
|
68
63
|
});
|
|
69
64
|
|
|
@@ -99,11 +94,8 @@ describe('Oas3 info-description', () => {
|
|
|
99
94
|
const results = await lintDocument({
|
|
100
95
|
externalRefResolver: new BaseResolver(),
|
|
101
96
|
document,
|
|
102
|
-
config:
|
|
103
|
-
|
|
104
|
-
rules: {
|
|
105
|
-
'info-description': 'error',
|
|
106
|
-
},
|
|
97
|
+
config: makeConfig({
|
|
98
|
+
'info-description': 'error',
|
|
107
99
|
}),
|
|
108
100
|
});
|
|
109
101
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 info-license', () => {
|
|
@@ -18,7 +18,7 @@ describe('Oas3 info-license', () => {
|
|
|
18
18
|
const results = await lintDocument({
|
|
19
19
|
externalRefResolver: new BaseResolver(),
|
|
20
20
|
document,
|
|
21
|
-
config:
|
|
21
|
+
config: makeConfig({ 'info-license': 'error' }),
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -55,7 +55,7 @@ describe('Oas3 info-license', () => {
|
|
|
55
55
|
const results = await lintDocument({
|
|
56
56
|
externalRefResolver: new BaseResolver(),
|
|
57
57
|
document,
|
|
58
|
-
config:
|
|
58
|
+
config: makeConfig({ 'info-license': 'error' }),
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 license-url', () => {
|
|
@@ -19,7 +19,7 @@ describe('Oas3 license-url', () => {
|
|
|
19
19
|
const results = await lintDocument({
|
|
20
20
|
externalRefResolver: new BaseResolver(),
|
|
21
21
|
document,
|
|
22
|
-
config:
|
|
22
|
+
config: makeConfig({ 'info-license-url': 'error' }),
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -56,7 +56,7 @@ describe('Oas3 license-url', () => {
|
|
|
56
56
|
const results = await lintDocument({
|
|
57
57
|
externalRefResolver: new BaseResolver(),
|
|
58
58
|
document,
|
|
59
|
-
config:
|
|
59
|
+
config: makeConfig({ 'info-license-url': 'error' }),
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('no-ambiguous-paths', () => {
|
|
@@ -47,7 +47,7 @@ describe('no-ambiguous-paths', () => {
|
|
|
47
47
|
const results = await lintDocument({
|
|
48
48
|
externalRefResolver: new BaseResolver(),
|
|
49
49
|
document,
|
|
50
|
-
config:
|
|
50
|
+
config: makeConfig({ 'no-ambiguous-paths': 'error' }),
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 typed enum', () => {
|
|
@@ -30,7 +30,7 @@ describe('Oas3 typed enum', () => {
|
|
|
30
30
|
const results = await lintDocument({
|
|
31
31
|
externalRefResolver: new BaseResolver(),
|
|
32
32
|
document,
|
|
33
|
-
config:
|
|
33
|
+
config: makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -63,7 +63,7 @@ describe('Oas3 typed enum', () => {
|
|
|
63
63
|
const results = await lintDocument({
|
|
64
64
|
externalRefResolver: new BaseResolver(),
|
|
65
65
|
document,
|
|
66
|
-
config:
|
|
66
|
+
config: makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -93,7 +93,7 @@ describe('Oas3 typed enum', () => {
|
|
|
93
93
|
const results = await lintDocument({
|
|
94
94
|
externalRefResolver: new BaseResolver(),
|
|
95
95
|
document,
|
|
96
|
-
config:
|
|
96
|
+
config: makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -141,7 +141,7 @@ describe('Oas3 typed enum', () => {
|
|
|
141
141
|
const results = await lintDocument({
|
|
142
142
|
externalRefResolver: new BaseResolver(),
|
|
143
143
|
document,
|
|
144
|
-
config:
|
|
144
|
+
config: makeConfig({ 'no-enum-type-mismatch': 'error' }),
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -162,4 +162,49 @@ describe('Oas3 typed enum', () => {
|
|
|
162
162
|
]
|
|
163
163
|
`);
|
|
164
164
|
});
|
|
165
|
+
|
|
166
|
+
it('should not crash on null schema when there is spec rule', async () => {
|
|
167
|
+
const document = parseYamlToDocument(
|
|
168
|
+
outdent`
|
|
169
|
+
openapi: 3.0.0
|
|
170
|
+
info:
|
|
171
|
+
title: test
|
|
172
|
+
version: 1.2.3
|
|
173
|
+
paths:
|
|
174
|
+
/some:
|
|
175
|
+
get:
|
|
176
|
+
responses:
|
|
177
|
+
'200':
|
|
178
|
+
description: test
|
|
179
|
+
content:
|
|
180
|
+
application/json:
|
|
181
|
+
schema: null
|
|
182
|
+
`,
|
|
183
|
+
'foobar.yaml',
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
const results = await lintDocument({
|
|
187
|
+
externalRefResolver: new BaseResolver(),
|
|
188
|
+
document,
|
|
189
|
+
config: makeConfig({ 'spec': 'error', 'no-enum-type-mismatch': 'error' }),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
193
|
+
Array [
|
|
194
|
+
Object {
|
|
195
|
+
"location": Array [
|
|
196
|
+
Object {
|
|
197
|
+
"pointer": "#/paths/~1some/get/responses/200/content/application~1json/schema",
|
|
198
|
+
"reportOnKey": false,
|
|
199
|
+
"source": "foobar.yaml",
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
"message": "Expected type \`Schema\` (object) but got \`null\`",
|
|
203
|
+
"ruleId": "spec",
|
|
204
|
+
"severity": "error",
|
|
205
|
+
"suggest": Array [],
|
|
206
|
+
},
|
|
207
|
+
]
|
|
208
|
+
`);
|
|
209
|
+
});
|
|
165
210
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('no-identical-paths', () => {
|
|
@@ -35,7 +35,7 @@ describe('no-identical-paths', () => {
|
|
|
35
35
|
const results = await lintDocument({
|
|
36
36
|
externalRefResolver: new BaseResolver(),
|
|
37
37
|
document,
|
|
38
|
-
config:
|
|
38
|
+
config: makeConfig({ 'no-identical-paths': 'error' }),
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('no-path-trailing-slash', () => {
|
|
@@ -20,7 +20,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
20
20
|
const results = await lintDocument({
|
|
21
21
|
externalRefResolver: new BaseResolver(),
|
|
22
22
|
document,
|
|
23
|
-
config:
|
|
23
|
+
config: makeConfig({ 'no-path-trailing-slash': 'error' }),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -57,7 +57,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
57
57
|
const results = await lintDocument({
|
|
58
58
|
externalRefResolver: new BaseResolver(),
|
|
59
59
|
document,
|
|
60
|
-
config:
|
|
60
|
+
config: makeConfig({ 'no-path-trailing-slash': 'error' }),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -78,7 +78,7 @@ describe('no-path-trailing-slash', () => {
|
|
|
78
78
|
const results = await lintDocument({
|
|
79
79
|
externalRefResolver: new BaseResolver(),
|
|
80
80
|
document,
|
|
81
|
-
config:
|
|
81
|
+
config: makeConfig({ 'no-path-trailing-slash': 'error' }),
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-2xx-response', () => {
|
|
@@ -22,7 +22,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
22
22
|
const results = await lintDocument({
|
|
23
23
|
externalRefResolver: new BaseResolver(),
|
|
24
24
|
document,
|
|
25
|
-
config:
|
|
25
|
+
config: makeConfig({ 'operation-2xx-response': 'error' }),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -61,7 +61,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
61
61
|
const results = await lintDocument({
|
|
62
62
|
externalRefResolver: new BaseResolver(),
|
|
63
63
|
document,
|
|
64
|
-
config:
|
|
64
|
+
config: makeConfig({ 'operation-2xx-response': 'error' }),
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -84,7 +84,7 @@ describe('Oas3 operation-2xx-response', () => {
|
|
|
84
84
|
const results = await lintDocument({
|
|
85
85
|
externalRefResolver: new BaseResolver(),
|
|
86
86
|
document,
|
|
87
|
-
config:
|
|
87
|
+
config: makeConfig({ 'operation-2xx-response': 'error' }),
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-operationId-unique', () => {
|
|
@@ -27,7 +27,7 @@ describe('Oas3 operation-operationId-unique', () => {
|
|
|
27
27
|
const results = await lintDocument({
|
|
28
28
|
externalRefResolver: new BaseResolver(),
|
|
29
29
|
document,
|
|
30
|
-
config:
|
|
30
|
+
config: makeConfig({ 'operation-operationId-unique': 'error' }),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -69,7 +69,7 @@ describe('Oas3 operation-operationId-unique', () => {
|
|
|
69
69
|
const results = await lintDocument({
|
|
70
70
|
externalRefResolver: new BaseResolver(),
|
|
71
71
|
document,
|
|
72
|
-
config:
|
|
72
|
+
config: makeConfig({ 'peration-operationId-unique': 'error' }),
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-operationId-url-safe', () => {
|
|
@@ -22,10 +22,7 @@ describe('Oas3 operation-operationId-url-safe', () => {
|
|
|
22
22
|
const results = await lintDocument({
|
|
23
23
|
externalRefResolver: new BaseResolver(),
|
|
24
24
|
document,
|
|
25
|
-
config:
|
|
26
|
-
extends: [],
|
|
27
|
-
rules: { 'operation-operationId-url-safe': 'error' },
|
|
28
|
-
}),
|
|
25
|
+
config: makeConfig({ 'operation-operationId-url-safe': 'error' }),
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-parameters-unique', () => {
|
|
@@ -23,10 +23,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
|
|
23
23
|
const results = await lintDocument({
|
|
24
24
|
externalRefResolver: new BaseResolver(),
|
|
25
25
|
document,
|
|
26
|
-
config:
|
|
27
|
-
extends: [],
|
|
28
|
-
rules: { 'operation-parameters-unique': 'error' },
|
|
29
|
-
}),
|
|
26
|
+
config: makeConfig({ 'operation-parameters-unique': 'error' }),
|
|
30
27
|
});
|
|
31
28
|
|
|
32
29
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -69,10 +66,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
|
|
69
66
|
const results = await lintDocument({
|
|
70
67
|
externalRefResolver: new BaseResolver(),
|
|
71
68
|
document,
|
|
72
|
-
config:
|
|
73
|
-
extends: [],
|
|
74
|
-
rules: { 'operation-parameters-unique': 'error' },
|
|
75
|
-
}),
|
|
69
|
+
config: makeConfig({ 'operation-parameters-unique': 'error' }),
|
|
76
70
|
});
|
|
77
71
|
|
|
78
72
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -102,10 +96,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
|
|
102
96
|
const results = await lintDocument({
|
|
103
97
|
externalRefResolver: new BaseResolver(),
|
|
104
98
|
document,
|
|
105
|
-
config:
|
|
106
|
-
extends: [],
|
|
107
|
-
rules: { 'operation-parameters-unique': 'error' },
|
|
108
|
-
}),
|
|
99
|
+
config: makeConfig({ 'operation-parameters-unique': 'error' }),
|
|
109
100
|
});
|
|
110
101
|
|
|
111
102
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -153,10 +144,7 @@ describe('Oas3 operation-parameters-unique', () => {
|
|
|
153
144
|
const results = await lintDocument({
|
|
154
145
|
externalRefResolver: new BaseResolver(),
|
|
155
146
|
document,
|
|
156
|
-
config:
|
|
157
|
-
extends: [],
|
|
158
|
-
rules: { 'operation-parameters-unique': 'error' },
|
|
159
|
-
}),
|
|
147
|
+
config: makeConfig({ 'operation-parameters-unique': 'error' }),
|
|
160
148
|
});
|
|
161
149
|
|
|
162
150
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-security-defined', () => {
|
|
@@ -20,7 +20,7 @@ describe('Oas3 operation-security-defined', () => {
|
|
|
20
20
|
const results = await lintDocument({
|
|
21
21
|
externalRefResolver: new BaseResolver(),
|
|
22
22
|
document,
|
|
23
|
-
config:
|
|
23
|
+
config: makeConfig({ 'operation-security-defined': 'error' }),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -62,7 +62,7 @@ describe('Oas3 operation-security-defined', () => {
|
|
|
62
62
|
const results = await lintDocument({
|
|
63
63
|
externalRefResolver: new BaseResolver(),
|
|
64
64
|
document,
|
|
65
|
-
config:
|
|
65
|
+
config: makeConfig({ 'operation-security-defined': 'error' }),
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
|
-
import { LintConfig } from '../../../config/config';
|
|
3
2
|
import { lintDocument } from '../../../lint';
|
|
4
3
|
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
+
import { makeConfig } from '../../__tests__/config';
|
|
5
5
|
import { BaseResolver } from '../../../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Oas3 operation-singular-tag', () => {
|
|
@@ -25,7 +25,7 @@ describe('Oas3 operation-singular-tag', () => {
|
|
|
25
25
|
const results = await lintDocument({
|
|
26
26
|
externalRefResolver: new BaseResolver(),
|
|
27
27
|
document,
|
|
28
|
-
config:
|
|
28
|
+
config: makeConfig({ 'operation-singular-tag': 'error' }),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -65,7 +65,7 @@ describe('Oas3 operation-singular-tag', () => {
|
|
|
65
65
|
const results = await lintDocument({
|
|
66
66
|
externalRefResolver: new BaseResolver(),
|
|
67
67
|
document,
|
|
68
|
-
config:
|
|
68
|
+
config: makeConfig({ 'operation-singular-tag': 'error' }),
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|