@redocly/openapi-core 1.0.0-beta.79 → 1.0.0-beta.83
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/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/js-yaml/index.js +1 -1
- package/lib/rules/common/operation-security-defined.js +1 -4
- package/lib/rules/common/spec.js +18 -3
- 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/lib/rules/oas3/no-invalid-media-type-examples.js +12 -11
- package/lib/types/index.d.ts +4 -0
- package/lib/types/oas2.js +42 -35
- package/lib/types/oas3.js +68 -139
- package/lib/types/oas3_1.js +52 -49
- package/lib/typings/openapi.d.ts +7 -0
- package/lib/utils.js +1 -1
- 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/index.ts +5 -1
- package/src/js-yaml/index.ts +1 -2
- package/src/redocly/registry-api.ts +4 -1
- 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/common/operation-security-defined.ts +4 -5
- package/src/rules/common/spec.ts +18 -0
- 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/src/rules/oas3/no-invalid-media-type-examples.ts +17 -21
- package/src/types/index.ts +4 -0
- package/src/types/oas2.ts +42 -40
- package/src/types/oas3.ts +68 -141
- package/src/types/oas3_1.ts +51 -50
- package/src/typings/openapi.ts +9 -0
- package/src/utils.ts +1 -1
- 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/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { Oas3_1Types } from './types/oas3_1';
|
|
|
3
3
|
export { Oas3Types } from './types/oas3';
|
|
4
4
|
export { Oas2Types } from './types/oas2';
|
|
5
5
|
export { ConfigTypes } from './types/redocly-yaml';
|
|
6
|
-
export { Oas3Definition, Oas3Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3Schema, Oas3Tag, } from './typings/openapi';
|
|
6
|
+
export { Oas3Definition, Oas3_1Definition, Oas3Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3Schema, Oas3_1Schema, Oas3Tag, Oas3_1Webhooks, Referenced } from './typings/openapi';
|
|
7
7
|
export { Oas2Definition } from './typings/swagger';
|
|
8
8
|
export { StatsAccumulator, StatsName } from './typings/common';
|
|
9
9
|
export { normalizeTypes } from './types';
|
|
@@ -13,7 +13,7 @@ export { loadConfig } from './config/load';
|
|
|
13
13
|
export { RedoclyClient } from './redocly';
|
|
14
14
|
export { Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve';
|
|
15
15
|
export { parseYaml, stringifyYaml } from './js-yaml';
|
|
16
|
-
export { unescapePointer } from './ref-utils';
|
|
16
|
+
export { unescapePointer, isRef } from './ref-utils';
|
|
17
17
|
export { detectOpenAPI, OasMajorVersion, openAPIMajor, OasVersion } from './oas-types';
|
|
18
18
|
export { normalizeVisitors } from './visitors';
|
|
19
19
|
export { WalkContext, walkDocument, NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject, Loc, } from './walk';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.loadConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.slash = exports.readFileFromUrl = void 0;
|
|
3
|
+
exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.loadConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.slash = exports.readFileFromUrl = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
|
|
6
6
|
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "parseYaml", { enumerable: true, get: function ()
|
|
|
36
36
|
Object.defineProperty(exports, "stringifyYaml", { enumerable: true, get: function () { return js_yaml_1.stringifyYaml; } });
|
|
37
37
|
var ref_utils_1 = require("./ref-utils");
|
|
38
38
|
Object.defineProperty(exports, "unescapePointer", { enumerable: true, get: function () { return ref_utils_1.unescapePointer; } });
|
|
39
|
+
Object.defineProperty(exports, "isRef", { enumerable: true, get: function () { return ref_utils_1.isRef; } });
|
|
39
40
|
var oas_types_1 = require("./oas-types");
|
|
40
41
|
Object.defineProperty(exports, "detectOpenAPI", { enumerable: true, get: function () { return oas_types_1.detectOpenAPI; } });
|
|
41
42
|
Object.defineProperty(exports, "OasMajorVersion", { enumerable: true, get: function () { return oas_types_1.OasMajorVersion; } });
|
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;
|
|
@@ -19,10 +19,7 @@ const OperationSecurityDefined = () => {
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
SecurityScheme(_securityScheme, { key }) {
|
|
22
|
-
referencedSchemes.set(key.toString(), {
|
|
23
|
-
defined: true,
|
|
24
|
-
from: [],
|
|
25
|
-
});
|
|
22
|
+
referencedSchemes.set(key.toString(), { defined: true, from: [] });
|
|
26
23
|
},
|
|
27
24
|
SecurityRequirement(requirements, { location }) {
|
|
28
25
|
for (const requirement of Object.keys(requirements)) {
|
package/lib/rules/common/spec.js
CHANGED
|
@@ -4,10 +4,11 @@ exports.OasSpec = void 0;
|
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const ref_utils_1 = require("../../ref-utils");
|
|
7
|
+
const utils_2 = require("../../utils");
|
|
7
8
|
const OasSpec = () => {
|
|
8
9
|
return {
|
|
9
10
|
any(node, { report, type, location, key, resolve, ignoreNextVisitorsOnNode }) {
|
|
10
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
11
12
|
const nodeType = utils_1.oasTypeOf(node);
|
|
12
13
|
if (type.items) {
|
|
13
14
|
if (nodeType !== 'array') {
|
|
@@ -34,6 +35,20 @@ const OasSpec = () => {
|
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
}
|
|
38
|
+
const allowed = (_a = type.allowed) === null || _a === void 0 ? void 0 : _a.call(type, node);
|
|
39
|
+
if (allowed && utils_2.isPlainObject(node)) {
|
|
40
|
+
for (const propName in node) {
|
|
41
|
+
if (allowed.includes(propName) ||
|
|
42
|
+
(type.extensionsPrefix && propName.startsWith(type.extensionsPrefix)) ||
|
|
43
|
+
!Object.keys(type.properties).includes(propName)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
report({
|
|
47
|
+
message: `The field \`${propName}\` is not allowed here.`,
|
|
48
|
+
location: location.child([propName]).key()
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
const requiredOneOf = type.requiredOneOf || null;
|
|
38
53
|
if (requiredOneOf) {
|
|
39
54
|
let hasProperty = false;
|
|
@@ -94,8 +109,8 @@ const OasSpec = () => {
|
|
|
94
109
|
location: propLocation,
|
|
95
110
|
});
|
|
96
111
|
}
|
|
97
|
-
else if (propValueType === 'array' && ((
|
|
98
|
-
const itemsType = (
|
|
112
|
+
else if (propValueType === 'array' && ((_b = propSchema.items) === null || _b === void 0 ? void 0 : _b.type)) {
|
|
113
|
+
const itemsType = (_c = propSchema.items) === null || _c === void 0 ? void 0 : _c.type;
|
|
99
114
|
for (let i = 0; i < propValue.length; i++) {
|
|
100
115
|
const item = propValue[i];
|
|
101
116
|
if (!utils_1.matchesJsonSchemaType(item, itemsType, false)) {
|
|
@@ -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
|
-
};
|
|
@@ -13,22 +13,23 @@ const ValidContentExamples = (opts) => {
|
|
|
13
13
|
if (!mediaType.schema)
|
|
14
14
|
return;
|
|
15
15
|
if (mediaType.example) {
|
|
16
|
-
|
|
16
|
+
resolveAndValidateExample(mediaType.example, location.child('example'));
|
|
17
17
|
}
|
|
18
18
|
else if (mediaType.examples) {
|
|
19
19
|
for (const exampleName of Object.keys(mediaType.examples)) {
|
|
20
|
-
|
|
21
|
-
let dataLoc = location.child(['examples', exampleName, 'value']);
|
|
22
|
-
if (ref_utils_1.isRef(example)) {
|
|
23
|
-
const resolved = resolve(example);
|
|
24
|
-
if (!resolved.location)
|
|
25
|
-
continue;
|
|
26
|
-
dataLoc = resolved.location.child('value');
|
|
27
|
-
example = resolved.node;
|
|
28
|
-
}
|
|
29
|
-
utils_1.validateExample(example.value, mediaType.schema, dataLoc, ctx, disallowAdditionalProperties);
|
|
20
|
+
resolveAndValidateExample(mediaType.examples[exampleName], location.child(['examples', exampleName, 'value']), true);
|
|
30
21
|
}
|
|
31
22
|
}
|
|
23
|
+
function resolveAndValidateExample(example, location, isMultiple) {
|
|
24
|
+
if (ref_utils_1.isRef(example)) {
|
|
25
|
+
const resolved = resolve(example);
|
|
26
|
+
if (!resolved.location)
|
|
27
|
+
return;
|
|
28
|
+
location = isMultiple ? resolved.location.child('value') : resolved.location;
|
|
29
|
+
example = resolved.node;
|
|
30
|
+
}
|
|
31
|
+
utils_1.validateExample(isMultiple ? example.value : example, mediaType.schema, location, ctx, disallowAdditionalProperties);
|
|
32
|
+
}
|
|
32
33
|
},
|
|
33
34
|
},
|
|
34
35
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ 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?: ((value: any) => string[] | undefined);
|
|
26
|
+
extensionsPrefix?: string;
|
|
25
27
|
};
|
|
26
28
|
declare type PropType = string | NodeType | ScalarSchema | undefined | null;
|
|
27
29
|
declare type ResolveTypeFn = (value: any, key: string) => string | PropType;
|
|
@@ -32,6 +34,8 @@ export declare type NormalizedNodeType = {
|
|
|
32
34
|
items?: NormalizedNodeType;
|
|
33
35
|
required?: string[] | ((value: any, key: string | number | undefined) => string[]);
|
|
34
36
|
requiredOneOf?: string[];
|
|
37
|
+
allowed?: ((value: any) => string[] | undefined);
|
|
38
|
+
extensionsPrefix?: string;
|
|
35
39
|
};
|
|
36
40
|
declare type NormalizedPropType = NormalizedNodeType | NormalizedScalarSchema | undefined | null;
|
|
37
41
|
declare type NormalizedResolveTypeFn = (value: any, key: string) => NormalizedNodeType | NormalizedScalarSchema | undefined | null;
|
package/lib/types/oas2.js
CHANGED
|
@@ -68,9 +68,7 @@ const PathItem = {
|
|
|
68
68
|
const Operation = {
|
|
69
69
|
properties: {
|
|
70
70
|
tags: { type: 'array', items: { type: 'string' } },
|
|
71
|
-
summary: {
|
|
72
|
-
type: 'string',
|
|
73
|
-
},
|
|
71
|
+
summary: { type: 'string' },
|
|
74
72
|
description: { type: 'string' },
|
|
75
73
|
externalDocs: 'ExternalDocs',
|
|
76
74
|
operationId: { type: 'string' },
|
|
@@ -180,9 +178,7 @@ const ResponsesMap = {
|
|
|
180
178
|
};
|
|
181
179
|
const Response = {
|
|
182
180
|
properties: {
|
|
183
|
-
description: {
|
|
184
|
-
type: 'string',
|
|
185
|
-
},
|
|
181
|
+
description: { type: 'string' },
|
|
186
182
|
schema: 'Schema',
|
|
187
183
|
headers: _1.mapOf('Header'),
|
|
188
184
|
examples: 'Examples',
|
|
@@ -299,44 +295,55 @@ const SecurityScheme = {
|
|
|
299
295
|
type: { enum: ['basic', 'apiKey', 'oauth2'] },
|
|
300
296
|
description: { type: 'string' },
|
|
301
297
|
name: { type: 'string' },
|
|
302
|
-
in: { type: 'string', enum: ['query', 'header'
|
|
298
|
+
in: { type: 'string', enum: ['query', 'header'] },
|
|
303
299
|
flow: { enum: ['implicit', 'password', 'application', 'accessCode'] },
|
|
304
300
|
authorizationUrl: { type: 'string' },
|
|
305
301
|
tokenUrl: { type: 'string' },
|
|
306
302
|
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
307
303
|
},
|
|
308
304
|
required(value) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
306
|
+
case 'apiKey':
|
|
307
|
+
return ['type', 'name', 'in'];
|
|
308
|
+
case 'oauth2':
|
|
309
|
+
switch (value === null || value === void 0 ? void 0 : value.flow) {
|
|
310
|
+
case 'implicit':
|
|
311
|
+
return ['type', 'flow', 'authorizationUrl', 'scopes'];
|
|
312
|
+
case 'accessCode':
|
|
313
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'scopes'];
|
|
314
|
+
case 'application':
|
|
315
|
+
case 'password':
|
|
316
|
+
return ['type', 'flow', 'tokenUrl', 'scopes'];
|
|
317
|
+
default:
|
|
318
|
+
return ['type', 'flow', 'scopes'];
|
|
319
|
+
}
|
|
320
|
+
default:
|
|
321
|
+
return ['type'];
|
|
317
322
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
323
|
+
},
|
|
324
|
+
allowed(value) {
|
|
325
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
326
|
+
case 'basic':
|
|
327
|
+
return ['type', 'description'];
|
|
328
|
+
case 'apiKey':
|
|
329
|
+
return ['type', 'name', 'in', 'description'];
|
|
330
|
+
case 'oauth2':
|
|
331
|
+
switch (value === null || value === void 0 ? void 0 : value.flow) {
|
|
332
|
+
case 'implicit':
|
|
333
|
+
return ['type', 'flow', 'authorizationUrl', 'description', 'scopes'];
|
|
334
|
+
case 'accessCode':
|
|
335
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'description', 'scopes'];
|
|
336
|
+
case 'application':
|
|
337
|
+
case 'password':
|
|
338
|
+
return ['type', 'flow', 'tokenUrl', 'description', 'scopes'];
|
|
339
|
+
default:
|
|
340
|
+
return ['type', 'flow', 'tokenUrl', 'authorizationUrl', 'description', 'scopes'];
|
|
341
|
+
}
|
|
342
|
+
default:
|
|
343
|
+
return ['type', 'description'];
|
|
337
344
|
}
|
|
338
|
-
return ['type'];
|
|
339
345
|
},
|
|
346
|
+
extensionsPrefix: 'x-',
|
|
340
347
|
};
|
|
341
348
|
const SecurityRequirement = {
|
|
342
349
|
properties: {},
|