@openlint/ruleset-spectral-oas 0.0.0-stage → 1.0.0
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/LICENSE +191 -0
- package/README.md +11 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/oas/functions/index.d.ts +15 -0
- package/dist/oas/functions/index.js +33 -0
- package/dist/oas/functions/index.js.map +1 -0
- package/dist/oas/functions/oasDiscriminator.d.ts +6 -0
- package/dist/oas/functions/oasDiscriminator.js +39 -0
- package/dist/oas/functions/oasDiscriminator.js.map +1 -0
- package/dist/oas/functions/oasDocumentSchema.d.ts +2 -0
- package/dist/oas/functions/oasDocumentSchema.js +104 -0
- package/dist/oas/functions/oasDocumentSchema.js.map +1 -0
- package/dist/oas/functions/oasExample.d.ts +7 -0
- package/dist/oas/functions/oasExample.js +217 -0
- package/dist/oas/functions/oasExample.js.map +1 -0
- package/dist/oas/functions/oasOpFormDataConsumeCheck.d.ts +6 -0
- package/dist/oas/functions/oasOpFormDataConsumeCheck.js +30 -0
- package/dist/oas/functions/oasOpFormDataConsumeCheck.js.map +1 -0
- package/dist/oas/functions/oasOpIdUnique.d.ts +2 -0
- package/dist/oas/functions/oasOpIdUnique.js +35 -0
- package/dist/oas/functions/oasOpIdUnique.js.map +1 -0
- package/dist/oas/functions/oasOpParams.d.ts +2 -0
- package/dist/oas/functions/oasOpParams.js +75 -0
- package/dist/oas/functions/oasOpParams.js.map +1 -0
- package/dist/oas/functions/oasOpSuccessResponse.d.ts +2 -0
- package/dist/oas/functions/oasOpSuccessResponse.js +27 -0
- package/dist/oas/functions/oasOpSuccessResponse.js.map +1 -0
- package/dist/oas/functions/oasPathParam.d.ts +2 -0
- package/dist/oas/functions/oasPathParam.js +135 -0
- package/dist/oas/functions/oasPathParam.js.map +1 -0
- package/dist/oas/functions/oasSchema.d.ts +5 -0
- package/dist/oas/functions/oasSchema.js +81 -0
- package/dist/oas/functions/oasSchema.js.map +1 -0
- package/dist/oas/functions/oasSecurityDefined.d.ts +5 -0
- package/dist/oas/functions/oasSecurityDefined.js +76 -0
- package/dist/oas/functions/oasSecurityDefined.js.map +1 -0
- package/dist/oas/functions/oasTagDefined.d.ts +2 -0
- package/dist/oas/functions/oasTagDefined.js +42 -0
- package/dist/oas/functions/oasTagDefined.js.map +1 -0
- package/dist/oas/functions/oasUnusedComponent.d.ts +4 -0
- package/dist/oas/functions/oasUnusedComponent.js +40 -0
- package/dist/oas/functions/oasUnusedComponent.js.map +1 -0
- package/dist/oas/functions/refSiblings.d.ts +2 -0
- package/dist/oas/functions/refSiblings.js +42 -0
- package/dist/oas/functions/refSiblings.js.map +1 -0
- package/dist/oas/functions/typedEnum.d.ts +7 -0
- package/dist/oas/functions/typedEnum.js +76 -0
- package/dist/oas/functions/typedEnum.js.map +1 -0
- package/dist/oas/functions/utils/getAllOperations.d.ts +7 -0
- package/dist/oas/functions/utils/getAllOperations.js +31 -0
- package/dist/oas/functions/utils/getAllOperations.js.map +1 -0
- package/dist/oas/functions/utils/isObject.d.ts +2 -0
- package/dist/oas/functions/utils/isObject.js +7 -0
- package/dist/oas/functions/utils/isObject.js.map +1 -0
- package/dist/oas/index.d.ts +733 -0
- package/dist/oas/index.js +765 -0
- package/dist/oas/index.js.map +1 -0
- package/dist/oas/schemas/__fixtures__/validate.d.ts +1 -0
- package/dist/oas/schemas/__fixtures__/validate.js +3 -0
- package/dist/oas/schemas/__fixtures__/validate.js.map +1 -0
- package/dist/oas/schemas/json-schema/draft-04.json +137 -0
- package/dist/oas/schemas/json-schema/draft-2020-12/index.json +54 -0
- package/dist/oas/schemas/json-schema/draft-2020-12/validation.json +101 -0
- package/dist/oas/schemas/oas/v2.0.json +1478 -0
- package/dist/oas/schemas/oas/v3.0.json +1652 -0
- package/dist/oas/schemas/oas/v3.1/dialect.schema.json +35 -0
- package/dist/oas/schemas/oas/v3.1/index.json +1276 -0
- package/dist/oas/schemas/oas/v3.1/meta.schema.json +93 -0
- package/dist/oas/schemas/oas/v3.2/dialect.schema.json +25 -0
- package/dist/oas/schemas/oas/v3.2/index.json +1527 -0
- package/dist/oas/schemas/oas/v3.2/meta.schema.json +103 -0
- package/dist/oas/schemas/validators.d.ts +66 -0
- package/dist/oas/schemas/validators.js +12991 -0
- package/dist/oas/schemas/validators.js.map +1 -0
- package/dist/shared/functions/index.d.ts +2 -0
- package/dist/shared/functions/index.js +7 -0
- package/dist/shared/functions/index.js.map +1 -0
- package/dist/shared/functions/serverVariables/index.d.ts +16 -0
- package/dist/shared/functions/serverVariables/index.js +154 -0
- package/dist/shared/functions/serverVariables/index.js.map +1 -0
- package/dist/shared/functions/serverVariables/utils/applyUrlVariables.d.ts +3 -0
- package/dist/shared/functions/serverVariables/utils/applyUrlVariables.js +32 -0
- package/dist/shared/functions/serverVariables/utils/applyUrlVariables.js.map +1 -0
- package/dist/shared/functions/serverVariables/utils/parseUrlVariables.d.ts +1 -0
- package/dist/shared/functions/serverVariables/utils/parseUrlVariables.js +12 -0
- package/dist/shared/functions/serverVariables/utils/parseUrlVariables.js.map +1 -0
- package/dist/shared/functions/uniquenessTags.d.ts +5 -0
- package/dist/shared/functions/uniquenessTags.js +42 -0
- package/dist/shared/functions/uniquenessTags.js.map +1 -0
- package/dist/shared/utils/getMissingProps.d.ts +1 -0
- package/dist/shared/utils/getMissingProps.js +9 -0
- package/dist/shared/utils/getMissingProps.js.map +1 -0
- package/dist/shared/utils/getRedundantProps.d.ts +1 -0
- package/dist/shared/utils/getRedundantProps.js +9 -0
- package/dist/shared/utils/getRedundantProps.js.map +1 -0
- package/package.json +47 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniquenessTags = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const uniquenessTags_1 = tslib_1.__importDefault(require("./uniquenessTags"));
|
|
6
|
+
Object.defineProperty(exports, "uniquenessTags", { enumerable: true, get: function () { return uniquenessTags_1.default; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/functions/index.ts"],"names":[],"mappings":";;;;AAAA,8EAA6D;AAEpD,+FAFW,wBAAc,OAEX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Input = {
|
|
2
|
+
url: string;
|
|
3
|
+
variables?: Record<string, {
|
|
4
|
+
enum?: string[];
|
|
5
|
+
default?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
examples?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
type Options = {
|
|
12
|
+
checkSubstitutions?: boolean;
|
|
13
|
+
requireDefault?: boolean;
|
|
14
|
+
} | null;
|
|
15
|
+
declare const _default: import("@openlint/openlint-core").RulesetFunctionWithValidator<Input, Options>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
4
|
+
const parseUrlVariables_1 = require("./utils/parseUrlVariables");
|
|
5
|
+
const getMissingProps_1 = require("../../utils/getMissingProps");
|
|
6
|
+
const getRedundantProps_1 = require("../../utils/getRedundantProps");
|
|
7
|
+
const applyUrlVariables_1 = require("./utils/applyUrlVariables");
|
|
8
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
9
|
+
input: {
|
|
10
|
+
errorMessage: 'Invalid Server Object',
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
url: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
},
|
|
16
|
+
variables: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
additionalProperties: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
enum: {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
default: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
},
|
|
33
|
+
examples: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
patternProperties: {
|
|
38
|
+
'^x-': true,
|
|
39
|
+
},
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['url'],
|
|
45
|
+
},
|
|
46
|
+
errorOnInvalidInput: true,
|
|
47
|
+
options: {
|
|
48
|
+
type: ['object', 'null'],
|
|
49
|
+
properties: {
|
|
50
|
+
checkSubstitutions: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
default: 'false',
|
|
53
|
+
},
|
|
54
|
+
requireDefault: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
default: 'false',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
},
|
|
61
|
+
}, function serverVariables({ url, variables }, opts, ctx) {
|
|
62
|
+
const results = [];
|
|
63
|
+
const foundVariables = (0, parseUrlVariables_1.parseUrlVariables)(url);
|
|
64
|
+
const definedVariablesKeys = variables === void 0 ? [] : Object.keys(variables);
|
|
65
|
+
accumulateRedundantVariables(results, ctx.path, foundVariables, definedVariablesKeys);
|
|
66
|
+
if (foundVariables.length === 0)
|
|
67
|
+
return results;
|
|
68
|
+
accumulateMissingVariables(results, ctx.path, foundVariables, definedVariablesKeys);
|
|
69
|
+
if (variables === void 0)
|
|
70
|
+
return results;
|
|
71
|
+
const variablePairs = [];
|
|
72
|
+
for (const key of definedVariablesKeys) {
|
|
73
|
+
if (!foundVariables.includes(key))
|
|
74
|
+
continue;
|
|
75
|
+
const variable = variables[key];
|
|
76
|
+
if (variable.enum !== undefined) {
|
|
77
|
+
variablePairs.push([key, variable.enum]);
|
|
78
|
+
checkVariableEnumValues(results, ctx.path, key, variable.enum, variable.default);
|
|
79
|
+
}
|
|
80
|
+
else if (variable.default !== undefined) {
|
|
81
|
+
variablePairs.push([key, [variable.default]]);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
variablePairs.push([key, []]);
|
|
85
|
+
}
|
|
86
|
+
if (variable.default === undefined && (opts === null || opts === void 0 ? void 0 : opts.requireDefault) === true) {
|
|
87
|
+
results.push({
|
|
88
|
+
message: `Server Variable "${key}" has a missing default.`,
|
|
89
|
+
path: [...ctx.path, 'variables', key],
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.checkSubstitutions) === true) {
|
|
94
|
+
checkSubstitutions(results, ctx.path, url, variablePairs);
|
|
95
|
+
}
|
|
96
|
+
return results;
|
|
97
|
+
});
|
|
98
|
+
function accumulateRedundantVariables(results, path, foundVariables, definedVariablesKeys) {
|
|
99
|
+
if (definedVariablesKeys.length === 0)
|
|
100
|
+
return;
|
|
101
|
+
const redundantVariables = (0, getRedundantProps_1.getRedundantProps)(foundVariables, definedVariablesKeys);
|
|
102
|
+
for (const variable of redundantVariables) {
|
|
103
|
+
results.push({
|
|
104
|
+
message: `Server's "variables" object has unused defined "${variable}" url variable.`,
|
|
105
|
+
path: [...path, 'variables', variable],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function accumulateMissingVariables(results, path, foundVariables, definedVariablesKeys) {
|
|
110
|
+
const missingVariables = definedVariablesKeys.length === 0 ? foundVariables : (0, getMissingProps_1.getMissingProps)(foundVariables, definedVariablesKeys);
|
|
111
|
+
if (missingVariables.length > 0) {
|
|
112
|
+
results.push({
|
|
113
|
+
message: `Not all server's variables are described with "variables" object. Missed: ${missingVariables.join(', ')}.`,
|
|
114
|
+
path: [...path, 'variables'],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function checkVariableEnumValues(results, path, name, enumValues, defaultValue) {
|
|
119
|
+
if (defaultValue !== void 0 && !enumValues.includes(defaultValue)) {
|
|
120
|
+
results.push({
|
|
121
|
+
message: `Server Variable "${name}" has a default not listed in the enum.`,
|
|
122
|
+
path: [...path, 'variables', name, 'default'],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function checkSubstitutions(results, path, url, variables) {
|
|
127
|
+
if (variables.length === 0)
|
|
128
|
+
return;
|
|
129
|
+
const invalidUrls = [];
|
|
130
|
+
for (const substitutedUrl of (0, applyUrlVariables_1.applyUrlVariables)(url, variables)) {
|
|
131
|
+
try {
|
|
132
|
+
new URL(substitutedUrl);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
invalidUrls.push(substitutedUrl);
|
|
136
|
+
if (invalidUrls.length === 5) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (invalidUrls.length === 5) {
|
|
142
|
+
results.push({
|
|
143
|
+
message: `At least 5 substitutions of server variables resulted in invalid URLs: ${invalidUrls.join(', ')} and more`,
|
|
144
|
+
path: [...path, 'variables'],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else if (invalidUrls.length > 0) {
|
|
148
|
+
results.push({
|
|
149
|
+
message: `A few substitutions of server variables resulted in invalid URLs: ${invalidUrls.join(', ')}`,
|
|
150
|
+
path: [...path, 'variables'],
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/shared/functions/serverVariables/index.ts"],"names":[],"mappings":";;AAAA,2DAAgE;AAGhE,iEAA8D;AAC9D,iEAA8D;AAC9D,qEAAkE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AM,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC;YACX,OAAO,EAAE,qEAAqE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACtG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyUrlVariables = applyUrlVariables;
|
|
4
|
+
function* applyUrlVariables(url, variables) {
|
|
5
|
+
yield* _applyUrlVariables(url, 0, variables.map(toApplicableVariable));
|
|
6
|
+
}
|
|
7
|
+
// this loosely follows https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.2
|
|
8
|
+
function* _applyUrlVariables(url, i, variables) {
|
|
9
|
+
const [name, values] = variables[i];
|
|
10
|
+
let x = 0;
|
|
11
|
+
while (x < values.length) {
|
|
12
|
+
const substitutedValue = url.replace(name, values[x]);
|
|
13
|
+
if (i === variables.length - 1) {
|
|
14
|
+
yield substitutedValue;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
yield* _applyUrlVariables(substitutedValue, i + 1, variables);
|
|
18
|
+
}
|
|
19
|
+
x++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function toApplicableVariable([name, values]) {
|
|
23
|
+
return [toReplaceRegExp(name), values.map(encodeURI)];
|
|
24
|
+
}
|
|
25
|
+
function toReplaceRegExp(name) {
|
|
26
|
+
return RegExp(escapeRegexp(`{${name}}`), 'g');
|
|
27
|
+
}
|
|
28
|
+
// https://github.com/tc39/proposal-regex-escaping/blob/main/polyfill.js
|
|
29
|
+
function escapeRegexp(value) {
|
|
30
|
+
return value.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=applyUrlVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyUrlVariables.js","sourceRoot":"","sources":["../../../../../src/shared/functions/serverVariables/utils/applyUrlVariables.ts"],"names":[],"mappings":";;AAGA,8CAEC;AAFD,QAAe,CAAC,CAAC,iBAAiB,CAAC,GAAW,EAAE,SAA8B;IAC5E,KAAK,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,mFAAmF;AACnF,QAAQ,CAAC,CAAC,kBAAkB,CAAC,GAAW,EAAE,CAAS,EAAE,SAAwC;IAC3F,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACzB,MAAM,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtD,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,gBAAgB,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,CAAC,kBAAkB,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC;QAED,CAAC,EAAE,CAAC;IACN,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAW;IACpD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,wEAAwE;AACxE,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseUrlVariables(str: string): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUrlVariables = parseUrlVariables;
|
|
4
|
+
function parseUrlVariables(str) {
|
|
5
|
+
if (typeof str !== 'string')
|
|
6
|
+
return [];
|
|
7
|
+
const variables = str.match(/{(.+?)}/g);
|
|
8
|
+
if (!variables || variables.length === 0)
|
|
9
|
+
return [];
|
|
10
|
+
return variables.map(v => v.slice(1, -1));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=parseUrlVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseUrlVariables.js","sourceRoot":"","sources":["../../../../../src/shared/functions/serverVariables/utils/parseUrlVariables.ts"],"names":[],"mappings":";;AAAA,8CAKC;AALD,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
4
|
+
function getDuplicateTagsIndexes(tags) {
|
|
5
|
+
return tags
|
|
6
|
+
.map(item => item.name)
|
|
7
|
+
.reduce((acc, item, i, arr) => {
|
|
8
|
+
if (arr.indexOf(item) !== i) {
|
|
9
|
+
acc.push(i);
|
|
10
|
+
}
|
|
11
|
+
return acc;
|
|
12
|
+
}, []);
|
|
13
|
+
}
|
|
14
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
15
|
+
input: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
name: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: ['name'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
options: null,
|
|
28
|
+
}, function uniquenessTags(targetVal, _, ctx) {
|
|
29
|
+
const duplicatedTags = getDuplicateTagsIndexes(targetVal);
|
|
30
|
+
if (duplicatedTags.length === 0)
|
|
31
|
+
return [];
|
|
32
|
+
const results = [];
|
|
33
|
+
for (const duplicatedIndex of duplicatedTags) {
|
|
34
|
+
const duplicatedTag = targetVal[duplicatedIndex].name;
|
|
35
|
+
results.push({
|
|
36
|
+
message: `"tags" object contains duplicate tag name "${duplicatedTag}".`,
|
|
37
|
+
path: [...ctx.path, duplicatedIndex, 'name'],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return results;
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=uniquenessTags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniquenessTags.js","sourceRoot":"","sources":["../../../src/shared/functions/uniquenessTags.ts"],"names":[],"mappings":";;AAAA,2DAAgE;AAMhE,SAAS,uBAAuB,CAAC,IAAU;IACzC,OAAO,IAAI;SACR,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACtB,MAAM,CAAW,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;QACtC,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC;AAED,kBAAe,IAAA,qCAAqB,EAClC;IACE,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IACD,OAAO,EAAE,IAAI;CACd,EACD,SAAS,cAAc,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG;IACvC,MAAM,cAAc,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE3C,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,KAAK,MAAM,eAAe,IAAI,cAAc,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC;QACtD,OAAO,CAAC,IAAI,CAAC;YACX,OAAO,EAAE,8CAA8C,aAAa,IAAI;YACxE,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getMissingProps(arr: string[], props: string[]): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMissingProps = getMissingProps;
|
|
4
|
+
function getMissingProps(arr, props) {
|
|
5
|
+
return arr.filter(val => {
|
|
6
|
+
return !props.includes(val);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=getMissingProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMissingProps.js","sourceRoot":"","sources":["../../../src/shared/utils/getMissingProps.ts"],"names":[],"mappings":";;AAAA,0CAIC;AAJD,SAAgB,eAAe,CAAC,GAAa,EAAE,KAAe;IAC5D,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRedundantProps(arr: string[], keys: string[]): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRedundantProps = getRedundantProps;
|
|
4
|
+
function getRedundantProps(arr, keys) {
|
|
5
|
+
return keys.filter(val => {
|
|
6
|
+
return !arr.includes(val);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=getRedundantProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRedundantProps.js","sourceRoot":"","sources":["../../../src/shared/utils/getRedundantProps.ts"],"names":[],"mappings":";;AAAA,8CAIC;AAJD,SAAgB,iBAAiB,CAAC,GAAa,EAAE,IAAc;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openlint/ruleset-spectral-oas",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Legacy Spectral OpenAPI ruleset for OpenLint",
|
|
5
|
+
"homepage": "https://github.com/openlint/ruleset-spectral-oas",
|
|
6
|
+
"bugs": "https://github.com/openlint/ruleset-spectral-oas/issues",
|
|
7
|
+
"author": "OpenLint <info@openlint.org>",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/openlint/ruleset-spectral-oas.git"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.0 || >= 24.0"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"/dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.build.json",
|
|
23
|
+
"test": "vitest run"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@openlint/openlint-core": "0.x",
|
|
27
|
+
"@openlint/openlint-formats": "0.x",
|
|
28
|
+
"@openlint/openlint-functions": "0.x",
|
|
29
|
+
"@openlint/openlint-runtime": "0.x",
|
|
30
|
+
"@stoplight/better-ajv-errors": "1.0.3",
|
|
31
|
+
"@stoplight/json": "^3.17.0",
|
|
32
|
+
"@stoplight/types": "^13.6.0",
|
|
33
|
+
"ajv": "^8.20.0",
|
|
34
|
+
"ajv-formats": "~2.1.1",
|
|
35
|
+
"json-schema-traverse": "^1.0.0",
|
|
36
|
+
"leven": "3.1.0",
|
|
37
|
+
"lodash": "^4.18.1",
|
|
38
|
+
"tslib": "^2.8.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@openlint/openlint-parsers": "^1.0.0",
|
|
42
|
+
"@openlint/openlint-ref-resolver": "0.x",
|
|
43
|
+
"@stoplight/path": "^1.3.2",
|
|
44
|
+
"@types/node": "^24.0.0",
|
|
45
|
+
"nock": "^13.5.4",
|
|
46
|
+
"typescript": "^6.0.0",
|
|
47
|
+
"vitest": "^5.0.5"
|
|
48
|
+
}
|
|
49
|
+
}
|