@redocly/openapi-core 1.0.0-beta.103 → 1.0.0-beta.106
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 +8 -6
- 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 +2 -2
- package/lib/config/all.d.ts +2 -2
- package/lib/config/all.js +1 -1
- 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 +39 -36
- package/lib/config/config.d.ts +6 -5
- package/lib/config/config.js +27 -20
- package/lib/config/load.js +6 -7
- package/lib/config/minimal.d.ts +2 -2
- package/lib/config/minimal.js +1 -1
- package/lib/config/recommended.d.ts +2 -2
- package/lib/config/recommended.js +1 -1
- package/lib/config/rules.d.ts +2 -2
- 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 +43 -26
- package/lib/decorators/common/filters/filter-helper.js +1 -1
- package/lib/decorators/common/remove-x-internal.js +2 -2
- package/lib/format/format.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -2
- package/lib/js-yaml/index.js +1 -6
- package/lib/lint.d.ts +2 -2
- package/lib/lint.js +16 -6
- package/lib/redocly/registry-api.d.ts +1 -1
- package/lib/redocly/registry-api.js +2 -2
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.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/operation-operationId.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 +1 -1
- package/lib/rules/oas2/index.js +4 -4
- package/lib/rules/oas2/remove-unused-components.js +3 -3
- package/lib/rules/oas3/index.js +4 -4
- package/lib/rules/oas3/no-empty-servers.js +1 -1
- package/lib/rules/oas3/remove-unused-components.js +2 -2
- package/lib/rules/other/stats.js +43 -14
- package/lib/rules/utils.d.ts +1 -1
- package/lib/rules/utils.js +4 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/redocly-yaml.js +9 -7
- package/lib/utils.d.ts +3 -2
- package/lib/utils.js +11 -2
- package/lib/walk.d.ts +2 -14
- package/lib/walk.js +19 -19
- package/package.json +3 -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__/fixtures/.redocly.lint-ignore.yaml +5 -0
- package/src/__tests__/js-yaml.test.ts +6 -4
- package/src/__tests__/lint.test.ts +127 -12
- package/src/__tests__/login.test.ts +2 -2
- package/src/__tests__/normalizeVisitors.test.ts +4 -4
- 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.test.ts +42 -1
- 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 -1
- 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 +18 -17
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +1 -1
- package/src/config/__tests__/config-resolvers.test.ts +123 -121
- package/src/config/__tests__/config.test.ts +76 -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 +2 -2
- package/src/config/__tests__/resolve-plugins.test.ts +3 -3
- package/src/config/__tests__/utils.test.ts +83 -0
- package/src/config/all.ts +3 -4
- package/src/config/builtIn.ts +5 -5
- package/src/config/config-resolvers.ts +122 -83
- package/src/config/config.ts +36 -32
- package/src/config/load.ts +13 -16
- package/src/config/minimal.ts +3 -3
- package/src/config/recommended.ts +3 -3
- package/src/config/rules.ts +6 -6
- package/src/config/types.ts +28 -19
- package/src/config/utils.ts +70 -50
- package/src/decorators/__tests__/filter-out.test.ts +113 -5
- 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/remove-x-internal.ts +4 -4
- package/src/decorators/common/tag-description-override.ts +1 -1
- package/src/format/codeframes.ts +4 -4
- package/src/format/format.ts +10 -10
- package/src/index.ts +3 -4
- package/src/js-yaml/index.ts +3 -8
- package/src/lint.ts +22 -18
- package/src/oas-types.ts +1 -6
- package/src/redocly/__tests__/redocly-client.test.ts +25 -19
- package/src/redocly/index.ts +6 -4
- package/src/redocly/registry-api.ts +6 -6
- package/src/ref-utils.ts +2 -2
- package/src/resolve.ts +7 -4
- package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
- package/src/rules/__tests__/utils.test.ts +122 -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/index.ts +6 -6
- 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 +2 -2
- package/src/rules/common/no-invalid-schema-examples.ts +1 -1
- package/src/rules/common/operation-operationId.ts +1 -1
- package/src/rules/common/operation-parameters-unique.ts +2 -2
- 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 +10 -7
- 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 +13 -8
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
- 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 +8 -8
- 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 +3 -3
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +12 -4
- package/src/rules/oas3/no-servers-empty-enum.ts +9 -10
- package/src/rules/oas3/remove-unused-components.ts +18 -7
- package/src/rules/other/stats.ts +46 -17
- package/src/rules/utils.ts +5 -3
- package/src/types/index.ts +5 -5
- package/src/types/redocly-yaml.ts +9 -7
- package/src/typings/common.ts +9 -1
- package/src/typings/openapi.ts +1 -1
- package/src/utils.ts +18 -8
- package/src/visitors.ts +4 -4
- package/src/walk.ts +23 -31
- 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/src/rules/common/license-url.ts +0 -10
package/lib/rules/oas3/index.js
CHANGED
|
@@ -20,13 +20,13 @@ const no_server_trailing_slash_1 = require("./no-server-trailing-slash");
|
|
|
20
20
|
const info_description_1 = require("../common/info-description");
|
|
21
21
|
const tag_description_1 = require("../common/tag-description");
|
|
22
22
|
const info_contact_1 = require("../common/info-contact");
|
|
23
|
+
const info_license_1 = require("../common/info-license");
|
|
23
24
|
const info_license_url_1 = require("../common/info-license-url");
|
|
24
25
|
const operation_description_1 = require("../common/operation-description");
|
|
25
26
|
const no_unused_components_1 = require("./no-unused-components");
|
|
26
27
|
const path_not_include_query_1 = require("../common/path-not-include-query");
|
|
27
28
|
const parameter_description_1 = require("../common/parameter-description");
|
|
28
29
|
const operation_singular_tag_1 = require("../common/operation-singular-tag");
|
|
29
|
-
const license_url_1 = require("../common/license-url");
|
|
30
30
|
const operation_security_defined_1 = require("../common/operation-security-defined");
|
|
31
31
|
const no_unresolved_refs_1 = require("../no-unresolved-refs");
|
|
32
32
|
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes");
|
|
@@ -54,11 +54,11 @@ exports.rules = {
|
|
|
54
54
|
spec: spec_1.OasSpec,
|
|
55
55
|
'info-description': info_description_1.InfoDescription,
|
|
56
56
|
'info-contact': info_contact_1.InfoContact,
|
|
57
|
-
'info-license':
|
|
58
|
-
'info-license-url':
|
|
57
|
+
'info-license': info_license_1.InfoLicense,
|
|
58
|
+
'info-license-url': info_license_url_1.InfoLicenseUrl,
|
|
59
59
|
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse,
|
|
60
60
|
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse,
|
|
61
|
-
|
|
61
|
+
assertions: assertions_1.Assertions,
|
|
62
62
|
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique,
|
|
63
63
|
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique,
|
|
64
64
|
'path-parameters-defined': path_params_defined_1.PathParamsDefined,
|
|
@@ -24,13 +24,13 @@ const RemoveUnusedComponents = () => {
|
|
|
24
24
|
name: key.toString(),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
28
|
},
|
|
29
29
|
DefinitionRoot: {
|
|
30
30
|
leave(root, ctx) {
|
|
31
31
|
const data = ctx.getVisitorData();
|
|
32
32
|
data.removedCount = 0;
|
|
33
|
-
components.forEach(usageInfo => {
|
|
33
|
+
components.forEach((usageInfo) => {
|
|
34
34
|
const { used, componentType, name } = usageInfo;
|
|
35
35
|
if (!used && componentType) {
|
|
36
36
|
let componentChild = root.components[componentType];
|
package/lib/rules/other/stats.js
CHANGED
|
@@ -3,10 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Stats = void 0;
|
|
4
4
|
const Stats = (statsAccumulator) => {
|
|
5
5
|
return {
|
|
6
|
-
ExternalDocs: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
ExternalDocs: {
|
|
7
|
+
leave() {
|
|
8
|
+
statsAccumulator.externalDocs.total++;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
ref: {
|
|
12
|
+
enter(ref) {
|
|
13
|
+
statsAccumulator.refs.items.add(ref['$ref']);
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
Tag: {
|
|
17
|
+
leave(tag) {
|
|
18
|
+
statsAccumulator.tags.items.add(tag.name);
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
Link: {
|
|
22
|
+
leave(link) {
|
|
23
|
+
statsAccumulator.links.items.add(link.operationId);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
10
26
|
DefinitionRoot: {
|
|
11
27
|
leave() {
|
|
12
28
|
statsAccumulator.parameters.total = statsAccumulator.parameters.items.size;
|
|
@@ -18,27 +34,40 @@ const Stats = (statsAccumulator) => {
|
|
|
18
34
|
WebhooksMap: {
|
|
19
35
|
Operation: {
|
|
20
36
|
leave(operation) {
|
|
21
|
-
operation.tags.forEach((tag) => {
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
operation.tags.forEach((tag) => {
|
|
38
|
+
statsAccumulator.tags.items.add(tag);
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
},
|
|
24
42
|
},
|
|
25
43
|
PathMap: {
|
|
26
44
|
PathItem: {
|
|
27
|
-
leave() {
|
|
45
|
+
leave() {
|
|
46
|
+
statsAccumulator.pathItems.total++;
|
|
47
|
+
},
|
|
28
48
|
Operation: {
|
|
29
49
|
leave(operation) {
|
|
30
50
|
statsAccumulator.operations.total++;
|
|
31
|
-
operation.tags &&
|
|
32
|
-
|
|
51
|
+
operation.tags &&
|
|
52
|
+
operation.tags.forEach((tag) => {
|
|
53
|
+
statsAccumulator.tags.items.add(tag);
|
|
54
|
+
});
|
|
55
|
+
},
|
|
33
56
|
},
|
|
34
|
-
Parameter: {
|
|
57
|
+
Parameter: {
|
|
58
|
+
leave(parameter) {
|
|
35
59
|
statsAccumulator.parameters.items.add(parameter.name);
|
|
36
|
-
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
37
62
|
},
|
|
38
63
|
},
|
|
39
64
|
NamedSchemas: {
|
|
40
|
-
Schema: {
|
|
41
|
-
|
|
65
|
+
Schema: {
|
|
66
|
+
leave() {
|
|
67
|
+
statsAccumulator.schemas.total++;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
42
71
|
};
|
|
43
72
|
};
|
|
44
73
|
exports.Stats = Stats;
|
package/lib/rules/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UserContext } from '../walk';
|
|
2
2
|
import { Location } from '../ref-utils';
|
|
3
3
|
import { Oas3Schema, Referenced } from '../typings/openapi';
|
|
4
|
-
export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array" | "null";
|
|
4
|
+
export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "integer" | "array" | "null";
|
|
5
5
|
/**
|
|
6
6
|
* Checks if value matches specified JSON schema type
|
|
7
7
|
*
|
package/lib/rules/utils.js
CHANGED
|
@@ -11,6 +11,9 @@ function oasTypeOf(value) {
|
|
|
11
11
|
else if (value === null) {
|
|
12
12
|
return 'null';
|
|
13
13
|
}
|
|
14
|
+
else if (Number.isInteger(value)) {
|
|
15
|
+
return 'integer';
|
|
16
|
+
}
|
|
14
17
|
else {
|
|
15
18
|
return typeof value;
|
|
16
19
|
}
|
|
@@ -25,7 +28,7 @@ exports.oasTypeOf = oasTypeOf;
|
|
|
25
28
|
*/
|
|
26
29
|
function matchesJsonSchemaType(value, type, nullable) {
|
|
27
30
|
if (nullable && value === null) {
|
|
28
|
-
return
|
|
31
|
+
return true;
|
|
29
32
|
}
|
|
30
33
|
switch (type) {
|
|
31
34
|
case 'array':
|
package/lib/types/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare type NodeType = {
|
|
|
22
22
|
items?: string;
|
|
23
23
|
required?: string[] | ((value: any, key: string | number | undefined) => string[]);
|
|
24
24
|
requiredOneOf?: string[];
|
|
25
|
-
allowed?: (
|
|
25
|
+
allowed?: (value: any) => string[] | undefined;
|
|
26
26
|
extensionsPrefix?: string;
|
|
27
27
|
};
|
|
28
28
|
declare type PropType = string | NodeType | ScalarSchema | undefined | null;
|
|
@@ -34,7 +34,7 @@ export declare type NormalizedNodeType = {
|
|
|
34
34
|
items?: NormalizedNodeType;
|
|
35
35
|
required?: string[] | ((value: any, key: string | number | undefined) => string[]);
|
|
36
36
|
requiredOneOf?: string[];
|
|
37
|
-
allowed?: (
|
|
37
|
+
allowed?: (value: any) => string[] | undefined;
|
|
38
38
|
extensionsPrefix?: string;
|
|
39
39
|
};
|
|
40
40
|
declare type NormalizedPropType = NormalizedNodeType | NormalizedScalarSchema | undefined | null;
|
|
@@ -53,6 +53,7 @@ const builtInRulesList = [
|
|
|
53
53
|
'no-invalid-parameter-examples',
|
|
54
54
|
'response-contains-header',
|
|
55
55
|
'response-contains-property',
|
|
56
|
+
'scalar-property-missing-example',
|
|
56
57
|
];
|
|
57
58
|
const nodeTypesList = [
|
|
58
59
|
'DefinitionRoot',
|
|
@@ -111,7 +112,8 @@ const ConfigRoot = {
|
|
|
111
112
|
properties: {},
|
|
112
113
|
additionalProperties: { properties: { type: 'string' } },
|
|
113
114
|
},
|
|
114
|
-
|
|
115
|
+
styleguide: 'RootConfigStyleguide',
|
|
116
|
+
lint: 'RootConfigStyleguide',
|
|
115
117
|
'features.openapi': 'ConfigReferenceDocs',
|
|
116
118
|
referenceDocs: 'ConfigReferenceDocs',
|
|
117
119
|
'features.mockServer': 'ConfigMockServer',
|
|
@@ -136,7 +138,7 @@ const ConfigApisProperties = {
|
|
|
136
138
|
type: 'string',
|
|
137
139
|
},
|
|
138
140
|
},
|
|
139
|
-
|
|
141
|
+
styleguide: 'ConfigStyleguide',
|
|
140
142
|
'features.openapi': 'ConfigReferenceDocs',
|
|
141
143
|
'features.mockServer': 'ConfigMockServer',
|
|
142
144
|
},
|
|
@@ -152,7 +154,7 @@ const ConfigHTTP = {
|
|
|
152
154
|
},
|
|
153
155
|
},
|
|
154
156
|
};
|
|
155
|
-
const
|
|
157
|
+
const ConfigStyleguide = {
|
|
156
158
|
properties: {
|
|
157
159
|
extends: {
|
|
158
160
|
type: 'array',
|
|
@@ -175,11 +177,11 @@ const ConfigLint = {
|
|
|
175
177
|
oas3_1Decorators: { type: 'object' },
|
|
176
178
|
},
|
|
177
179
|
};
|
|
178
|
-
const
|
|
180
|
+
const RootConfigStyleguide = {
|
|
179
181
|
properties: Object.assign({ plugins: {
|
|
180
182
|
type: 'array',
|
|
181
183
|
items: { type: 'string' },
|
|
182
|
-
} },
|
|
184
|
+
} }, ConfigStyleguide.properties),
|
|
183
185
|
};
|
|
184
186
|
const Rules = {
|
|
185
187
|
properties: {},
|
|
@@ -764,8 +766,8 @@ exports.ConfigTypes = {
|
|
|
764
766
|
ConfigRoot,
|
|
765
767
|
ConfigApis,
|
|
766
768
|
ConfigApisProperties,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
+
RootConfigStyleguide,
|
|
770
|
+
ConfigStyleguide,
|
|
769
771
|
ConfigReferenceDocs,
|
|
770
772
|
ConfigMockServer,
|
|
771
773
|
ConfigHTTP,
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UserContext } from './walk';
|
|
2
|
-
import
|
|
2
|
+
import { HttpResolveConfig } from './config';
|
|
3
3
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
4
4
|
export declare type StackFrame<T> = {
|
|
5
5
|
prev: StackFrame<T> | null;
|
|
@@ -38,5 +38,6 @@ export declare function isNotEmptyObject(obj: any): boolean;
|
|
|
38
38
|
export declare function isString(value: unknown): value is string;
|
|
39
39
|
export declare function isNotString<T>(value: string | T): value is T;
|
|
40
40
|
export declare function assignExisting<T>(target: Record<string, T>, obj: Record<string, T>): void;
|
|
41
|
-
export declare
|
|
41
|
+
export declare function getMatchingStatusCodeRange(code: number | string): string;
|
|
42
42
|
export declare function isCustomRuleId(id: string): boolean;
|
|
43
|
+
export declare function doesYamlFileExist(filePath: string): boolean;
|
package/lib/utils.js
CHANGED
|
@@ -9,8 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
12
|
+
exports.doesYamlFileExist = exports.isCustomRuleId = exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
14
15
|
const minimatch = require("minimatch");
|
|
15
16
|
const node_fetch_1 = require("node-fetch");
|
|
16
17
|
const pluralize = require("pluralize");
|
|
@@ -173,9 +174,17 @@ function assignExisting(target, obj) {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
exports.assignExisting = assignExisting;
|
|
176
|
-
|
|
177
|
+
function getMatchingStatusCodeRange(code) {
|
|
178
|
+
return `${code}`.replace(/^(\d)\d\d$/, (_, firstDigit) => `${firstDigit}XX`);
|
|
179
|
+
}
|
|
177
180
|
exports.getMatchingStatusCodeRange = getMatchingStatusCodeRange;
|
|
178
181
|
function isCustomRuleId(id) {
|
|
179
182
|
return id.includes('/');
|
|
180
183
|
}
|
|
181
184
|
exports.isCustomRuleId = isCustomRuleId;
|
|
185
|
+
function doesYamlFileExist(filePath) {
|
|
186
|
+
return ((path_1.extname(filePath) === '.yaml' || path_1.extname(filePath) === '.yml') &&
|
|
187
|
+
fs.hasOwnProperty('existsSync') &&
|
|
188
|
+
fs.existsSync(filePath));
|
|
189
|
+
}
|
|
190
|
+
exports.doesYamlFileExist = doesYamlFileExist;
|
package/lib/walk.d.ts
CHANGED
|
@@ -14,25 +14,13 @@ export declare type ResolveResult<T extends NonUndefined> = {
|
|
|
14
14
|
location: undefined;
|
|
15
15
|
error?: ResolveError | YamlParseError;
|
|
16
16
|
};
|
|
17
|
-
export declare type ResolveFn<T>
|
|
18
|
-
location: Location;
|
|
19
|
-
node: T;
|
|
20
|
-
} | {
|
|
21
|
-
location: undefined;
|
|
22
|
-
node: undefined;
|
|
23
|
-
};
|
|
17
|
+
export declare type ResolveFn = <T>(node: Referenced<T>, from?: string) => ResolveResult<T>;
|
|
24
18
|
export declare type UserContext = {
|
|
25
19
|
report(problem: Problem): void;
|
|
26
20
|
location: Location;
|
|
27
21
|
rawNode: any;
|
|
28
22
|
rawLocation: Location;
|
|
29
|
-
resolve
|
|
30
|
-
location: Location;
|
|
31
|
-
node: T;
|
|
32
|
-
} | {
|
|
33
|
-
location: undefined;
|
|
34
|
-
node: undefined;
|
|
35
|
-
};
|
|
23
|
+
resolve: ResolveFn;
|
|
36
24
|
parentLocations: Record<string, Location>;
|
|
37
25
|
type: NormalizedNodeType;
|
|
38
26
|
key: string | number;
|
package/lib/walk.js
CHANGED
|
@@ -32,6 +32,25 @@ function walkDocument(opts) {
|
|
|
32
32
|
walkNode(document.parsed, rootType, new ref_utils_1.Location(document.source, '#/'), undefined, '');
|
|
33
33
|
function walkNode(node, type, location, parent, key) {
|
|
34
34
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
35
|
+
const resolve = (ref, from = currentLocation.source.absoluteRef) => {
|
|
36
|
+
if (!ref_utils_1.isRef(ref))
|
|
37
|
+
return { location, node: ref };
|
|
38
|
+
const refId = resolve_1.makeRefId(from, ref.$ref);
|
|
39
|
+
const resolvedRef = resolvedRefMap.get(refId);
|
|
40
|
+
if (!resolvedRef) {
|
|
41
|
+
return {
|
|
42
|
+
location: undefined,
|
|
43
|
+
node: undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const { resolved, node, document, nodePointer, error } = resolvedRef;
|
|
47
|
+
const newLocation = resolved
|
|
48
|
+
? new ref_utils_1.Location(document.source, nodePointer)
|
|
49
|
+
: error instanceof resolve_1.YamlParseError
|
|
50
|
+
? new ref_utils_1.Location(error.source, '')
|
|
51
|
+
: undefined;
|
|
52
|
+
return { location: newLocation, node, error };
|
|
53
|
+
};
|
|
35
54
|
const rawLocation = location;
|
|
36
55
|
let currentLocation = location;
|
|
37
56
|
const { node: resolvedNode, location: resolvedLocation, error } = resolve(node);
|
|
@@ -224,25 +243,6 @@ function walkDocument(opts) {
|
|
|
224
243
|
}, collectParents(context), context);
|
|
225
244
|
return { ignoreNextVisitorsOnNode };
|
|
226
245
|
}
|
|
227
|
-
function resolve(ref, from = currentLocation.source.absoluteRef) {
|
|
228
|
-
if (!ref_utils_1.isRef(ref))
|
|
229
|
-
return { location, node: ref };
|
|
230
|
-
const refId = resolve_1.makeRefId(from, ref.$ref);
|
|
231
|
-
const resolvedRef = resolvedRefMap.get(refId);
|
|
232
|
-
if (!resolvedRef) {
|
|
233
|
-
return {
|
|
234
|
-
location: undefined,
|
|
235
|
-
node: undefined,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const { resolved, node, document, nodePointer, error } = resolvedRef;
|
|
239
|
-
const newLocation = resolved
|
|
240
|
-
? new ref_utils_1.Location(document.source, nodePointer)
|
|
241
|
-
: error instanceof resolve_1.YamlParseError
|
|
242
|
-
? new ref_utils_1.Location(error.source, '')
|
|
243
|
-
: undefined;
|
|
244
|
-
return { location: newLocation, node, error };
|
|
245
|
-
}
|
|
246
246
|
function reportFn(ruleId, severity, opts) {
|
|
247
247
|
const loc = opts.location
|
|
248
248
|
? Array.isArray(opts.location)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.106",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"fs": false,
|
|
17
17
|
"path": "path-browserify",
|
|
18
18
|
"os": false,
|
|
19
|
-
"node-fetch": false
|
|
19
|
+
"node-fetch": false,
|
|
20
|
+
"colorette": false
|
|
20
21
|
},
|
|
21
22
|
"homepage": "https://github.com/Redocly/redocly-cli",
|
|
22
23
|
"keywords": [
|
|
@@ -1,5 +1,146 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`bundle should add to meta ref from redocly registry 1`] = `
|
|
4
|
+
fileDependencies: {}
|
|
5
|
+
rootType:
|
|
6
|
+
properties:
|
|
7
|
+
openapi: null
|
|
8
|
+
info:
|
|
9
|
+
properties:
|
|
10
|
+
title:
|
|
11
|
+
type: string
|
|
12
|
+
version:
|
|
13
|
+
type: string
|
|
14
|
+
description:
|
|
15
|
+
type: string
|
|
16
|
+
termsOfService:
|
|
17
|
+
type: string
|
|
18
|
+
contact:
|
|
19
|
+
properties:
|
|
20
|
+
name:
|
|
21
|
+
type: string
|
|
22
|
+
url:
|
|
23
|
+
type: string
|
|
24
|
+
email:
|
|
25
|
+
type: string
|
|
26
|
+
name: Contact
|
|
27
|
+
license:
|
|
28
|
+
properties:
|
|
29
|
+
name:
|
|
30
|
+
type: string
|
|
31
|
+
url:
|
|
32
|
+
type: string
|
|
33
|
+
required:
|
|
34
|
+
- name
|
|
35
|
+
name: License
|
|
36
|
+
required:
|
|
37
|
+
- title
|
|
38
|
+
- version
|
|
39
|
+
name: Info
|
|
40
|
+
servers:
|
|
41
|
+
name: ServerList
|
|
42
|
+
properties: {}
|
|
43
|
+
items:
|
|
44
|
+
properties:
|
|
45
|
+
url:
|
|
46
|
+
type: string
|
|
47
|
+
description:
|
|
48
|
+
type: string
|
|
49
|
+
variables:
|
|
50
|
+
name: ServerVariableMap
|
|
51
|
+
properties: {}
|
|
52
|
+
required:
|
|
53
|
+
- url
|
|
54
|
+
name: Server
|
|
55
|
+
security:
|
|
56
|
+
name: SecurityRequirementList
|
|
57
|
+
properties: {}
|
|
58
|
+
items:
|
|
59
|
+
properties: {}
|
|
60
|
+
additionalProperties:
|
|
61
|
+
type: array
|
|
62
|
+
items:
|
|
63
|
+
type: string
|
|
64
|
+
name: SecurityRequirement
|
|
65
|
+
tags:
|
|
66
|
+
name: TagList
|
|
67
|
+
properties: {}
|
|
68
|
+
items:
|
|
69
|
+
properties:
|
|
70
|
+
name:
|
|
71
|
+
type: string
|
|
72
|
+
description:
|
|
73
|
+
type: string
|
|
74
|
+
externalDocs:
|
|
75
|
+
properties:
|
|
76
|
+
description:
|
|
77
|
+
type: string
|
|
78
|
+
url:
|
|
79
|
+
type: string
|
|
80
|
+
required:
|
|
81
|
+
- url
|
|
82
|
+
name: ExternalDocs
|
|
83
|
+
required:
|
|
84
|
+
- name
|
|
85
|
+
name: Tag
|
|
86
|
+
externalDocs:
|
|
87
|
+
properties:
|
|
88
|
+
description:
|
|
89
|
+
type: string
|
|
90
|
+
url:
|
|
91
|
+
type: string
|
|
92
|
+
required:
|
|
93
|
+
- url
|
|
94
|
+
name: ExternalDocs
|
|
95
|
+
paths:
|
|
96
|
+
properties: {}
|
|
97
|
+
name: PathMap
|
|
98
|
+
components:
|
|
99
|
+
properties:
|
|
100
|
+
parameters:
|
|
101
|
+
name: NamedParameters
|
|
102
|
+
properties: {}
|
|
103
|
+
schemas:
|
|
104
|
+
name: NamedSchemas
|
|
105
|
+
properties: {}
|
|
106
|
+
responses:
|
|
107
|
+
name: NamedResponses
|
|
108
|
+
properties: {}
|
|
109
|
+
examples:
|
|
110
|
+
name: NamedExamples
|
|
111
|
+
properties: {}
|
|
112
|
+
requestBodies:
|
|
113
|
+
name: NamedRequestBodies
|
|
114
|
+
properties: {}
|
|
115
|
+
headers:
|
|
116
|
+
name: NamedHeaders
|
|
117
|
+
properties: {}
|
|
118
|
+
securitySchemes:
|
|
119
|
+
name: NamedSecuritySchemes
|
|
120
|
+
properties: {}
|
|
121
|
+
links:
|
|
122
|
+
name: NamedLinks
|
|
123
|
+
properties: {}
|
|
124
|
+
callbacks:
|
|
125
|
+
name: NamedCallbacks
|
|
126
|
+
properties: {}
|
|
127
|
+
name: Components
|
|
128
|
+
x-webhooks:
|
|
129
|
+
properties: {}
|
|
130
|
+
name: WebhooksMap
|
|
131
|
+
required:
|
|
132
|
+
- openapi
|
|
133
|
+
- paths
|
|
134
|
+
- info
|
|
135
|
+
name: DefinitionRoot
|
|
136
|
+
refTypes: {}
|
|
137
|
+
visitorsData:
|
|
138
|
+
registry-dependencies:
|
|
139
|
+
links:
|
|
140
|
+
- https://api.redocly.com/registry/params
|
|
141
|
+
|
|
142
|
+
`;
|
|
143
|
+
|
|
3
144
|
exports[`bundle should bundle external refs 1`] = `
|
|
4
145
|
openapi: 3.0.0
|
|
5
146
|
paths:
|