@redocly/openapi-core 1.0.0-beta.105 → 1.0.0-beta.108
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/README.md +4 -4
- package/__tests__/utils.ts +5 -5
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
- package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
- package/lib/benchmark/utils.d.ts +2 -2
- package/lib/benchmark/utils.js +2 -2
- package/lib/bundle.d.ts +2 -2
- package/lib/bundle.js +7 -4
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +3 -3
- package/lib/config/builtIn.d.ts +2 -2
- package/lib/config/builtIn.js +2 -2
- package/lib/config/config-resolvers.d.ts +5 -5
- package/lib/config/config-resolvers.js +70 -49
- package/lib/config/config.d.ts +8 -10
- package/lib/config/config.js +10 -7
- package/lib/config/load.d.ts +7 -0
- package/lib/config/load.js +18 -10
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +5 -4
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +5 -4
- package/lib/config/rules.d.ts +3 -3
- package/lib/config/rules.js +1 -1
- package/lib/config/types.d.ts +23 -19
- package/lib/config/utils.d.ts +5 -5
- package/lib/config/utils.js +48 -31
- package/lib/decorators/common/registry-dependencies.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +2 -2
- package/lib/env.d.ts +3 -0
- package/lib/env.js +8 -0
- package/lib/format/codeframes.js +16 -10
- package/lib/format/format.js +29 -27
- package/lib/index.d.ts +5 -5
- package/lib/index.js +4 -2
- package/lib/js-yaml/index.js +2 -6
- package/lib/lint.d.ts +2 -2
- package/lib/lint.js +16 -6
- package/lib/logger.d.ts +10 -0
- package/lib/logger.js +31 -0
- package/lib/output.d.ts +3 -0
- package/lib/output.js +9 -0
- package/lib/redocly/index.js +10 -9
- package/lib/redocly/registry-api-types.d.ts +28 -30
- package/lib/redocly/registry-api.d.ts +4 -3
- package/lib/redocly/registry-api.js +9 -4
- package/lib/ref-utils.js +2 -1
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +1 -1
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +7 -7
- package/lib/rules/common/assertions/asserts.js +4 -4
- package/lib/rules/common/assertions/index.js +1 -1
- package/lib/rules/common/info-license-url.d.ts +1 -1
- package/lib/rules/common/info-license-url.js +5 -10
- package/lib/rules/common/info-license.d.ts +2 -0
- package/lib/rules/common/info-license.js +17 -0
- package/lib/rules/common/no-enum-type-mismatch.js +1 -3
- package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
- package/lib/rules/common/no-invalid-schema-examples.js +3 -3
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-security-defined.js +1 -1
- package/lib/rules/common/path-not-include-query.js +1 -1
- package/lib/rules/common/paths-kebab-case.js +4 -1
- package/lib/rules/common/spec.js +3 -3
- package/lib/rules/oas2/index.js +4 -4
- package/lib/rules/oas2/remove-unused-components.js +5 -5
- package/lib/rules/oas3/index.js +6 -6
- package/lib/rules/oas3/no-empty-servers.js +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
- package/lib/rules/oas3/{no-servers-empty-enum.js → no-server-variables-empty-enum.js} +4 -4
- package/lib/rules/oas3/no-unused-components.js +1 -1
- package/lib/rules/oas3/remove-unused-components.js +5 -5
- package/lib/rules/other/stats.js +43 -14
- package/lib/rules/utils.d.ts +3 -2
- package/lib/rules/utils.js +20 -5
- package/lib/types/index.d.ts +2 -2
- package/lib/types/redocly-yaml.js +9 -8
- package/lib/utils.d.ts +5 -0
- package/lib/utils.js +22 -5
- package/lib/visitors.d.ts +1 -1
- package/lib/visitors.js +2 -2
- package/lib/walk.d.ts +2 -1
- package/lib/walk.js +6 -3
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
- package/src/__tests__/bundle.test.ts +68 -34
- package/src/__tests__/codeframes.test.ts +13 -14
- package/src/__tests__/js-yaml.test.ts +6 -4
- package/src/__tests__/lint.test.ts +74 -6
- package/src/__tests__/logger-browser.test.ts +53 -0
- package/src/__tests__/logger.test.ts +47 -0
- package/src/__tests__/login.test.ts +2 -2
- package/src/__tests__/normalizeVisitors.test.ts +4 -4
- package/src/__tests__/output-browser.test.ts +18 -0
- package/src/__tests__/output.test.ts +15 -0
- package/src/__tests__/ref-utils.test.ts +13 -13
- package/src/__tests__/resolve-http.test.ts +1 -1
- package/src/__tests__/resolve.test.ts +14 -11
- package/src/__tests__/utils-browser.test.ts +11 -0
- package/src/__tests__/utils.test.ts +7 -0
- package/src/__tests__/walk.test.ts +48 -56
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -2
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
- package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
- package/src/benchmark/benchmark.js +9 -5
- package/src/benchmark/utils.ts +5 -5
- package/src/bundle.ts +24 -20
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +7 -5
- package/src/config/__tests__/config-resolvers.test.ts +123 -121
- package/src/config/__tests__/config.test.ts +111 -76
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
- package/src/config/__tests__/load.test.ts +79 -1
- package/src/config/__tests__/resolve-plugins.test.ts +3 -3
- package/src/config/__tests__/utils.test.ts +83 -0
- package/src/config/all.ts +5 -6
- package/src/config/builtIn.ts +5 -5
- package/src/config/config-resolvers.ts +161 -96
- package/src/config/config.ts +15 -13
- package/src/config/load.ts +34 -11
- package/src/config/minimal.ts +7 -6
- package/src/config/recommended.ts +7 -6
- package/src/config/rules.ts +6 -6
- package/src/config/types.ts +28 -19
- package/src/config/utils.ts +78 -57
- package/src/decorators/__tests__/filter-out.test.ts +8 -4
- package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
- package/src/decorators/common/filters/filter-helper.ts +1 -1
- package/src/decorators/common/info-description-override.ts +1 -1
- package/src/decorators/common/operation-description-override.ts +1 -1
- package/src/decorators/common/registry-dependencies.ts +1 -1
- package/src/decorators/common/remove-x-internal.ts +4 -4
- package/src/decorators/common/tag-description-override.ts +1 -1
- package/src/env.ts +5 -0
- package/src/format/codeframes.ts +18 -12
- package/src/format/format.ts +37 -42
- package/src/index.ts +8 -7
- package/src/js-yaml/index.ts +4 -8
- package/src/lint.ts +22 -18
- package/src/logger.ts +34 -0
- package/src/oas-types.ts +1 -6
- package/src/output.ts +7 -0
- package/src/redocly/__tests__/redocly-client.test.ts +25 -19
- package/src/redocly/index.ts +12 -7
- package/src/redocly/registry-api-types.ts +27 -29
- package/src/redocly/registry-api.ts +22 -12
- package/src/ref-utils.ts +4 -3
- package/src/resolve.ts +11 -8
- package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
- package/src/rules/__tests__/utils.test.ts +160 -0
- package/src/rules/ajv.ts +7 -8
- package/src/rules/common/__tests__/info-description.test.ts +3 -3
- package/src/rules/common/__tests__/info-license.test.ts +2 -2
- package/src/rules/common/__tests__/license-url.test.ts +2 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
- package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
- package/src/rules/common/__tests__/spec.test.ts +2 -2
- package/src/rules/common/__tests__/tag-description.test.ts +2 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
- package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
- package/src/rules/common/assertions/asserts.ts +4 -4
- package/src/rules/common/assertions/index.ts +7 -7
- package/src/rules/common/info-license-url.ts +4 -9
- package/src/rules/common/info-license.ts +15 -0
- package/src/rules/common/no-ambiguous-paths.ts +1 -1
- package/src/rules/common/no-enum-type-mismatch.ts +12 -9
- package/src/rules/common/no-invalid-parameter-examples.ts +4 -4
- package/src/rules/common/no-invalid-schema-examples.ts +4 -4
- package/src/rules/common/operation-operationId.ts +1 -1
- package/src/rules/common/operation-parameters-unique.ts +2 -2
- package/src/rules/common/operation-security-defined.ts +1 -1
- package/src/rules/common/path-not-include-query.ts +1 -1
- package/src/rules/common/path-params-defined.ts +1 -1
- package/src/rules/common/paths-kebab-case.ts +4 -1
- package/src/rules/common/scalar-property-missing-example.ts +1 -1
- package/src/rules/common/spec.ts +12 -9
- package/src/rules/no-unresolved-refs.ts +1 -1
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
- package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
- package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
- package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
- package/src/rules/oas2/index.ts +3 -3
- package/src/rules/oas2/remove-unused-components.ts +14 -9
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +16 -16
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +13 -13
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
- package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
- package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
- package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
- package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
- package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
- package/src/rules/oas3/index.ts +5 -5
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +14 -6
- package/src/rules/oas3/{no-servers-empty-enum.ts → no-server-variables-empty-enum.ts} +10 -11
- package/src/rules/oas3/no-unused-components.ts +1 -1
- package/src/rules/oas3/remove-unused-components.ts +21 -10
- package/src/rules/other/stats.ts +46 -17
- package/src/rules/utils.ts +20 -4
- package/src/types/index.ts +5 -5
- package/src/types/redocly-yaml.ts +9 -8
- package/src/typings/common.ts +9 -1
- package/src/typings/openapi.ts +1 -1
- package/src/utils.ts +26 -3
- package/src/visitors.ts +9 -9
- package/src/walk.ts +15 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/common/license-url.d.ts +0 -2
- package/lib/rules/common/license-url.js +0 -12
- package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
- package/src/rules/common/license-url.ts +0 -10
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StyleguideConfig, RuleConfig, resolveStyleguideConfig } from '../../../../config';
|
|
2
2
|
import { parseYamlToDocument } from '../../../../../__tests__/utils';
|
|
3
3
|
import { lintDocument } from '../../../../lint';
|
|
4
4
|
import { BaseResolver } from '../../../../resolve';
|
|
5
5
|
|
|
6
6
|
export async function lintDoc(
|
|
7
7
|
source: string,
|
|
8
|
-
rules: Record<string, RuleConfig> = { spec: 'error' }
|
|
8
|
+
rules: Record<string, RuleConfig> = { spec: 'error' }
|
|
9
9
|
) {
|
|
10
10
|
const document = parseYamlToDocument(source, 'foobar.yaml');
|
|
11
11
|
|
|
12
12
|
const results = await lintDocument({
|
|
13
13
|
externalRefResolver: new BaseResolver(),
|
|
14
14
|
document,
|
|
15
|
-
config: new
|
|
16
|
-
await
|
|
17
|
-
|
|
15
|
+
config: new StyleguideConfig(
|
|
16
|
+
await resolveStyleguideConfig({
|
|
17
|
+
styleguideConfig: {
|
|
18
18
|
plugins: [],
|
|
19
19
|
extends: [],
|
|
20
20
|
rules,
|
|
21
21
|
},
|
|
22
|
-
})
|
|
22
|
+
})
|
|
23
23
|
),
|
|
24
24
|
});
|
|
25
25
|
|
package/src/rules/oas2/index.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples';
|
|
|
4
4
|
import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples';
|
|
5
5
|
import { InfoDescription } from '../common/info-description';
|
|
6
6
|
import { InfoContact } from '../common/info-contact';
|
|
7
|
-
import { InfoLicense } from '../common/info-license
|
|
8
|
-
import { InfoLicenseUrl } from '../common/license-url';
|
|
7
|
+
import { InfoLicense } from '../common/info-license';
|
|
8
|
+
import { InfoLicenseUrl } from '../common/info-license-url';
|
|
9
9
|
import { BooleanParameterPrefixes } from './boolean-parameter-prefixes';
|
|
10
10
|
import { TagDescription } from '../common/tag-description';
|
|
11
11
|
import { TagsAlphabetical } from '../common/tags-alphabetical';
|
|
@@ -57,7 +57,7 @@ export const rules = {
|
|
|
57
57
|
'no-path-trailing-slash': NoPathTrailingSlash as Oas2Rule,
|
|
58
58
|
'operation-2xx-response': Operation2xxResponse as Oas2Rule,
|
|
59
59
|
'operation-4xx-response': Operation4xxResponse as Oas2Rule,
|
|
60
|
-
|
|
60
|
+
assertions: Assertions as Oas2Rule,
|
|
61
61
|
'operation-operationId-unique': OperationIdUnique as Oas2Rule,
|
|
62
62
|
'operation-parameters-unique': OperationParametersUnique as Oas2Rule,
|
|
63
63
|
'path-parameters-defined': PathParamsDefined as Oas2Rule,
|
|
@@ -4,9 +4,16 @@ import { Oas2Components } from '../../typings/swagger';
|
|
|
4
4
|
import { isEmptyObject } from '../../utils';
|
|
5
5
|
|
|
6
6
|
export const RemoveUnusedComponents: Oas2Rule = () => {
|
|
7
|
-
|
|
7
|
+
const components = new Map<
|
|
8
|
+
string,
|
|
9
|
+
{ used: boolean; componentType?: keyof Oas2Components; name: string }
|
|
10
|
+
>();
|
|
8
11
|
|
|
9
|
-
function registerComponent(
|
|
12
|
+
function registerComponent(
|
|
13
|
+
location: Location,
|
|
14
|
+
componentType: keyof Oas2Components,
|
|
15
|
+
name: string
|
|
16
|
+
): void {
|
|
10
17
|
components.set(location.absolutePointer, {
|
|
11
18
|
used: components.get(location.absolutePointer)?.used || false,
|
|
12
19
|
componentType,
|
|
@@ -17,9 +24,7 @@ export const RemoveUnusedComponents: Oas2Rule = () => {
|
|
|
17
24
|
return {
|
|
18
25
|
ref: {
|
|
19
26
|
leave(ref, { type, resolve, key }) {
|
|
20
|
-
if (
|
|
21
|
-
['Schema', 'Parameter', 'Response', 'SecurityScheme'].includes(type.name)
|
|
22
|
-
) {
|
|
27
|
+
if (['Schema', 'Parameter', 'Response', 'SecurityScheme'].includes(type.name)) {
|
|
23
28
|
const resolvedRef = resolve(ref);
|
|
24
29
|
if (!resolvedRef.location) return;
|
|
25
30
|
components.set(resolvedRef.location.absolutePointer, {
|
|
@@ -27,15 +32,15 @@ export const RemoveUnusedComponents: Oas2Rule = () => {
|
|
|
27
32
|
name: key.toString(),
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
|
-
}
|
|
35
|
+
},
|
|
31
36
|
},
|
|
32
37
|
DefinitionRoot: {
|
|
33
38
|
leave(root, ctx) {
|
|
34
39
|
const data = ctx.getVisitorData() as { removedCount: number };
|
|
35
40
|
data.removedCount = 0;
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
components.forEach(usageInfo => {
|
|
42
|
+
const rootComponents = new Set<keyof Oas2Components>();
|
|
43
|
+
components.forEach((usageInfo) => {
|
|
39
44
|
const { used, name, componentType } = usageInfo;
|
|
40
45
|
if (!used && componentType) {
|
|
41
46
|
rootComponents.add(componentType);
|
|
@@ -71,6 +76,6 @@ export const RemoveUnusedComponents: Oas2Rule = () => {
|
|
|
71
76
|
SecurityScheme(_securityScheme, { location, key }) {
|
|
72
77
|
registerComponent(location, 'securityDefinitions', key.toString());
|
|
73
78
|
},
|
|
74
|
-
}
|
|
79
|
+
},
|
|
75
80
|
};
|
|
76
81
|
};
|
|
@@ -16,7 +16,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
16
16
|
schema:
|
|
17
17
|
type: boolean
|
|
18
18
|
`,
|
|
19
|
-
'foobar.yaml'
|
|
19
|
+
'foobar.yaml'
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
const results = await lintDocument({
|
|
@@ -68,7 +68,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
68
68
|
schema:
|
|
69
69
|
type: boolean
|
|
70
70
|
`,
|
|
71
|
-
'foobar.yaml'
|
|
71
|
+
'foobar.yaml'
|
|
72
72
|
);
|
|
73
73
|
|
|
74
74
|
const results = await lintDocument({
|
|
@@ -92,7 +92,7 @@ describe('oas3 boolean-parameter-prefixes', () => {
|
|
|
92
92
|
schema:
|
|
93
93
|
type: boolean
|
|
94
94
|
`,
|
|
95
|
-
'foobar.yaml'
|
|
95
|
+
'foobar.yaml'
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
const results = await lintDocument({
|
|
@@ -3,8 +3,8 @@ import { lintDocument } from '../../../lint';
|
|
|
3
3
|
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
5
|
|
|
6
|
-
describe('Oas3 as3-no-
|
|
7
|
-
it('oas3-no-
|
|
6
|
+
describe('Oas3 as3-no-server-variables-empty-enum', () => {
|
|
7
|
+
it('oas3-no-server-variables-empty-enum: should report on server object with empty enum and unknown enum value', async () => {
|
|
8
8
|
const document = parseYamlToDocument(
|
|
9
9
|
outdent`
|
|
10
10
|
openapi: 3.0.0
|
|
@@ -24,7 +24,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
24
24
|
const results = await lintDocument({
|
|
25
25
|
externalRefResolver: new BaseResolver(),
|
|
26
26
|
document,
|
|
27
|
-
config: await makeConfig({ 'no-
|
|
27
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -38,7 +38,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
38
38
|
},
|
|
39
39
|
],
|
|
40
40
|
"message": "Server variable with \`enum\` must be a non-empty array.",
|
|
41
|
-
"ruleId": "no-
|
|
41
|
+
"ruleId": "no-server-variables-empty-enum",
|
|
42
42
|
"severity": "error",
|
|
43
43
|
"suggest": Array [],
|
|
44
44
|
},
|
|
@@ -51,7 +51,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
53
|
"message": "Server variable define \`enum\` and \`default\`. \`enum\` must include default value",
|
|
54
|
-
"ruleId": "no-
|
|
54
|
+
"ruleId": "no-server-variables-empty-enum",
|
|
55
55
|
"severity": "error",
|
|
56
56
|
"suggest": Array [],
|
|
57
57
|
},
|
|
@@ -59,7 +59,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
59
59
|
`);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
it('oas3-no-
|
|
62
|
+
it('oas3-no-server-variables-empty-enum: should report on server object with empty enum', async () => {
|
|
63
63
|
const document = parseYamlToDocument(
|
|
64
64
|
outdent`
|
|
65
65
|
openapi: 3.0.0
|
|
@@ -78,7 +78,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
78
78
|
const results = await lintDocument({
|
|
79
79
|
externalRefResolver: new BaseResolver(),
|
|
80
80
|
document,
|
|
81
|
-
config: await makeConfig({ 'no-
|
|
81
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -92,7 +92,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
92
92
|
},
|
|
93
93
|
],
|
|
94
94
|
"message": "Server variable with \`enum\` must be a non-empty array.",
|
|
95
|
-
"ruleId": "no-
|
|
95
|
+
"ruleId": "no-server-variables-empty-enum",
|
|
96
96
|
"severity": "error",
|
|
97
97
|
"suggest": Array [],
|
|
98
98
|
},
|
|
@@ -100,7 +100,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
100
100
|
`);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it('oas3-no-
|
|
103
|
+
it('oas3-no-server-variables-empty-enum: should be success because variables is empty object', async () => {
|
|
104
104
|
const document = parseYamlToDocument(
|
|
105
105
|
outdent`
|
|
106
106
|
openapi: 3.0.0
|
|
@@ -117,13 +117,13 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
117
117
|
const results = await lintDocument({
|
|
118
118
|
externalRefResolver: new BaseResolver(),
|
|
119
119
|
document,
|
|
120
|
-
config: await makeConfig({ 'no-
|
|
120
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it('oas3-no-
|
|
126
|
+
it('oas3-no-server-variables-empty-enum: should be success because variable is empty object', async () => {
|
|
127
127
|
const document = parseYamlToDocument(
|
|
128
128
|
outdent`
|
|
129
129
|
openapi: 3.0.0
|
|
@@ -141,13 +141,13 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
141
141
|
const results = await lintDocument({
|
|
142
142
|
externalRefResolver: new BaseResolver(),
|
|
143
143
|
document,
|
|
144
|
-
config: await makeConfig({ 'no-
|
|
144
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
it('oas3-no-
|
|
150
|
+
it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => {
|
|
151
151
|
const document = parseYamlToDocument(
|
|
152
152
|
outdent`
|
|
153
153
|
openapi: 3.0.0
|
|
@@ -168,13 +168,13 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
168
168
|
const results = await lintDocument({
|
|
169
169
|
externalRefResolver: new BaseResolver(),
|
|
170
170
|
document,
|
|
171
|
-
config: await makeConfig({ 'no-
|
|
171
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
it('oas3-no-
|
|
177
|
+
it('oas3-no-server-variables-empty-enum: should be success because enum contains default value', async () => {
|
|
178
178
|
const document = parseYamlToDocument(
|
|
179
179
|
outdent`
|
|
180
180
|
openapi: 3.0.0
|
|
@@ -197,7 +197,7 @@ describe('Oas3 as3-no-servers-empty-enum', () => {
|
|
|
197
197
|
const results = await lintDocument({
|
|
198
198
|
externalRefResolver: new BaseResolver(),
|
|
199
199
|
document,
|
|
200
|
-
config: await makeConfig({ 'no-
|
|
200
|
+
config: await makeConfig({ 'no-server-variables-empty-enum': 'error' }),
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
@@ -14,7 +14,7 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
|
|
14
14
|
value: 12
|
|
15
15
|
externalValue: https://1.1.1.1
|
|
16
16
|
`,
|
|
17
|
-
'foobar.yaml'
|
|
17
|
+
'foobar.yaml'
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const results = await lintDocument({
|
|
@@ -51,7 +51,7 @@ describe('Oas3 oas3-no-example-value-and-externalValue', () => {
|
|
|
51
51
|
some:
|
|
52
52
|
value: 12
|
|
53
53
|
`,
|
|
54
|
-
'foobar.yaml'
|
|
54
|
+
'foobar.yaml'
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
const results = await lintDocument({
|
|
@@ -27,7 +27,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
27
27
|
type: number
|
|
28
28
|
|
|
29
29
|
`,
|
|
30
|
-
'foobar.yaml'
|
|
30
|
+
'foobar.yaml'
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
const results = await lintDocument({
|
|
@@ -76,7 +76,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
76
76
|
`);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it('should report on invalid example with
|
|
79
|
+
it('should report on invalid example with allowAdditionalProperties', async () => {
|
|
80
80
|
const document = parseYamlToDocument(
|
|
81
81
|
outdent`
|
|
82
82
|
openapi: 3.0.0
|
|
@@ -100,7 +100,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
100
100
|
type: number
|
|
101
101
|
|
|
102
102
|
`,
|
|
103
|
-
'foobar.yaml'
|
|
103
|
+
'foobar.yaml'
|
|
104
104
|
);
|
|
105
105
|
|
|
106
106
|
const results = await lintDocument({
|
|
@@ -109,7 +109,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
109
109
|
config: await makeConfig({
|
|
110
110
|
'no-invalid-media-type-examples': {
|
|
111
111
|
severity: 'error',
|
|
112
|
-
|
|
112
|
+
allowAdditionalProperties: false,
|
|
113
113
|
},
|
|
114
114
|
}),
|
|
115
115
|
});
|
|
@@ -137,7 +137,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
137
137
|
`);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
it('should not on invalid example with
|
|
140
|
+
it('should not on invalid example with allowAdditionalProperties', async () => {
|
|
141
141
|
const document = parseYamlToDocument(
|
|
142
142
|
outdent`
|
|
143
143
|
openapi: 3.0.0
|
|
@@ -160,7 +160,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
160
160
|
type: number
|
|
161
161
|
|
|
162
162
|
`,
|
|
163
|
-
'foobar.yaml'
|
|
163
|
+
'foobar.yaml'
|
|
164
164
|
);
|
|
165
165
|
|
|
166
166
|
const results = await lintDocument({
|
|
@@ -169,7 +169,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
169
169
|
config: await makeConfig({
|
|
170
170
|
'no-invalid-media-type-examples': {
|
|
171
171
|
severity: 'error',
|
|
172
|
-
|
|
172
|
+
allowAdditionalProperties: false,
|
|
173
173
|
},
|
|
174
174
|
}),
|
|
175
175
|
});
|
|
@@ -210,7 +210,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
210
210
|
type: number
|
|
211
211
|
|
|
212
212
|
`,
|
|
213
|
-
'foobar.yaml'
|
|
213
|
+
'foobar.yaml'
|
|
214
214
|
);
|
|
215
215
|
|
|
216
216
|
const results = await lintDocument({
|
|
@@ -219,7 +219,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
219
219
|
config: await makeConfig({
|
|
220
220
|
'no-invalid-media-type-examples': {
|
|
221
221
|
severity: 'error',
|
|
222
|
-
|
|
222
|
+
allowAdditionalProperties: false,
|
|
223
223
|
},
|
|
224
224
|
}),
|
|
225
225
|
});
|
|
@@ -263,7 +263,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
263
263
|
b: 35
|
|
264
264
|
|
|
265
265
|
`,
|
|
266
|
-
'foobar.yaml'
|
|
266
|
+
'foobar.yaml'
|
|
267
267
|
);
|
|
268
268
|
|
|
269
269
|
const results = await lintDocument({
|
|
@@ -295,7 +295,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
295
295
|
type: number
|
|
296
296
|
|
|
297
297
|
`,
|
|
298
|
-
'foobar.yaml'
|
|
298
|
+
'foobar.yaml'
|
|
299
299
|
);
|
|
300
300
|
|
|
301
301
|
const results = await lintDocument({
|
|
@@ -330,7 +330,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
330
330
|
$ref: '#/components/schemas/C'
|
|
331
331
|
|
|
332
332
|
`,
|
|
333
|
-
__dirname + '/foobar.yaml'
|
|
333
|
+
__dirname + '/foobar.yaml'
|
|
334
334
|
);
|
|
335
335
|
|
|
336
336
|
const results = await lintDocument({
|
|
@@ -358,7 +358,7 @@ describe('no-invalid-media-type-examples', () => {
|
|
|
358
358
|
nullable: true
|
|
359
359
|
|
|
360
360
|
`,
|
|
361
|
-
'foobar.yaml'
|
|
361
|
+
'foobar.yaml'
|
|
362
362
|
);
|
|
363
363
|
|
|
364
364
|
const results = await lintDocument({
|
|
@@ -11,7 +11,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
|
|
|
11
11
|
servers:
|
|
12
12
|
- url: example.com
|
|
13
13
|
`,
|
|
14
|
-
'foobar.yaml'
|
|
14
|
+
'foobar.yaml'
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const results = await lintDocument({
|
|
@@ -46,7 +46,7 @@ describe('Oas3 oas3-no-server-example.com', () => {
|
|
|
46
46
|
servers:
|
|
47
47
|
- url: not-example.com
|
|
48
48
|
`,
|
|
49
|
-
'foobar.yaml'
|
|
49
|
+
'foobar.yaml'
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
const results = await lintDocument({
|
|
@@ -11,7 +11,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
|
|
11
11
|
servers:
|
|
12
12
|
- url: https://somedomain.com/
|
|
13
13
|
`,
|
|
14
|
-
'foobar.yaml'
|
|
14
|
+
'foobar.yaml'
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const results = await lintDocument({
|
|
@@ -46,7 +46,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
|
|
46
46
|
servers:
|
|
47
47
|
- url: https://somedomain.com
|
|
48
48
|
`,
|
|
49
|
-
'foobar.yaml'
|
|
49
|
+
'foobar.yaml'
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
const results = await lintDocument({
|
|
@@ -65,7 +65,7 @@ describe('Oas3 oas3-no-server-trailing-slash', () => {
|
|
|
65
65
|
servers:
|
|
66
66
|
- url: /
|
|
67
67
|
`,
|
|
68
|
-
'foobar.yaml'
|
|
68
|
+
'foobar.yaml'
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
const results = await lintDocument({
|
|
@@ -23,7 +23,7 @@ describe('OpenAPI Schema', () => {
|
|
|
23
23
|
expect(
|
|
24
24
|
await validateDoc(source, {
|
|
25
25
|
spec: 'error',
|
|
26
|
-
})
|
|
26
|
+
})
|
|
27
27
|
).toMatchInlineSnapshot(`
|
|
28
28
|
Array [
|
|
29
29
|
Object {
|
|
@@ -56,7 +56,7 @@ describe('OpenAPI Schema', () => {
|
|
|
56
56
|
expect(
|
|
57
57
|
await validateDoc(source, {
|
|
58
58
|
spec: 'error',
|
|
59
|
-
})
|
|
59
|
+
})
|
|
60
60
|
).toMatchInlineSnapshot(`
|
|
61
61
|
Array [
|
|
62
62
|
Object {
|
|
@@ -89,7 +89,7 @@ describe('OpenAPI Schema', () => {
|
|
|
89
89
|
expect(
|
|
90
90
|
await validateDoc(source, {
|
|
91
91
|
spec: 'error',
|
|
92
|
-
})
|
|
92
|
+
})
|
|
93
93
|
).toMatchInlineSnapshot(`
|
|
94
94
|
Array [
|
|
95
95
|
Object {
|
|
@@ -126,7 +126,7 @@ describe('OpenAPI Schema', () => {
|
|
|
126
126
|
expect(
|
|
127
127
|
await validateDoc(source, {
|
|
128
128
|
spec: 'error',
|
|
129
|
-
})
|
|
129
|
+
})
|
|
130
130
|
).toMatchInlineSnapshot(`Array []`);
|
|
131
131
|
});
|
|
132
132
|
|
|
@@ -155,7 +155,7 @@ describe('OpenAPI Schema', () => {
|
|
|
155
155
|
expect(
|
|
156
156
|
await validateDoc(source, {
|
|
157
157
|
spec: 'error',
|
|
158
|
-
})
|
|
158
|
+
})
|
|
159
159
|
).toMatchInlineSnapshot(`
|
|
160
160
|
Array [
|
|
161
161
|
Object {
|
|
@@ -191,7 +191,7 @@ describe('OpenAPI Schema', () => {
|
|
|
191
191
|
expect(
|
|
192
192
|
await validateDoc(source, {
|
|
193
193
|
spec: 'error',
|
|
194
|
-
})
|
|
194
|
+
})
|
|
195
195
|
).toMatchInlineSnapshot(`
|
|
196
196
|
Array [
|
|
197
197
|
Object {
|
|
@@ -226,7 +226,7 @@ describe('OpenAPI Schema', () => {
|
|
|
226
226
|
expect(
|
|
227
227
|
await validateDoc(source, {
|
|
228
228
|
spec: 'error',
|
|
229
|
-
})
|
|
229
|
+
})
|
|
230
230
|
).toMatchInlineSnapshot(`Array []`);
|
|
231
231
|
});
|
|
232
232
|
|
|
@@ -253,7 +253,7 @@ describe('OpenAPI Schema', () => {
|
|
|
253
253
|
expect(
|
|
254
254
|
await validateDoc(source, {
|
|
255
255
|
spec: 'error',
|
|
256
|
-
})
|
|
256
|
+
})
|
|
257
257
|
).toMatchInlineSnapshot(`
|
|
258
258
|
Array [
|
|
259
259
|
Object {
|
|
@@ -288,7 +288,7 @@ describe('OpenAPI Schema', () => {
|
|
|
288
288
|
expect(
|
|
289
289
|
await validateDoc(source, {
|
|
290
290
|
spec: 'error',
|
|
291
|
-
})
|
|
291
|
+
})
|
|
292
292
|
).toMatchInlineSnapshot(`
|
|
293
293
|
Array [
|
|
294
294
|
Object {
|
|
@@ -322,7 +322,7 @@ describe('OpenAPI Schema', () => {
|
|
|
322
322
|
expect(
|
|
323
323
|
await validateDoc(source, {
|
|
324
324
|
spec: 'error',
|
|
325
|
-
})
|
|
325
|
+
})
|
|
326
326
|
).toMatchInlineSnapshot(`Array []`);
|
|
327
327
|
});
|
|
328
328
|
|
|
@@ -346,7 +346,7 @@ describe('OpenAPI Schema', () => {
|
|
|
346
346
|
expect(
|
|
347
347
|
await validateDoc(source, {
|
|
348
348
|
spec: 'error',
|
|
349
|
-
})
|
|
349
|
+
})
|
|
350
350
|
).toMatchInlineSnapshot(`
|
|
351
351
|
Array [
|
|
352
352
|
Object {
|
|
@@ -378,7 +378,7 @@ describe('OpenAPI Schema', () => {
|
|
|
378
378
|
expect(
|
|
379
379
|
await validateDoc(source, {
|
|
380
380
|
spec: 'error',
|
|
381
|
-
})
|
|
381
|
+
})
|
|
382
382
|
).toMatchInlineSnapshot(`
|
|
383
383
|
Array [
|
|
384
384
|
Object {
|
|
@@ -23,7 +23,7 @@ it('should not report if summary field is valid', async () => {
|
|
|
23
23
|
expect(
|
|
24
24
|
await validateDoc(source, {
|
|
25
25
|
spec: 'error',
|
|
26
|
-
})
|
|
26
|
+
})
|
|
27
27
|
).toMatchInlineSnapshot(`Array []`);
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -49,7 +49,7 @@ it('should report if summary field is not string ', async () => {
|
|
|
49
49
|
expect(
|
|
50
50
|
await validateDoc(source, {
|
|
51
51
|
spec: 'error',
|
|
52
|
-
})
|
|
52
|
+
})
|
|
53
53
|
).toMatchInlineSnapshot(`
|
|
54
54
|
Array [
|
|
55
55
|
Object {
|
|
@@ -82,7 +82,7 @@ it('should not report if description field is valid', async () => {
|
|
|
82
82
|
expect(
|
|
83
83
|
await validateDoc(source, {
|
|
84
84
|
spec: 'error',
|
|
85
|
-
})
|
|
85
|
+
})
|
|
86
86
|
).toMatchInlineSnapshot(`Array []`);
|
|
87
87
|
});
|
|
88
88
|
|
|
@@ -108,7 +108,7 @@ it('should report if description field is not string', async () => {
|
|
|
108
108
|
expect(
|
|
109
109
|
await validateDoc(source, {
|
|
110
110
|
spec: 'error',
|
|
111
|
-
})
|
|
111
|
+
})
|
|
112
112
|
).toMatchInlineSnapshot(`
|
|
113
113
|
Array [
|
|
114
114
|
Object {
|
|
@@ -140,7 +140,7 @@ it('should not report of a valid GET operation object', async () => {
|
|
|
140
140
|
expect(
|
|
141
141
|
await validateDoc(source, {
|
|
142
142
|
spec: 'error',
|
|
143
|
-
})
|
|
143
|
+
})
|
|
144
144
|
).toMatchInlineSnapshot(`Array []`);
|
|
145
145
|
});
|
|
146
146
|
|
|
@@ -170,7 +170,7 @@ it('should not report of a valid PUT operation object', async () => {
|
|
|
170
170
|
expect(
|
|
171
171
|
await validateDoc(source, {
|
|
172
172
|
spec: 'error',
|
|
173
|
-
})
|
|
173
|
+
})
|
|
174
174
|
).toMatchInlineSnapshot(`Array []`);
|
|
175
175
|
});
|
|
176
176
|
|
|
@@ -208,7 +208,7 @@ it('should not report of a valid Post operation object', async () => {
|
|
|
208
208
|
expect(
|
|
209
209
|
await validateDoc(source, {
|
|
210
210
|
spec: 'error',
|
|
211
|
-
})
|
|
211
|
+
})
|
|
212
212
|
).toMatchInlineSnapshot(`Array []`);
|
|
213
213
|
});
|
|
214
214
|
|
|
@@ -248,6 +248,6 @@ it('should not report of a valid delete operation object', async () => {
|
|
|
248
248
|
expect(
|
|
249
249
|
await validateDoc(source, {
|
|
250
250
|
spec: 'error',
|
|
251
|
-
})
|
|
251
|
+
})
|
|
252
252
|
).toMatchInlineSnapshot(`Array []`);
|
|
253
253
|
});
|