@redocly/openapi-core 1.0.0-beta.79 → 1.0.0-beta.80
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__/utils.ts +11 -1
- package/lib/config/builtIn.js +18 -4
- package/lib/{rules → decorators}/common/info-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/info-description-override.js +0 -0
- package/lib/{rules → decorators}/common/operation-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/operation-description-override.js +0 -0
- package/lib/{rules → decorators}/common/registry-dependencies.d.ts +0 -0
- package/lib/{rules → decorators}/common/registry-dependencies.js +0 -0
- package/lib/{rules → decorators}/common/remove-x-internal.d.ts +0 -0
- package/lib/{rules → decorators}/common/remove-x-internal.js +0 -0
- package/lib/{rules → decorators}/common/tag-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/tag-description-override.js +0 -0
- package/lib/decorators/oas2/index.d.ts +8 -0
- package/lib/decorators/oas2/index.js +15 -0
- package/lib/decorators/oas3/index.d.ts +8 -0
- package/lib/decorators/oas3/index.js +15 -0
- package/lib/js-yaml/index.js +1 -1
- package/lib/rules/oas2/index.d.ts +1 -8
- package/lib/rules/oas2/index.js +1 -13
- package/lib/rules/oas3/index.d.ts +0 -8
- package/lib/rules/oas3/index.js +1 -13
- package/package.json +1 -1
- package/src/__tests__/js-yaml.test.ts +29 -5
- package/src/__tests__/lint.test.ts +1 -3
- package/src/config/builtIn.ts +20 -7
- package/src/{rules/__tests__/hide-internals.test.ts → decorators/__tests__/remove-x-internal.test.ts} +1 -2
- package/src/{rules → decorators}/common/info-description-override.ts +0 -0
- package/src/{rules → decorators}/common/operation-description-override.ts +0 -0
- package/src/{rules → decorators}/common/registry-dependencies.ts +0 -0
- package/src/{rules → decorators}/common/remove-x-internal.ts +0 -0
- package/src/{rules → decorators}/common/tag-description-override.ts +0 -0
- package/src/decorators/oas2/index.ts +14 -0
- package/src/decorators/oas3/index.ts +14 -0
- package/src/js-yaml/index.ts +1 -2
- package/src/rules/__tests__/no-unresolved-refs.test.ts +1 -4
- package/src/rules/common/__tests__/info-description.test.ts +1 -3
- package/src/rules/common/__tests__/info-license.test.ts +1 -2
- package/src/rules/common/__tests__/license-url.test.ts +1 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -2
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -2
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +1 -2
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -2
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +1 -2
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +1 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -2
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +1 -2
- package/src/rules/common/__tests__/operation-security-defined.test.ts +1 -2
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +1 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +1 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +1 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +1 -2
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +1 -2
- package/src/rules/common/__tests__/tag-description.test.ts +1 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +1 -2
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +1 -2
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -2
- package/src/rules/oas2/index.ts +1 -13
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -2
- package/src/rules/oas3/index.ts +0 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/builtin.d.ts +0 -22
- package/lib/rules/builtin.js +0 -17
- package/src/rules/__tests__/config.ts +0 -11
- package/src/rules/builtin.ts +0 -18
package/__tests__/utils.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
|
|
3
3
|
import { Document, Source, NormalizedProblem, parseYaml, stringifyYaml } from '../src';
|
|
4
|
-
import { RuleConfig, LintConfig, Plugin } from '../src/config/config';
|
|
4
|
+
import { RuleConfig, LintConfig, Plugin, DecoratorConfig } from '../src/config/config';
|
|
5
5
|
import { Oas3RuleSet } from '../src/oas-types';
|
|
6
|
+
import { defaultPlugin } from '../src/config/builtIn';
|
|
6
7
|
|
|
7
8
|
export function parseYamlToDocument(body: string, absoluteRef: string = ''): Document {
|
|
8
9
|
return {
|
|
@@ -62,3 +63,12 @@ export function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin
|
|
|
62
63
|
rules: rulesConf,
|
|
63
64
|
});
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
export function makeConfig(rules: Record<string, RuleConfig>, decorators?: Record<string, DecoratorConfig>) {
|
|
68
|
+
return new LintConfig({
|
|
69
|
+
plugins: [defaultPlugin],
|
|
70
|
+
extends: [],
|
|
71
|
+
rules,
|
|
72
|
+
decorators,
|
|
73
|
+
});
|
|
74
|
+
}
|
package/lib/config/builtIn.js
CHANGED
|
@@ -4,7 +4,12 @@ exports.defaultPlugin = exports.builtInConfigs = void 0;
|
|
|
4
4
|
const recommended_1 = require("./recommended");
|
|
5
5
|
const all_1 = require("./all");
|
|
6
6
|
const minimal_1 = require("./minimal");
|
|
7
|
-
const
|
|
7
|
+
const oas3_1 = require("../rules/oas3");
|
|
8
|
+
const oas2_1 = require("../rules/oas2");
|
|
9
|
+
const oas3_2 = require("../rules/oas3");
|
|
10
|
+
const oas2_2 = require("../rules/oas2");
|
|
11
|
+
const oas3_3 = require("../decorators/oas3");
|
|
12
|
+
const oas2_3 = require("../decorators/oas2");
|
|
8
13
|
exports.builtInConfigs = {
|
|
9
14
|
recommended: recommended_1.default,
|
|
10
15
|
minimal: minimal_1.default,
|
|
@@ -15,8 +20,17 @@ exports.builtInConfigs = {
|
|
|
15
20
|
};
|
|
16
21
|
exports.defaultPlugin = {
|
|
17
22
|
id: '',
|
|
18
|
-
rules:
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
rules: {
|
|
24
|
+
oas3: oas3_1.rules,
|
|
25
|
+
oas2: oas2_1.rules,
|
|
26
|
+
},
|
|
27
|
+
preprocessors: {
|
|
28
|
+
oas3: oas3_2.preprocessors,
|
|
29
|
+
oas2: oas2_2.preprocessors,
|
|
30
|
+
},
|
|
31
|
+
decorators: {
|
|
32
|
+
oas3: oas3_3.decorators,
|
|
33
|
+
oas2: oas2_3.decorators,
|
|
34
|
+
},
|
|
21
35
|
configs: exports.builtInConfigs,
|
|
22
36
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Oas2Decorator } from '../../visitors';
|
|
2
|
+
export declare const decorators: {
|
|
3
|
+
'registry-dependencies': Oas2Decorator;
|
|
4
|
+
'operation-description-override': Oas2Decorator;
|
|
5
|
+
'tag-description-override': Oas2Decorator;
|
|
6
|
+
'info-description-override': Oas2Decorator;
|
|
7
|
+
'remove-x-internal': Oas2Decorator;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decorators = void 0;
|
|
4
|
+
const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
5
|
+
const operation_description_override_1 = require("../common/operation-description-override");
|
|
6
|
+
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
|
+
const info_description_override_1 = require("../common/info-description-override");
|
|
8
|
+
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
9
|
+
exports.decorators = {
|
|
10
|
+
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
|
+
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
|
+
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
|
+
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Oas3Decorator } from '../../visitors';
|
|
2
|
+
export declare const decorators: {
|
|
3
|
+
'registry-dependencies': Oas3Decorator;
|
|
4
|
+
'operation-description-override': Oas3Decorator;
|
|
5
|
+
'tag-description-override': Oas3Decorator;
|
|
6
|
+
'info-description-override': Oas3Decorator;
|
|
7
|
+
'remove-x-internal': Oas3Decorator;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decorators = void 0;
|
|
4
|
+
const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
5
|
+
const operation_description_override_1 = require("../common/operation-description-override");
|
|
6
|
+
const tag_description_override_1 = require("../common/tag-description-override");
|
|
7
|
+
const info_description_override_1 = require("../common/info-description-override");
|
|
8
|
+
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
9
|
+
exports.decorators = {
|
|
10
|
+
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
11
|
+
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
12
|
+
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
13
|
+
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
14
|
+
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
15
|
+
};
|
package/lib/js-yaml/index.js
CHANGED
|
@@ -15,5 +15,5 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
|
|
|
15
15
|
});
|
|
16
16
|
const parseYaml = (str, opts) => js_yaml_1.load(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
|
|
17
17
|
exports.parseYaml = parseYaml;
|
|
18
|
-
const stringifyYaml = (obj, opts) => js_yaml_1.dump(obj,
|
|
18
|
+
const stringifyYaml = (obj, opts) => js_yaml_1.dump(obj, opts);
|
|
19
19
|
exports.stringifyYaml = stringifyYaml;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Oas2Rule } from '../../visitors';
|
|
2
2
|
export declare const rules: {
|
|
3
3
|
spec: Oas2Rule;
|
|
4
4
|
'no-invalid-schema-examples': any;
|
|
@@ -40,10 +40,3 @@ export declare const rules: {
|
|
|
40
40
|
'path-segment-plural': Oas2Rule;
|
|
41
41
|
};
|
|
42
42
|
export declare const preprocessors: {};
|
|
43
|
-
export declare const decorators: {
|
|
44
|
-
'registry-dependencies': Oas2Decorator;
|
|
45
|
-
'operation-description-override': Oas2Decorator;
|
|
46
|
-
'tag-description-override': Oas2Decorator;
|
|
47
|
-
'info-description-override': Oas2Decorator;
|
|
48
|
-
'remove-x-internal': Oas2Decorator;
|
|
49
|
-
};
|
package/lib/rules/oas2/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.preprocessors = exports.rules = void 0;
|
|
4
4
|
const spec_1 = require("../common/spec");
|
|
5
5
|
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples");
|
|
6
6
|
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples");
|
|
@@ -29,7 +29,6 @@ const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
|
29
29
|
const operation_security_defined_1 = require("../common/operation-security-defined");
|
|
30
30
|
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
31
31
|
const path_http_verbs_order_1 = require("../common/path-http-verbs-order");
|
|
32
|
-
const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
33
32
|
const no_identical_paths_1 = require("../common/no-identical-paths");
|
|
34
33
|
const operation_operationId_1 = require("../common/operation-operationId");
|
|
35
34
|
const operation_summary_1 = require("../common/operation-summary");
|
|
@@ -39,10 +38,6 @@ const path_excludes_patterns_1 = require("../common/path-excludes-patterns");
|
|
|
39
38
|
const request_mime_type_1 = require("./request-mime-type");
|
|
40
39
|
const response_mime_type_1 = require("./response-mime-type");
|
|
41
40
|
const path_segment_plural_1 = require("../common/path-segment-plural");
|
|
42
|
-
const operation_description_override_1 = require("../common/operation-description-override");
|
|
43
|
-
const tag_description_override_1 = require("../common/tag-description-override");
|
|
44
|
-
const info_description_override_1 = require("../common/info-description-override");
|
|
45
|
-
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
46
41
|
exports.rules = {
|
|
47
42
|
spec: spec_1.OasSpec,
|
|
48
43
|
'no-invalid-schema-examples': no_invalid_schema_examples_1.NoInvalidSchemaExamples,
|
|
@@ -84,10 +79,3 @@ exports.rules = {
|
|
|
84
79
|
'path-segment-plural': path_segment_plural_1.PathSegmentPlural,
|
|
85
80
|
};
|
|
86
81
|
exports.preprocessors = {};
|
|
87
|
-
exports.decorators = {
|
|
88
|
-
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
89
|
-
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
90
|
-
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
91
|
-
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
92
|
-
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
93
|
-
};
|
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import { Oas3RuleSet } from '../../oas-types';
|
|
2
|
-
import { Oas3Decorator } from '../../visitors';
|
|
3
2
|
export declare const rules: Oas3RuleSet;
|
|
4
3
|
export declare const preprocessors: {};
|
|
5
|
-
export declare const decorators: {
|
|
6
|
-
'registry-dependencies': Oas3Decorator;
|
|
7
|
-
'operation-description-override': Oas3Decorator;
|
|
8
|
-
'tag-description-override': Oas3Decorator;
|
|
9
|
-
'info-description-override': Oas3Decorator;
|
|
10
|
-
'remove-x-internal': Oas3Decorator;
|
|
11
|
-
};
|
package/lib/rules/oas3/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.preprocessors = exports.rules = void 0;
|
|
4
4
|
const spec_1 = require("../common/spec");
|
|
5
5
|
const operation_2xx_response_1 = require("../common/operation-2xx-response");
|
|
6
6
|
const operation_4xx_response_1 = require("../common/operation-4xx-response");
|
|
@@ -33,7 +33,6 @@ const paths_kebab_case_1 = require("../common/paths-kebab-case");
|
|
|
33
33
|
const path_http_verbs_order_1 = require("../common/path-http-verbs-order");
|
|
34
34
|
const no_empty_servers_1 = require("./no-empty-servers");
|
|
35
35
|
const no_invalid_media_type_examples_1 = require("./no-invalid-media-type-examples");
|
|
36
|
-
const registry_dependencies_1 = require("../common/registry-dependencies");
|
|
37
36
|
const no_identical_paths_1 = require("../common/no-identical-paths");
|
|
38
37
|
const no_undefined_server_variable_1 = require("./no-undefined-server-variable");
|
|
39
38
|
const operation_operationId_1 = require("../common/operation-operationId");
|
|
@@ -44,13 +43,9 @@ const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths");
|
|
|
44
43
|
const request_mime_type_1 = require("./request-mime-type");
|
|
45
44
|
const response_mime_type_1 = require("./response-mime-type");
|
|
46
45
|
const path_segment_plural_1 = require("../common/path-segment-plural");
|
|
47
|
-
const operation_description_override_1 = require("../common/operation-description-override");
|
|
48
|
-
const tag_description_override_1 = require("../common/tag-description-override");
|
|
49
|
-
const info_description_override_1 = require("../common/info-description-override");
|
|
50
46
|
const path_excludes_patterns_1 = require("../common/path-excludes-patterns");
|
|
51
47
|
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples");
|
|
52
48
|
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples");
|
|
53
|
-
const remove_x_internal_1 = require("../common/remove-x-internal");
|
|
54
49
|
exports.rules = {
|
|
55
50
|
spec: spec_1.OasSpec,
|
|
56
51
|
'info-description': info_description_1.InfoDescription,
|
|
@@ -100,10 +95,3 @@ exports.rules = {
|
|
|
100
95
|
'no-invalid-parameter-examples': no_invalid_parameter_examples_1.NoInvalidParameterExamples,
|
|
101
96
|
};
|
|
102
97
|
exports.preprocessors = {};
|
|
103
|
-
exports.decorators = {
|
|
104
|
-
'registry-dependencies': registry_dependencies_1.RegistryDependencies,
|
|
105
|
-
'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
|
|
106
|
-
'tag-description-override': tag_description_override_1.TagDescriptionOverride,
|
|
107
|
-
'info-description-override': info_description_override_1.InfoDescriptionOverride,
|
|
108
|
-
'remove-x-internal': remove_x_internal_1.RemoveXInternal
|
|
109
|
-
};
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { outdent } from 'outdent';
|
|
1
2
|
import { parseYaml, stringifyYaml } from '../js-yaml';
|
|
2
3
|
|
|
3
4
|
const yaml = `
|
|
@@ -7,7 +8,8 @@ const yaml = `
|
|
|
7
8
|
number: 1000
|
|
8
9
|
decimal: 12.34
|
|
9
10
|
boolean: true
|
|
10
|
-
|
|
11
|
+
dateWithoutQuotes: 2020-01-01
|
|
12
|
+
dateWithQuotes: '2020-01-01'
|
|
11
13
|
array:
|
|
12
14
|
- 1
|
|
13
15
|
- 2
|
|
@@ -16,6 +18,16 @@ const yaml = `
|
|
|
16
18
|
key2: 2
|
|
17
19
|
`;
|
|
18
20
|
|
|
21
|
+
const yamlToDump = outdent`
|
|
22
|
+
date: '2022-01-21T11:29:56.694Z'
|
|
23
|
+
dateWithoutQuotes: 2020-01-01
|
|
24
|
+
dateWithQuotes: '2020-01-01'
|
|
25
|
+
dateImplicit: !!str 2020-01-01
|
|
26
|
+
string: test
|
|
27
|
+
stringWithQuotes: 'test'
|
|
28
|
+
stringWithDoubleQuotes: "test"
|
|
29
|
+
`;
|
|
30
|
+
|
|
19
31
|
const jsObject = {
|
|
20
32
|
emptyValue: null,
|
|
21
33
|
'spaces in keys': 'spaces in keys',
|
|
@@ -23,7 +35,8 @@ const jsObject = {
|
|
|
23
35
|
number: 1000,
|
|
24
36
|
decimal: 12.34,
|
|
25
37
|
boolean: true,
|
|
26
|
-
|
|
38
|
+
dateWithoutQuotes: '2020-01-01',
|
|
39
|
+
dateWithQuotes: '2020-01-01',
|
|
27
40
|
array: [1, 2],
|
|
28
41
|
object: { key1: 1, key2: 2 },
|
|
29
42
|
};
|
|
@@ -33,14 +46,25 @@ describe('js-yaml', () => {
|
|
|
33
46
|
expect(parseYaml(yaml)).toEqual(jsObject);
|
|
34
47
|
});
|
|
35
48
|
|
|
49
|
+
test('should correctly dump date and string', () => {
|
|
50
|
+
expect(stringifyYaml(parseYaml(yamlToDump))).toMatchInlineSnapshot(
|
|
51
|
+
`
|
|
52
|
+
"date: '2022-01-21T11:29:56.694Z'
|
|
53
|
+
dateWithoutQuotes: '2020-01-01'
|
|
54
|
+
dateWithQuotes: '2020-01-01'
|
|
55
|
+
dateImplicit: '2020-01-01'
|
|
56
|
+
string: test
|
|
57
|
+
stringWithQuotes: test
|
|
58
|
+
stringWithDoubleQuotes: test
|
|
59
|
+
"
|
|
60
|
+
`);
|
|
61
|
+
});
|
|
62
|
+
|
|
36
63
|
test('parse and stringify', () => {
|
|
37
64
|
expect(parseYaml(stringifyYaml(jsObject))).toEqual(jsObject);
|
|
38
65
|
});
|
|
39
66
|
|
|
40
67
|
test('should throw an error for unsupported types', () => {
|
|
41
|
-
expect(() => stringifyYaml({ date: new Date() }))
|
|
42
|
-
.toThrow('unacceptable kind of an object to dump [object Date]');
|
|
43
|
-
|
|
44
68
|
expect(() => stringifyYaml({ foo: () => {} }))
|
|
45
69
|
.toThrow('unacceptable kind of an object to dump [object Function]');
|
|
46
70
|
});
|
|
@@ -3,9 +3,7 @@ import { outdent } from 'outdent';
|
|
|
3
3
|
import { lintFromString, lintConfig, lintDocument } from '../lint';
|
|
4
4
|
import { BaseResolver } from '../resolve';
|
|
5
5
|
import { loadConfig } from '../config/load';
|
|
6
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../__tests__/utils';
|
|
7
|
-
// todo create general utils for tests and move this config.
|
|
8
|
-
import { makeConfig } from '../rules/__tests__/config';
|
|
6
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../__tests__/utils';
|
|
9
7
|
|
|
10
8
|
describe('lint', () => {
|
|
11
9
|
it('lintFromString should work', async () => {
|
package/src/config/builtIn.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import recommended from './recommended';
|
|
2
2
|
import all from './all';
|
|
3
3
|
import minimal from './minimal';
|
|
4
|
-
import { LintRawConfig, Plugin } from './config';
|
|
5
|
-
|
|
6
|
-
import
|
|
4
|
+
import { CustomRulesConfig, LintRawConfig, Plugin } from './config';
|
|
5
|
+
import { rules as oas3Rules } from '../rules/oas3';
|
|
6
|
+
import { rules as oas2Rules } from '../rules/oas2';
|
|
7
|
+
import { preprocessors as oas3Preprocessors } from '../rules/oas3';
|
|
8
|
+
import { preprocessors as oas2Preprocessors } from '../rules/oas2';
|
|
9
|
+
import { decorators as oas3Decorators } from '../decorators/oas3';
|
|
10
|
+
import { decorators as oas2Decorators } from '../decorators/oas2';
|
|
7
11
|
|
|
8
12
|
export const builtInConfigs: Record<string, LintRawConfig> = {
|
|
9
13
|
recommended,
|
|
@@ -16,8 +20,17 @@ export const builtInConfigs: Record<string, LintRawConfig> = {
|
|
|
16
20
|
|
|
17
21
|
export const defaultPlugin: Plugin = {
|
|
18
22
|
id: '', // default plugin doesn't have id
|
|
19
|
-
rules:
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
rules: {
|
|
24
|
+
oas3: oas3Rules,
|
|
25
|
+
oas2: oas2Rules,
|
|
26
|
+
} as CustomRulesConfig,
|
|
27
|
+
preprocessors: {
|
|
28
|
+
oas3: oas3Preprocessors,
|
|
29
|
+
oas2: oas2Preprocessors,
|
|
30
|
+
},
|
|
31
|
+
decorators: {
|
|
32
|
+
oas3: oas3Decorators,
|
|
33
|
+
oas2: oas2Decorators,
|
|
34
|
+
},
|
|
22
35
|
configs: builtInConfigs,
|
|
23
|
-
}
|
|
36
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { bundleDocument } from '../../bundle';
|
|
3
3
|
import { BaseResolver } from '../../resolve';
|
|
4
|
-
import { parseYamlToDocument, yamlSerializer } from '../../../__tests__/utils';
|
|
5
|
-
import { makeConfig } from './config';
|
|
4
|
+
import { parseYamlToDocument, yamlSerializer, makeConfig } from '../../../__tests__/utils';
|
|
6
5
|
|
|
7
6
|
describe('oas3 remove-x-internal', () => {
|
|
8
7
|
expect.addSnapshotSerializer(yamlSerializer);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Oas2Decorator } from '../../visitors';
|
|
2
|
+
import { RegistryDependencies } from '../common/registry-dependencies';
|
|
3
|
+
import { OperationDescriptionOverride } from '../common/operation-description-override';
|
|
4
|
+
import { TagDescriptionOverride } from '../common/tag-description-override';
|
|
5
|
+
import { InfoDescriptionOverride } from '../common/info-description-override';
|
|
6
|
+
import { RemoveXInternal } from '../common/remove-x-internal';
|
|
7
|
+
|
|
8
|
+
export const decorators = {
|
|
9
|
+
'registry-dependencies': RegistryDependencies as Oas2Decorator,
|
|
10
|
+
'operation-description-override': OperationDescriptionOverride as Oas2Decorator,
|
|
11
|
+
'tag-description-override': TagDescriptionOverride as Oas2Decorator,
|
|
12
|
+
'info-description-override': InfoDescriptionOverride as Oas2Decorator,
|
|
13
|
+
'remove-x-internal': RemoveXInternal as Oas2Decorator
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Oas3Decorator } from '../../visitors';
|
|
2
|
+
import { RegistryDependencies } from '../common/registry-dependencies';
|
|
3
|
+
import { OperationDescriptionOverride } from '../common/operation-description-override';
|
|
4
|
+
import { TagDescriptionOverride } from '../common/tag-description-override';
|
|
5
|
+
import { InfoDescriptionOverride } from '../common/info-description-override';
|
|
6
|
+
import { RemoveXInternal } from '../common/remove-x-internal';
|
|
7
|
+
|
|
8
|
+
export const decorators = {
|
|
9
|
+
'registry-dependencies': RegistryDependencies as Oas3Decorator,
|
|
10
|
+
'operation-description-override': OperationDescriptionOverride as Oas3Decorator,
|
|
11
|
+
'tag-description-override': TagDescriptionOverride as Oas3Decorator,
|
|
12
|
+
'info-description-override': InfoDescriptionOverride as Oas3Decorator,
|
|
13
|
+
'remove-x-internal': RemoveXInternal as Oas3Decorator
|
|
14
|
+
};
|
package/src/js-yaml/index.ts
CHANGED
|
@@ -15,5 +15,4 @@ const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = JSON_SCHEMA.extend({
|
|
|
15
15
|
export const parseYaml = (str: string, opts?: LoadOptions): unknown =>
|
|
16
16
|
load(str, {schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts});
|
|
17
17
|
|
|
18
|
-
export const stringifyYaml = (obj: any, opts?: DumpOptions): string =>
|
|
19
|
-
dump(obj, {schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts});
|
|
18
|
+
export const stringifyYaml = (obj: any, opts?: DumpOptions): string => dump(obj, opts);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import path = require('path');
|
|
2
2
|
import { outdent } from 'outdent';
|
|
3
|
-
|
|
4
3
|
import { lintDocument } from '../../lint';
|
|
5
4
|
import { BaseResolver } from '../../resolve';
|
|
6
|
-
|
|
7
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../__tests__/utils';
|
|
8
|
-
import { makeConfig } from './config';
|
|
5
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../__tests__/utils';
|
|
9
6
|
|
|
10
7
|
describe('oas3 boolean-parameter-prefixes', () => {
|
|
11
8
|
it('should report on unresolved $ref', async () => {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
5
|
|
|
6
|
-
import { makeConfig } from '../../__tests__/config';
|
|
7
|
-
|
|
8
6
|
describe('Oas3 info-description', () => {
|
|
9
7
|
it('should report on info with no description', async () => {
|
|
10
8
|
const document = parseYamlToDocument(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 info-license', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 license-url', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('no-ambiguous-paths', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 typed enum', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('no-identical-paths', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('no-path-trailing-slash', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-2xx-response', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-4xx-response', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-operationId-unique', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-operationId-url-safe', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-parameters-unique', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-security-defined', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Oas3 operation-singular-tag', () => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import { lintDocument } from '../../../lint';
|
|
3
|
-
import { parseYamlToDocument, replaceSourceWithRef } from '../../../../__tests__/utils';
|
|
4
|
-
import { makeConfig } from '../../__tests__/config';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
5
4
|
import { BaseResolver } from '../../../resolve';
|
|
6
5
|
|
|
7
6
|
describe('Common path-http-verbs-order', () => {
|