@redocly/openapi-core 1.0.0-beta.106 → 1.0.0-beta.109
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/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +1 -1
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +9 -6
- package/lib/config/all.js +5 -3
- package/lib/config/config-resolvers.js +32 -14
- package/lib/config/config.d.ts +3 -5
- package/lib/config/config.js +7 -4
- package/lib/config/load.d.ts +7 -0
- package/lib/config/load.js +14 -6
- package/lib/config/minimal.js +7 -4
- package/lib/config/recommended.js +7 -4
- package/lib/config/rules.d.ts +1 -1
- package/lib/config/rules.js +1 -1
- package/lib/config/types.d.ts +7 -0
- package/lib/config/utils.d.ts +2 -2
- package/lib/config/utils.js +49 -11
- package/lib/decorators/common/registry-dependencies.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.d.ts +1 -1
- package/lib/format/format.js +49 -26
- package/lib/index.d.ts +5 -5
- package/lib/index.js +3 -1
- package/lib/js-yaml/index.js +1 -0
- package/lib/lint.js +2 -2
- 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 +3 -3
- package/lib/redocly/registry-api.js +7 -1
- package/lib/ref-utils.js +2 -1
- package/lib/resolve.d.ts +1 -1
- package/lib/resolve.js +4 -2
- 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/no-ambiguous-paths.js +1 -1
- package/lib/rules/common/no-identical-paths.js +1 -1
- 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-2xx-response.js +1 -1
- package/lib/rules/common/operation-4xx-response.js +1 -1
- package/lib/rules/common/operation-operationId.js +1 -1
- package/lib/rules/common/operation-tag-defined.js +1 -1
- package/lib/rules/common/path-not-include-query.js +1 -1
- package/lib/rules/common/security-defined.d.ts +2 -0
- package/lib/rules/common/{operation-security-defined.js → security-defined.js} +19 -5
- package/lib/rules/common/spec.js +14 -3
- package/lib/rules/common/tags-alphabetical.js +1 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +2 -2
- package/lib/rules/oas2/remove-unused-components.js +3 -3
- package/lib/rules/oas2/request-mime-type.js +1 -1
- package/lib/rules/oas2/response-mime-type.js +1 -1
- package/lib/rules/oas3/index.js +8 -4
- 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} +5 -5
- package/lib/rules/oas3/no-unused-components.js +2 -2
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
- package/lib/rules/oas3/remove-unused-components.js +4 -4
- package/lib/rules/oas3/request-mime-type.js +1 -1
- package/lib/rules/oas3/response-mime-type.js +1 -1
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.js +46 -0
- package/lib/rules/other/stats.d.ts +2 -2
- package/lib/rules/other/stats.js +2 -2
- package/lib/rules/utils.d.ts +3 -2
- package/lib/rules/utils.js +16 -4
- package/lib/types/oas2.js +5 -5
- package/lib/types/oas3.js +27 -20
- package/lib/types/oas3_1.js +3 -3
- package/lib/types/redocly-yaml.js +47 -56
- package/lib/utils.d.ts +6 -1
- package/lib/utils.js +24 -7
- package/lib/visitors.d.ts +12 -12
- package/lib/visitors.js +15 -3
- 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 +3 -3
- package/src/__tests__/fixtures/extension.js +3 -3
- package/src/__tests__/format.test.ts +76 -0
- package/src/__tests__/lint.test.ts +106 -131
- package/src/__tests__/logger-browser.test.ts +53 -0
- package/src/__tests__/logger.test.ts +47 -0
- package/src/__tests__/output-browser.test.ts +18 -0
- package/src/__tests__/output.test.ts +15 -0
- package/src/__tests__/resolve-http.test.ts +1 -1
- package/src/__tests__/resolve.test.ts +9 -9
- package/src/__tests__/utils-browser.test.ts +11 -0
- package/src/__tests__/utils.test.ts +7 -0
- package/src/__tests__/walk.test.ts +78 -10
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +0 -1
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
- package/src/bundle.ts +10 -7
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +12 -6
- package/src/config/__tests__/config.test.ts +35 -0
- package/src/config/__tests__/fixtures/plugin-config.yaml +2 -3
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +11 -12
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +7 -8
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +18 -19
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +9 -10
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +3 -4
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +4 -5
- package/src/config/__tests__/load.test.ts +76 -1
- package/src/config/__tests__/utils.test.ts +64 -4
- package/src/config/all.ts +5 -3
- package/src/config/config-resolvers.ts +45 -19
- package/src/config/config.ts +10 -8
- package/src/config/load.ts +31 -7
- package/src/config/minimal.ts +7 -4
- package/src/config/recommended.ts +7 -4
- package/src/config/rules.ts +2 -2
- package/src/config/types.ts +11 -0
- package/src/config/utils.ts +115 -25
- package/src/decorators/common/registry-dependencies.ts +2 -2
- package/src/env.ts +5 -0
- package/src/format/codeframes.ts +15 -9
- package/src/format/format.ts +59 -34
- package/src/index.ts +6 -4
- package/src/js-yaml/index.ts +1 -0
- package/src/lint.ts +2 -2
- package/src/logger.ts +34 -0
- package/src/output.ts +7 -0
- package/src/redocly/index.ts +7 -4
- package/src/redocly/registry-api-types.ts +27 -29
- package/src/redocly/registry-api.ts +18 -7
- package/src/ref-utils.ts +2 -1
- package/src/resolve.ts +7 -5
- package/src/rules/__tests__/utils.test.ts +39 -1
- package/src/rules/ajv.ts +7 -7
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -0
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -1
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +26 -3
- package/src/rules/common/__tests__/security-defined.test.ts +175 -0
- package/src/rules/common/__tests__/spec.test.ts +79 -0
- package/src/rules/common/assertions/__tests__/utils.test.ts +2 -2
- package/src/rules/common/assertions/asserts.ts +4 -4
- package/src/rules/common/assertions/index.ts +1 -1
- package/src/rules/common/no-ambiguous-paths.ts +1 -1
- package/src/rules/common/no-identical-paths.ts +1 -1
- 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-2xx-response.ts +1 -1
- package/src/rules/common/operation-4xx-response.ts +1 -1
- package/src/rules/common/operation-operationId.ts +1 -1
- package/src/rules/common/operation-tag-defined.ts +1 -1
- package/src/rules/common/path-not-include-query.ts +1 -1
- package/src/rules/common/{operation-security-defined.ts → security-defined.ts} +20 -5
- package/src/rules/common/spec.ts +17 -3
- package/src/rules/common/tags-alphabetical.ts +1 -1
- package/src/rules/oas2/index.ts +2 -2
- package/src/rules/oas2/remove-unused-components.ts +3 -3
- package/src/rules/oas2/request-mime-type.ts +1 -1
- package/src/rules/oas2/response-mime-type.ts +1 -1
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +16 -16
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +5 -5
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +145 -0
- package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -0
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +217 -0
- package/src/rules/oas3/index.ts +8 -4
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +3 -3
- package/src/rules/oas3/{no-servers-empty-enum.ts → no-server-variables-empty-enum.ts} +3 -3
- package/src/rules/oas3/no-unused-components.ts +2 -2
- package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +36 -0
- package/src/rules/oas3/remove-unused-components.ts +5 -5
- package/src/rules/oas3/request-mime-type.ts +1 -1
- package/src/rules/oas3/response-mime-type.ts +1 -1
- package/src/rules/oas3/spec-components-invalid-map-name.ts +53 -0
- package/src/rules/other/stats.ts +2 -2
- package/src/rules/utils.ts +17 -3
- package/src/types/index.ts +2 -2
- package/src/types/oas2.ts +5 -5
- package/src/types/oas3.ts +27 -20
- package/src/types/oas3_1.ts +3 -3
- package/src/types/redocly-yaml.ts +53 -41
- package/src/utils.ts +31 -4
- package/src/visitors.ts +34 -18
- package/src/walk.ts +15 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/common/operation-security-defined.d.ts +0 -2
- package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
- package/src/rules/common/__tests__/operation-security-defined.test.ts +0 -69
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RemoveUnusedComponents = void 0;
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const RemoveUnusedComponents = () => {
|
|
6
|
-
|
|
6
|
+
const components = new Map();
|
|
7
7
|
function registerComponent(location, componentType, name) {
|
|
8
8
|
var _a;
|
|
9
9
|
components.set(location.absolutePointer, {
|
|
@@ -26,14 +26,14 @@ const RemoveUnusedComponents = () => {
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
Root: {
|
|
30
30
|
leave(root, ctx) {
|
|
31
31
|
const data = ctx.getVisitorData();
|
|
32
32
|
data.removedCount = 0;
|
|
33
33
|
components.forEach((usageInfo) => {
|
|
34
34
|
const { used, componentType, name } = usageInfo;
|
|
35
|
-
if (!used && componentType) {
|
|
36
|
-
|
|
35
|
+
if (!used && componentType && root.components) {
|
|
36
|
+
const componentChild = root.components[componentType];
|
|
37
37
|
delete componentChild[name];
|
|
38
38
|
data.removedCount++;
|
|
39
39
|
if (utils_1.isEmptyObject(componentChild)) {
|
|
@@ -4,7 +4,7 @@ exports.RequestMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const RequestMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
PathsMap: {
|
|
8
8
|
RequestBody: {
|
|
9
9
|
leave(requestBody, ctx) {
|
|
10
10
|
utils_1.validateMimeTypeOAS3({ type: 'consumes', value: requestBody }, ctx, allowedValues);
|
|
@@ -4,7 +4,7 @@ exports.ResponseMimeType = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const ResponseMimeType = ({ allowedValues }) => {
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
PathsMap: {
|
|
8
8
|
Response: {
|
|
9
9
|
leave(response, ctx) {
|
|
10
10
|
utils_1.validateMimeTypeOAS3({ type: 'produces', value: response }, ctx, allowedValues);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpecComponentsInvalidMapName = void 0;
|
|
4
|
+
const SpecComponentsInvalidMapName = () => {
|
|
5
|
+
const KEYS_REGEX = '^[a-zA-Z0-9\\.\\-_]+$';
|
|
6
|
+
function validateKey(key, report, location, component) {
|
|
7
|
+
if (!new RegExp(KEYS_REGEX).test(key)) {
|
|
8
|
+
report({
|
|
9
|
+
message: `The map key in ${component} "${key}" does not match the regular expression "${KEYS_REGEX}"`,
|
|
10
|
+
location: location.key(),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
Components: {
|
|
16
|
+
Parameter(_node, { key, report, location }) {
|
|
17
|
+
validateKey(key, report, location, 'parameters');
|
|
18
|
+
},
|
|
19
|
+
Response(_node, { key, report, location }) {
|
|
20
|
+
validateKey(key, report, location, 'responses');
|
|
21
|
+
},
|
|
22
|
+
Schema(_node, { key, report, location }) {
|
|
23
|
+
validateKey(key, report, location, 'schemas');
|
|
24
|
+
},
|
|
25
|
+
Example(_node, { key, report, location }) {
|
|
26
|
+
validateKey(key, report, location, 'examples');
|
|
27
|
+
},
|
|
28
|
+
RequestBody(_node, { key, report, location }) {
|
|
29
|
+
validateKey(key, report, location, 'requestBodies');
|
|
30
|
+
},
|
|
31
|
+
Header(_node, { key, report, location }) {
|
|
32
|
+
validateKey(key, report, location, 'headers');
|
|
33
|
+
},
|
|
34
|
+
SecurityScheme(_node, { key, report, location }) {
|
|
35
|
+
validateKey(key, report, location, 'securitySchemas');
|
|
36
|
+
},
|
|
37
|
+
Link(_node, { key, report, location }) {
|
|
38
|
+
validateKey(key, report, location, 'links');
|
|
39
|
+
},
|
|
40
|
+
Callback(_node, { key, report, location }) {
|
|
41
|
+
validateKey(key, report, location, 'callbacks');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.SpecComponentsInvalidMapName = SpecComponentsInvalidMapName;
|
|
@@ -14,7 +14,7 @@ export declare const Stats: (statsAccumulator: StatsAccumulator) => {
|
|
|
14
14
|
Link: {
|
|
15
15
|
leave(link: any): void;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
Root: {
|
|
18
18
|
leave(): void;
|
|
19
19
|
};
|
|
20
20
|
WebhooksMap: {
|
|
@@ -22,7 +22,7 @@ export declare const Stats: (statsAccumulator: StatsAccumulator) => {
|
|
|
22
22
|
leave(operation: any): void;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
PathsMap: {
|
|
26
26
|
PathItem: {
|
|
27
27
|
leave(): void;
|
|
28
28
|
Operation: {
|
package/lib/rules/other/stats.js
CHANGED
|
@@ -23,7 +23,7 @@ const Stats = (statsAccumulator) => {
|
|
|
23
23
|
statsAccumulator.links.items.add(link.operationId);
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
Root: {
|
|
27
27
|
leave() {
|
|
28
28
|
statsAccumulator.parameters.total = statsAccumulator.parameters.items.size;
|
|
29
29
|
statsAccumulator.refs.total = statsAccumulator.refs.items.size;
|
|
@@ -40,7 +40,7 @@ const Stats = (statsAccumulator) => {
|
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
|
|
43
|
+
PathsMap: {
|
|
44
44
|
PathItem: {
|
|
45
45
|
leave() {
|
|
46
46
|
statsAccumulator.pathItems.total++;
|
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" | "
|
|
4
|
+
export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "integer" | "array";
|
|
5
5
|
/**
|
|
6
6
|
* Checks if value matches specified JSON schema type
|
|
7
7
|
*
|
|
@@ -14,4 +14,5 @@ export declare function missingRequiredField(type: string, field: string): strin
|
|
|
14
14
|
export declare function fieldNonEmpty(type: string, field: string): string;
|
|
15
15
|
export declare function validateDefinedAndNonEmpty(fieldName: string, value: any, ctx: UserContext): void;
|
|
16
16
|
export declare function getSuggest(given: string, variants: string[]): string[];
|
|
17
|
-
export declare function validateExample(example: any, schema: Referenced<Oas3Schema>, dataLoc: Location, { resolve, location, report }: UserContext,
|
|
17
|
+
export declare function validateExample(example: any, schema: Referenced<Oas3Schema>, dataLoc: Location, { resolve, location, report }: UserContext, allowAdditionalProperties: boolean): void;
|
|
18
|
+
export declare function getAdditionalPropertiesOption(opts: Record<string, any>): boolean;
|
package/lib/rules/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateExample = exports.getSuggest = exports.validateDefinedAndNonEmpty = exports.fieldNonEmpty = exports.missingRequiredField = exports.matchesJsonSchemaType = exports.oasTypeOf = void 0;
|
|
3
|
+
exports.getAdditionalPropertiesOption = exports.validateExample = exports.getSuggest = exports.validateDefinedAndNonEmpty = exports.fieldNonEmpty = exports.missingRequiredField = exports.matchesJsonSchemaType = exports.oasTypeOf = void 0;
|
|
4
4
|
const levenshtein = require("js-levenshtein");
|
|
5
5
|
const ref_utils_1 = require("../ref-utils");
|
|
6
6
|
const ajv_1 = require("./ajv");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
7
8
|
function oasTypeOf(value) {
|
|
8
9
|
if (Array.isArray(value)) {
|
|
9
10
|
return 'array';
|
|
@@ -85,11 +86,11 @@ function getSuggest(given, variants) {
|
|
|
85
86
|
return distances.map((d) => d.variant);
|
|
86
87
|
}
|
|
87
88
|
exports.getSuggest = getSuggest;
|
|
88
|
-
function validateExample(example, schema, dataLoc, { resolve, location, report },
|
|
89
|
+
function validateExample(example, schema, dataLoc, { resolve, location, report }, allowAdditionalProperties) {
|
|
89
90
|
try {
|
|
90
|
-
const { valid, errors } = ajv_1.validateJsonSchema(example, schema, location.child('schema'), dataLoc.pointer, resolve,
|
|
91
|
+
const { valid, errors } = ajv_1.validateJsonSchema(example, schema, location.child('schema'), dataLoc.pointer, resolve, allowAdditionalProperties);
|
|
91
92
|
if (!valid) {
|
|
92
|
-
for (
|
|
93
|
+
for (const error of errors) {
|
|
93
94
|
report({
|
|
94
95
|
message: `Example value must conform to the schema: ${error.message}.`,
|
|
95
96
|
location: Object.assign(Object.assign({}, new ref_utils_1.Location(dataLoc.source, error.instancePath)), { reportOnKey: error.keyword === 'additionalProperties' }),
|
|
@@ -108,3 +109,14 @@ function validateExample(example, schema, dataLoc, { resolve, location, report }
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
exports.validateExample = validateExample;
|
|
112
|
+
function getAdditionalPropertiesOption(opts) {
|
|
113
|
+
if (opts.disallowAdditionalProperties === undefined) {
|
|
114
|
+
return opts.allowAdditionalProperties;
|
|
115
|
+
}
|
|
116
|
+
if (opts.allowAdditionalProperties !== undefined) {
|
|
117
|
+
utils_1.showErrorForDeprecatedField('disallowAdditionalProperties', 'allowAdditionalProperties');
|
|
118
|
+
}
|
|
119
|
+
utils_1.showWarningForDeprecatedField('disallowAdditionalProperties', 'allowAdditionalProperties');
|
|
120
|
+
return !opts.disallowAdditionalProperties;
|
|
121
|
+
}
|
|
122
|
+
exports.getAdditionalPropertiesOption = getAdditionalPropertiesOption;
|
package/lib/types/oas2.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Oas2Types = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
|
|
6
|
-
const
|
|
6
|
+
const Root = {
|
|
7
7
|
properties: {
|
|
8
8
|
swagger: { type: 'string' },
|
|
9
9
|
info: 'Info',
|
|
@@ -12,7 +12,7 @@ const DefinitionRoot = {
|
|
|
12
12
|
schemes: { type: 'array', items: { type: 'string' } },
|
|
13
13
|
consumes: { type: 'array', items: { type: 'string' } },
|
|
14
14
|
produces: { type: 'array', items: { type: 'string' } },
|
|
15
|
-
paths: '
|
|
15
|
+
paths: 'PathsMap',
|
|
16
16
|
definitions: 'NamedSchemas',
|
|
17
17
|
parameters: 'NamedParameters',
|
|
18
18
|
responses: 'NamedResponses',
|
|
@@ -48,7 +48,7 @@ const License = {
|
|
|
48
48
|
},
|
|
49
49
|
required: ['name'],
|
|
50
50
|
};
|
|
51
|
-
const
|
|
51
|
+
const PathsMap = {
|
|
52
52
|
properties: {},
|
|
53
53
|
additionalProperties: (_value, key) => key.startsWith('/') ? 'PathItem' : undefined,
|
|
54
54
|
};
|
|
@@ -352,14 +352,14 @@ const SecurityRequirement = {
|
|
|
352
352
|
additionalProperties: { type: 'array', items: { type: 'string' } },
|
|
353
353
|
};
|
|
354
354
|
exports.Oas2Types = {
|
|
355
|
-
|
|
355
|
+
Root,
|
|
356
356
|
Tag,
|
|
357
357
|
ExternalDocs,
|
|
358
358
|
SecurityRequirement,
|
|
359
359
|
Info,
|
|
360
360
|
Contact,
|
|
361
361
|
License,
|
|
362
|
-
|
|
362
|
+
PathsMap,
|
|
363
363
|
PathItem,
|
|
364
364
|
Parameter,
|
|
365
365
|
ParameterItems,
|
package/lib/types/oas3.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Oas3Types = void 0;
|
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const ref_utils_1 = require("../ref-utils");
|
|
6
6
|
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
|
|
7
|
-
const
|
|
7
|
+
const Root = {
|
|
8
8
|
properties: {
|
|
9
9
|
openapi: null,
|
|
10
10
|
info: 'Info',
|
|
@@ -12,7 +12,7 @@ const DefinitionRoot = {
|
|
|
12
12
|
security: _1.listOf('SecurityRequirement'),
|
|
13
13
|
tags: _1.listOf('Tag'),
|
|
14
14
|
externalDocs: 'ExternalDocs',
|
|
15
|
-
paths: '
|
|
15
|
+
paths: 'PathsMap',
|
|
16
16
|
components: 'Components',
|
|
17
17
|
'x-webhooks': 'WebhooksMap',
|
|
18
18
|
},
|
|
@@ -37,7 +37,7 @@ const Server = {
|
|
|
37
37
|
properties: {
|
|
38
38
|
url: { type: 'string' },
|
|
39
39
|
description: { type: 'string' },
|
|
40
|
-
variables:
|
|
40
|
+
variables: 'ServerVariablesMap',
|
|
41
41
|
},
|
|
42
42
|
required: ['url'],
|
|
43
43
|
};
|
|
@@ -81,7 +81,7 @@ const License = {
|
|
|
81
81
|
},
|
|
82
82
|
required: ['name'],
|
|
83
83
|
};
|
|
84
|
-
const
|
|
84
|
+
const PathsMap = {
|
|
85
85
|
properties: {},
|
|
86
86
|
additionalProperties: (_value, key) => key.startsWith('/') ? 'PathItem' : undefined,
|
|
87
87
|
};
|
|
@@ -121,8 +121,8 @@ const Parameter = {
|
|
|
121
121
|
allowReserved: { type: 'boolean' },
|
|
122
122
|
schema: 'Schema',
|
|
123
123
|
example: { isExample: true },
|
|
124
|
-
examples:
|
|
125
|
-
content: '
|
|
124
|
+
examples: 'ExamplesMap',
|
|
125
|
+
content: 'MediaTypesMap',
|
|
126
126
|
},
|
|
127
127
|
required: ['name', 'in'],
|
|
128
128
|
requiredOneOf: ['schema', 'content'],
|
|
@@ -143,7 +143,7 @@ const Operation = {
|
|
|
143
143
|
requestBody: 'RequestBody',
|
|
144
144
|
responses: 'ResponsesMap',
|
|
145
145
|
deprecated: { type: 'boolean' },
|
|
146
|
-
callbacks:
|
|
146
|
+
callbacks: 'CallbacksMap',
|
|
147
147
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
148
148
|
'x-code-samples': _1.listOf('XCodeSample'),
|
|
149
149
|
'x-hideTryItPanel': { type: 'boolean' },
|
|
@@ -161,11 +161,11 @@ const RequestBody = {
|
|
|
161
161
|
properties: {
|
|
162
162
|
description: { type: 'string' },
|
|
163
163
|
required: { type: 'boolean' },
|
|
164
|
-
content: '
|
|
164
|
+
content: 'MediaTypesMap',
|
|
165
165
|
},
|
|
166
166
|
required: ['content'],
|
|
167
167
|
};
|
|
168
|
-
const
|
|
168
|
+
const MediaTypesMap = {
|
|
169
169
|
properties: {},
|
|
170
170
|
additionalProperties: 'MediaType',
|
|
171
171
|
};
|
|
@@ -173,8 +173,8 @@ const MediaType = {
|
|
|
173
173
|
properties: {
|
|
174
174
|
schema: 'Schema',
|
|
175
175
|
example: { isExample: true },
|
|
176
|
-
examples:
|
|
177
|
-
encoding:
|
|
176
|
+
examples: 'ExamplesMap',
|
|
177
|
+
encoding: 'EncodingsMap',
|
|
178
178
|
},
|
|
179
179
|
};
|
|
180
180
|
const Example = {
|
|
@@ -188,7 +188,7 @@ const Example = {
|
|
|
188
188
|
const Encoding = {
|
|
189
189
|
properties: {
|
|
190
190
|
contentType: { type: 'string' },
|
|
191
|
-
headers:
|
|
191
|
+
headers: 'HeadersMap',
|
|
192
192
|
style: {
|
|
193
193
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
194
194
|
},
|
|
@@ -209,9 +209,10 @@ const Header = {
|
|
|
209
209
|
allowReserved: { type: 'boolean' },
|
|
210
210
|
schema: 'Schema',
|
|
211
211
|
example: { isExample: true },
|
|
212
|
-
examples:
|
|
213
|
-
content: '
|
|
212
|
+
examples: 'ExamplesMap',
|
|
213
|
+
content: 'MediaTypesMap',
|
|
214
214
|
},
|
|
215
|
+
requiredOneOf: ['schema', 'content'],
|
|
215
216
|
};
|
|
216
217
|
const ResponsesMap = {
|
|
217
218
|
properties: { default: 'Response' },
|
|
@@ -220,9 +221,9 @@ const ResponsesMap = {
|
|
|
220
221
|
const Response = {
|
|
221
222
|
properties: {
|
|
222
223
|
description: { type: 'string' },
|
|
223
|
-
headers:
|
|
224
|
-
content: '
|
|
225
|
-
links:
|
|
224
|
+
headers: 'HeadersMap',
|
|
225
|
+
content: 'MediaTypesMap',
|
|
226
|
+
links: 'LinksMap',
|
|
226
227
|
},
|
|
227
228
|
required: ['description'],
|
|
228
229
|
};
|
|
@@ -427,26 +428,31 @@ const SecurityScheme = {
|
|
|
427
428
|
extensionsPrefix: 'x-',
|
|
428
429
|
};
|
|
429
430
|
exports.Oas3Types = {
|
|
430
|
-
|
|
431
|
+
Root,
|
|
431
432
|
Tag,
|
|
432
433
|
ExternalDocs,
|
|
433
434
|
Server,
|
|
434
435
|
ServerVariable,
|
|
436
|
+
ServerVariablesMap: _1.mapOf('ServerVariable'),
|
|
435
437
|
SecurityRequirement,
|
|
436
438
|
Info,
|
|
437
439
|
Contact,
|
|
438
440
|
License,
|
|
439
|
-
|
|
441
|
+
PathsMap,
|
|
440
442
|
PathItem,
|
|
441
443
|
Parameter,
|
|
442
444
|
Operation,
|
|
443
445
|
Callback: _1.mapOf('PathItem'),
|
|
446
|
+
CallbacksMap: _1.mapOf('Callback'),
|
|
444
447
|
RequestBody,
|
|
445
|
-
|
|
448
|
+
MediaTypesMap,
|
|
446
449
|
MediaType,
|
|
447
450
|
Example,
|
|
451
|
+
ExamplesMap: _1.mapOf('Example'),
|
|
448
452
|
Encoding,
|
|
453
|
+
EncodingsMap: _1.mapOf('Encoding'),
|
|
449
454
|
Header,
|
|
455
|
+
HeadersMap: _1.mapOf('Header'),
|
|
450
456
|
ResponsesMap,
|
|
451
457
|
Response,
|
|
452
458
|
Link,
|
|
@@ -456,6 +462,7 @@ exports.Oas3Types = {
|
|
|
456
462
|
DiscriminatorMapping,
|
|
457
463
|
Discriminator,
|
|
458
464
|
Components,
|
|
465
|
+
LinksMap: _1.mapOf('Link'),
|
|
459
466
|
NamedSchemas: _1.mapOf('Schema'),
|
|
460
467
|
NamedResponses: _1.mapOf('Response'),
|
|
461
468
|
NamedParameters: _1.mapOf('Parameter'),
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Oas3_1Types = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const oas3_1 = require("./oas3");
|
|
6
|
-
const
|
|
6
|
+
const Root = {
|
|
7
7
|
properties: {
|
|
8
8
|
openapi: null,
|
|
9
9
|
info: 'Info',
|
|
@@ -11,7 +11,7 @@ const DefinitionRoot = {
|
|
|
11
11
|
security: _1.listOf('SecurityRequirement'),
|
|
12
12
|
tags: _1.listOf('Tag'),
|
|
13
13
|
externalDocs: 'ExternalDocs',
|
|
14
|
-
paths: '
|
|
14
|
+
paths: 'PathsMap',
|
|
15
15
|
webhooks: 'WebhooksMap',
|
|
16
16
|
components: 'Components',
|
|
17
17
|
jsonSchemaDialect: { type: 'string' },
|
|
@@ -237,7 +237,7 @@ const SecurityScheme = {
|
|
|
237
237
|
extensionsPrefix: 'x-',
|
|
238
238
|
};
|
|
239
239
|
exports.Oas3_1Types = Object.assign(Object.assign({}, oas3_1.Oas3Types), { Info,
|
|
240
|
-
|
|
240
|
+
Root,
|
|
241
241
|
Schema,
|
|
242
242
|
License,
|
|
243
243
|
Components, NamedPathItems: _1.mapOf('PathItem'), SecurityScheme,
|
|
@@ -11,6 +11,7 @@ const builtInRulesList = [
|
|
|
11
11
|
'info-license-url',
|
|
12
12
|
'operation-2xx-response',
|
|
13
13
|
'operation-4xx-response',
|
|
14
|
+
'operation-4xx-problem-details-rfc7807',
|
|
14
15
|
'assertions',
|
|
15
16
|
'operation-operationId-unique',
|
|
16
17
|
'operation-parameters-unique',
|
|
@@ -34,7 +35,7 @@ const builtInRulesList = [
|
|
|
34
35
|
'path-params-defined',
|
|
35
36
|
'parameter-description',
|
|
36
37
|
'operation-singular-tag',
|
|
37
|
-
'
|
|
38
|
+
'security-defined',
|
|
38
39
|
'no-unresolved-refs',
|
|
39
40
|
'paths-kebab-case',
|
|
40
41
|
'boolean-parameter-prefixes',
|
|
@@ -43,7 +44,7 @@ const builtInRulesList = [
|
|
|
43
44
|
'no-identical-paths',
|
|
44
45
|
'no-ambiguous-paths',
|
|
45
46
|
'no-undefined-server-variable',
|
|
46
|
-
'no-
|
|
47
|
+
'no-server-variables-empty-enum',
|
|
47
48
|
'no-http-verbs-in-paths',
|
|
48
49
|
'path-excludes-patterns',
|
|
49
50
|
'request-mime-type',
|
|
@@ -54,31 +55,38 @@ const builtInRulesList = [
|
|
|
54
55
|
'response-contains-header',
|
|
55
56
|
'response-contains-property',
|
|
56
57
|
'scalar-property-missing-example',
|
|
58
|
+
'spec-components-invalid-map-name',
|
|
57
59
|
];
|
|
58
60
|
const nodeTypesList = [
|
|
59
|
-
'
|
|
61
|
+
'Root',
|
|
60
62
|
'Tag',
|
|
61
63
|
'ExternalDocs',
|
|
62
64
|
'Server',
|
|
63
65
|
'ServerVariable',
|
|
66
|
+
'ServerVariablesMap',
|
|
64
67
|
'SecurityRequirement',
|
|
65
68
|
'Info',
|
|
66
69
|
'Contact',
|
|
67
70
|
'License',
|
|
68
|
-
'
|
|
71
|
+
'PathsMap',
|
|
69
72
|
'PathItem',
|
|
70
73
|
'Parameter',
|
|
71
74
|
'Operation',
|
|
72
75
|
'Callback',
|
|
76
|
+
'CallbacksMap',
|
|
73
77
|
'RequestBody',
|
|
74
|
-
'
|
|
78
|
+
'MediaTypesMap',
|
|
75
79
|
'MediaType',
|
|
76
80
|
'Example',
|
|
81
|
+
'ExamplesMap',
|
|
77
82
|
'Encoding',
|
|
83
|
+
'EncodingsMap',
|
|
78
84
|
'Header',
|
|
85
|
+
'HeadersMap',
|
|
79
86
|
'ResponsesMap',
|
|
80
87
|
'Response',
|
|
81
88
|
'Link',
|
|
89
|
+
'LinksMap',
|
|
82
90
|
'Schema',
|
|
83
91
|
'Xml',
|
|
84
92
|
'SchemaProperties',
|
|
@@ -103,45 +111,57 @@ const nodeTypesList = [
|
|
|
103
111
|
'XCodeSample',
|
|
104
112
|
'WebhooksMap',
|
|
105
113
|
];
|
|
106
|
-
const
|
|
114
|
+
const ConfigStyleguide = {
|
|
107
115
|
properties: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
116
|
+
extends: {
|
|
117
|
+
type: 'array',
|
|
118
|
+
items: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
rules: 'Rules',
|
|
123
|
+
oas2Rules: 'Rules',
|
|
124
|
+
oas3_0Rules: 'Rules',
|
|
125
|
+
oas3_1Rules: 'Rules',
|
|
126
|
+
preprocessors: { type: 'object' },
|
|
127
|
+
oas2Preprocessors: { type: 'object' },
|
|
128
|
+
oas3_0Preprocessors: { type: 'object' },
|
|
129
|
+
oas3_1Preprocessors: { type: 'object' },
|
|
130
|
+
decorators: { type: 'object' },
|
|
131
|
+
oas2Decorators: { type: 'object' },
|
|
132
|
+
oas3_0Decorators: { type: 'object' },
|
|
133
|
+
oas3_1Decorators: { type: 'object' },
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
const RootConfigStyleguide = {
|
|
137
|
+
properties: Object.assign({ plugins: {
|
|
138
|
+
type: 'array',
|
|
139
|
+
items: { type: 'string' },
|
|
140
|
+
} }, ConfigStyleguide.properties),
|
|
141
|
+
};
|
|
142
|
+
const ConfigRoot = {
|
|
143
|
+
properties: Object.assign(Object.assign({ organization: { type: 'string' }, apis: 'ConfigApis', apiDefinitions: {
|
|
111
144
|
type: 'object',
|
|
112
145
|
properties: {},
|
|
113
146
|
additionalProperties: { properties: { type: 'string' } },
|
|
114
|
-
},
|
|
115
|
-
styleguide: 'RootConfigStyleguide',
|
|
116
|
-
lint: 'RootConfigStyleguide',
|
|
117
|
-
'features.openapi': 'ConfigReferenceDocs',
|
|
118
|
-
referenceDocs: 'ConfigReferenceDocs',
|
|
119
|
-
'features.mockServer': 'ConfigMockServer',
|
|
120
|
-
region: { enum: ['us', 'eu'] },
|
|
121
|
-
resolve: {
|
|
147
|
+
} }, RootConfigStyleguide.properties), { styleguide: 'RootConfigStyleguide', lint: 'RootConfigStyleguide', 'features.openapi': 'ConfigReferenceDocs', referenceDocs: 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer', region: { enum: ['us', 'eu'] }, resolve: {
|
|
122
148
|
properties: {
|
|
123
149
|
http: 'ConfigHTTP',
|
|
150
|
+
doNotResolveExamples: { type: 'boolean' },
|
|
124
151
|
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
152
|
+
} }),
|
|
127
153
|
};
|
|
128
154
|
const ConfigApis = {
|
|
129
155
|
properties: {},
|
|
130
156
|
additionalProperties: 'ConfigApisProperties',
|
|
131
157
|
};
|
|
132
158
|
const ConfigApisProperties = {
|
|
133
|
-
properties: {
|
|
134
|
-
root: { type: 'string' },
|
|
135
|
-
labels: {
|
|
159
|
+
properties: Object.assign(Object.assign({ root: { type: 'string' }, labels: {
|
|
136
160
|
type: 'array',
|
|
137
161
|
items: {
|
|
138
162
|
type: 'string',
|
|
139
163
|
},
|
|
140
|
-
},
|
|
141
|
-
styleguide: 'ConfigStyleguide',
|
|
142
|
-
'features.openapi': 'ConfigReferenceDocs',
|
|
143
|
-
'features.mockServer': 'ConfigMockServer',
|
|
144
|
-
},
|
|
164
|
+
}, lint: 'ConfigStyleguide', styleguide: 'ConfigStyleguide' }, ConfigStyleguide.properties), { 'features.openapi': 'ConfigReferenceDocs', 'features.mockServer': 'ConfigMockServer' }),
|
|
145
165
|
required: ['root'],
|
|
146
166
|
};
|
|
147
167
|
const ConfigHTTP = {
|
|
@@ -154,35 +174,6 @@ const ConfigHTTP = {
|
|
|
154
174
|
},
|
|
155
175
|
},
|
|
156
176
|
};
|
|
157
|
-
const ConfigStyleguide = {
|
|
158
|
-
properties: {
|
|
159
|
-
extends: {
|
|
160
|
-
type: 'array',
|
|
161
|
-
items: {
|
|
162
|
-
type: 'string',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
doNotResolveExamples: { type: 'boolean' },
|
|
166
|
-
rules: 'Rules',
|
|
167
|
-
oas2Rules: 'Rules',
|
|
168
|
-
oas3_0Rules: 'Rules',
|
|
169
|
-
oas3_1Rules: 'Rules',
|
|
170
|
-
preprocessors: { type: 'object' },
|
|
171
|
-
oas2Preprocessors: { type: 'object' },
|
|
172
|
-
oas3_0Preprocessors: { type: 'object' },
|
|
173
|
-
oas3_1Preprocessors: { type: 'object' },
|
|
174
|
-
decorators: { type: 'object' },
|
|
175
|
-
oas2Decorators: { type: 'object' },
|
|
176
|
-
oas3_0Decorators: { type: 'object' },
|
|
177
|
-
oas3_1Decorators: { type: 'object' },
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
const RootConfigStyleguide = {
|
|
181
|
-
properties: Object.assign({ plugins: {
|
|
182
|
-
type: 'array',
|
|
183
|
-
items: { type: 'string' },
|
|
184
|
-
} }, ConfigStyleguide.properties),
|
|
185
|
-
};
|
|
186
177
|
const Rules = {
|
|
187
178
|
properties: {},
|
|
188
179
|
additionalProperties: (value, key) => {
|
package/lib/utils.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function pushStack<T, P extends Stack<T> = Stack<T>>(head: P, val
|
|
|
14
14
|
export declare function popStack<T, P extends Stack<T>>(head: P): StackFrame<T> | null;
|
|
15
15
|
export declare type BundleOutputFormat = 'json' | 'yml' | 'yaml';
|
|
16
16
|
export declare function loadYaml<T>(filename: string): Promise<T>;
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function isDefined<T>(x: T | undefined): x is T;
|
|
18
18
|
export declare function isPlainObject(value: any): value is object;
|
|
19
19
|
export declare function isEmptyObject(value: any): value is object;
|
|
20
20
|
export declare function isEmptyArray(value: any): boolean;
|
|
@@ -41,3 +41,8 @@ export declare function assignExisting<T>(target: Record<string, T>, obj: Record
|
|
|
41
41
|
export declare function getMatchingStatusCodeRange(code: number | string): string;
|
|
42
42
|
export declare function isCustomRuleId(id: string): boolean;
|
|
43
43
|
export declare function doesYamlFileExist(filePath: string): boolean;
|
|
44
|
+
export declare function showWarningForDeprecatedField(deprecatedField: string, updatedField?: string): void;
|
|
45
|
+
export declare function showErrorForDeprecatedField(deprecatedField: string, updatedField?: string): void;
|
|
46
|
+
export declare type Falsy = undefined | null | false | '' | 0;
|
|
47
|
+
export declare function isTruthy<Truthy>(value: Truthy | Falsy): value is Truthy;
|
|
48
|
+
export declare function identity<T>(value: T): T;
|