@openlint/ruleset-spectral-oas 0.0.0-stage → 0.1.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,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const json_schema_traverse_1 = tslib_1.__importDefault(require("json-schema-traverse"));
|
|
5
|
+
const openlint_functions_1 = require("@openlint/openlint-functions");
|
|
6
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
7
|
+
const openlint_formats_1 = require("@openlint/openlint-formats");
|
|
8
|
+
const json_1 = require("@stoplight/json");
|
|
9
|
+
function rewriteNullable(schema, errors) {
|
|
10
|
+
for (const error of errors) {
|
|
11
|
+
if (error.keyword !== 'type')
|
|
12
|
+
continue;
|
|
13
|
+
const value = getSchemaProperty(schema, error.schemaPath);
|
|
14
|
+
if ((0, json_1.isPlainObject)(value) && value.nullable === true) {
|
|
15
|
+
error.message += ',null';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
20
|
+
input: null,
|
|
21
|
+
options: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
schema: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
}, function oasSchema(targetVal, opts, context) {
|
|
31
|
+
var _a;
|
|
32
|
+
const formats = context.document.formats;
|
|
33
|
+
let { schema } = opts;
|
|
34
|
+
let dialect = 'draft4';
|
|
35
|
+
let prepareResults;
|
|
36
|
+
if (!formats) {
|
|
37
|
+
dialect = 'auto';
|
|
38
|
+
}
|
|
39
|
+
else if (formats.has(openlint_formats_1.oas3_2) || formats.has(openlint_formats_1.oas3_1)) {
|
|
40
|
+
if ((0, json_1.isPlainObject)(context.document.data) && typeof context.document.data.jsonSchemaDialect === 'string') {
|
|
41
|
+
dialect =
|
|
42
|
+
(_a = (0, openlint_formats_1.extractDraftVersion)(context.document.data.jsonSchemaDialect)) !== null && _a !== void 0 ? _a : 'draft2020-12';
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
dialect = 'draft2020-12';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (formats.has(openlint_formats_1.oas3_0)) {
|
|
49
|
+
prepareResults = rewriteNullable.bind(null, schema);
|
|
50
|
+
}
|
|
51
|
+
else if (formats.has(openlint_formats_1.oas2)) {
|
|
52
|
+
const clonedSchema = JSON.parse(JSON.stringify(schema));
|
|
53
|
+
(0, json_schema_traverse_1.default)(clonedSchema, visitOAS2);
|
|
54
|
+
schema = clonedSchema;
|
|
55
|
+
prepareResults = rewriteNullable.bind(null, clonedSchema);
|
|
56
|
+
}
|
|
57
|
+
return (0, openlint_functions_1.schema)(targetVal, {
|
|
58
|
+
...opts,
|
|
59
|
+
schema,
|
|
60
|
+
prepareResults,
|
|
61
|
+
dialect,
|
|
62
|
+
}, context);
|
|
63
|
+
});
|
|
64
|
+
const visitOAS2 = schema => {
|
|
65
|
+
if (schema['x-nullable'] === true) {
|
|
66
|
+
schema.nullable = true;
|
|
67
|
+
delete schema['x-nullable'];
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function getSchemaProperty(schema, schemaPath) {
|
|
71
|
+
const path = (0, json_1.pointerToPath)(schemaPath);
|
|
72
|
+
let value = schema;
|
|
73
|
+
for (const fragment of path.slice(0, -1)) {
|
|
74
|
+
if (!(0, json_1.isPlainObject)(value)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
value = value[fragment];
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=oasSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oasSchema.js","sourceRoot":"","sources":["../../../src/oas/functions/oasSchema.ts"],"names":[],"mappings":";;;AACA,wFAA4C;AAC5C,qEAAiF;AACjF,2DAAgE;AAChE,iEAA+F;AAC/F,0CAA+D;AAM/D,SAAS,eAAe,CAAC,MAAoB,EAAE,MAAqB;IAClE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM;YAAE,SAAS;QACvC,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,EAAE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
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
4
|
+
const json_1 = require("@stoplight/json");
|
|
5
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
6
|
+
input: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
additionalProperties: {
|
|
9
|
+
type: 'array',
|
|
10
|
+
items: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
options: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
oasVersion: {
|
|
19
|
+
enum: [2, 3],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
}, function oasSecurityDefined(input, { oasVersion }, { document, path }) {
|
|
25
|
+
const schemeNames = Object.keys(input);
|
|
26
|
+
if (schemeNames.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
if (!(0, json_1.isPlainObject)(document.data))
|
|
29
|
+
return;
|
|
30
|
+
const allDefs = oasVersion === 2
|
|
31
|
+
? document.data.securityDefinitions
|
|
32
|
+
: (0, json_1.isPlainObject)(document.data.components)
|
|
33
|
+
? document.data.components.securitySchemes
|
|
34
|
+
: null;
|
|
35
|
+
let results;
|
|
36
|
+
for (const schemeName of schemeNames) {
|
|
37
|
+
if (!(0, json_1.isPlainObject)(allDefs) || !(schemeName in allDefs)) {
|
|
38
|
+
const object = path.length == 2 ? 'API' : 'Operation';
|
|
39
|
+
const location = oasVersion === 2 ? 'securityDefinitions' : 'components.securitySchemes';
|
|
40
|
+
results !== null && results !== void 0 ? results : (results = []);
|
|
41
|
+
results.push({
|
|
42
|
+
message: `${object} "security" values must match a scheme defined in the "${location}" object.`,
|
|
43
|
+
path: [...path, schemeName],
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const scope = input[schemeName];
|
|
48
|
+
for (let i = 0; i < scope.length; i++) {
|
|
49
|
+
const scopeName = scope[i];
|
|
50
|
+
if (!isScopeDefined(oasVersion, scopeName, allDefs[schemeName])) {
|
|
51
|
+
results !== null && results !== void 0 ? results : (results = []);
|
|
52
|
+
results.push({
|
|
53
|
+
message: `"${scopeName}" must be listed among scopes.`,
|
|
54
|
+
path: [...path, schemeName, i],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return results;
|
|
60
|
+
});
|
|
61
|
+
function isScopeDefined(oasVersion, scopeName, securityScheme) {
|
|
62
|
+
if (!(0, json_1.isPlainObject)(securityScheme))
|
|
63
|
+
return false;
|
|
64
|
+
if (oasVersion === 2) {
|
|
65
|
+
return (0, json_1.isPlainObject)(securityScheme.scopes) && scopeName in securityScheme.scopes;
|
|
66
|
+
}
|
|
67
|
+
if ((0, json_1.isPlainObject)(securityScheme.flows)) {
|
|
68
|
+
for (const flow of Object.values(securityScheme.flows)) {
|
|
69
|
+
if ((0, json_1.isPlainObject)(flow) && (0, json_1.isPlainObject)(flow.scopes) && scopeName in flow.scopes) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=oasSecurityDefined.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oasSecurityDefined.js","sourceRoot":"","sources":["../../../src/oas/functions/oasSecurityDefined.ts"],"names":[],"mappings":";;AAAA,2DAAgE;AAEhE,0CAAgD;AAMhD,kBAAe,IAAA,qCAAqB,EAClC;IACE,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE;YACpB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;aACf;SACF;KACF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,U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,EAAE,CAAC;gBAClF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This function will check an API doc to verify that any tag that appears on
|
|
3
|
+
// an operation is also present in the global tags array.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
6
|
+
const getAllOperations_1 = require("./utils/getAllOperations");
|
|
7
|
+
const isObject_1 = require("./utils/isObject");
|
|
8
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
9
|
+
input: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
},
|
|
12
|
+
options: null,
|
|
13
|
+
}, function oasTagDefined(targetVal) {
|
|
14
|
+
const results = [];
|
|
15
|
+
const globalTags = [];
|
|
16
|
+
if (Array.isArray(targetVal.tags)) {
|
|
17
|
+
for (const tag of targetVal.tags) {
|
|
18
|
+
if ((0, isObject_1.isObject)(tag) && typeof tag.name === 'string') {
|
|
19
|
+
globalTags.push(tag.name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const { paths } = targetVal;
|
|
24
|
+
for (const { path, operation, value } of (0, getAllOperations_1.getAllOperations)(paths)) {
|
|
25
|
+
if (!(0, isObject_1.isObject)(value))
|
|
26
|
+
continue;
|
|
27
|
+
const { tags } = value;
|
|
28
|
+
if (!Array.isArray(tags)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
for (const [i, tag] of tags.entries()) {
|
|
32
|
+
if (!globalTags.includes(tag)) {
|
|
33
|
+
results.push({
|
|
34
|
+
message: 'Operation tags must be defined in global tags.',
|
|
35
|
+
path: ['paths', path, operation, 'tags', i],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return results;
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=oasTagDefined.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oasTagDefined.js","sourceRoot":"","sources":["../../../src/oas/functions/oasTagDefined.ts"],"names":[],"mappings":";AAAA,6EAA6E;AAC7E,yDAAyD;;AAGzD,2DAAgE;AAChE,+DAA4D;AAC5D,+CAA4C;AAE5C,kBAAe,IAAA,qCAAqB,EAClC;IACE,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;KACf;IACD,OAAO,EAAE,IAAI;CACd,EACD,SAAS,aAAa,CAAC,SAAS;IAC9B,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,IAAA,mBAAQ,EAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAClD,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;IAE5B,KAAK,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,IAAA,mCAAgB,EAAC,KAAK,CAAC,EAAE,CAAC;QACjE,IAAI,CAAC,IAAA,mBAAQ,EAAC,KAAK,CAAC;YAAE,SAAS;QAE/B,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC;oBACX,OAAO,EAAE,gDAAgD;oBACzD,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;iBAC5C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openlint_functions_1 = require("@openlint/openlint-functions");
|
|
4
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
5
|
+
const isObject_1 = require("./utils/isObject");
|
|
6
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
7
|
+
input: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
components: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: ['components'],
|
|
15
|
+
},
|
|
16
|
+
options: null,
|
|
17
|
+
}, function oasUnusedComponent(targetVal, opts, context) {
|
|
18
|
+
const results = [];
|
|
19
|
+
const componentTypes = [
|
|
20
|
+
'schemas',
|
|
21
|
+
'responses',
|
|
22
|
+
'parameters',
|
|
23
|
+
'examples',
|
|
24
|
+
'requestBodies',
|
|
25
|
+
'headers',
|
|
26
|
+
'links',
|
|
27
|
+
'callbacks',
|
|
28
|
+
];
|
|
29
|
+
for (const type of componentTypes) {
|
|
30
|
+
const value = targetVal.components[type];
|
|
31
|
+
if (!(0, isObject_1.isObject)(value))
|
|
32
|
+
continue;
|
|
33
|
+
const resultsForType = (0, openlint_functions_1.unreferencedReusableObject)(value, { reusableObjectsLocation: `#/components/${type}` }, context);
|
|
34
|
+
if (resultsForType !== void 0 && Array.isArray(resultsForType)) {
|
|
35
|
+
results.push(...resultsForType);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=oasUnusedComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oasUnusedComponent.js","sourceRoot":"","sources":["../../../src/oas/functions/oasUnusedComponent.ts"],"names":[],"mappings":";;AAAA,qEAA0E;AAC1E,2DAAiF;AACjF,+CAA4C;AAE5C,kBAAe,IAAA,qCAAqB,EAClC;IACE,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;aACf;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;IACD,OAAO,EAAE,IAAI;CACd,EACD,SAAS,kBAAkB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO;IAClD,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,MAAM,cAAc,GAAG;QACrB,SAAS;QACT,WAAW;QACX,YAAY;QACZ,UAAU;QACV,eAAe;QACf,SAAS;QACT,OAAO;QACP,WAAW;KACZ,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,IAAA,mBAAQ,EAAC,KAAK,CAAC;YAAE,SAAS;QAE/B,MAAM,cAAc,GAAG,IAAA,+CAA0B,EAC/C,KAAK,EACL,EAAE,uBAAuB,EAAE,gBAAgB,IAAI,EAAE,EAAE,EACnD,OAAO,CACR,CAAC;QACF,IAAI,cAAc,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YAC/D,OAAO,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CACF,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
|
+
const isObject_1 = require("./utils/isObject");
|
|
5
|
+
function getParentValue(document, path) {
|
|
6
|
+
if (path.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
let piece = document;
|
|
10
|
+
for (let i = 0; i < path.length - 1; i += 1) {
|
|
11
|
+
if (!(0, isObject_1.isObject)(piece)) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
piece = piece[path[i]];
|
|
15
|
+
}
|
|
16
|
+
return piece;
|
|
17
|
+
}
|
|
18
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
19
|
+
input: null,
|
|
20
|
+
options: null,
|
|
21
|
+
}, function refSiblings(targetVal, opts, { document, path }) {
|
|
22
|
+
const value = getParentValue(document.data, path);
|
|
23
|
+
if (!(0, isObject_1.isObject)(value))
|
|
24
|
+
return;
|
|
25
|
+
const keys = Object.keys(value);
|
|
26
|
+
if (keys.length === 1) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const results = [];
|
|
30
|
+
const actualObjPath = path.slice(0, -1);
|
|
31
|
+
for (const key of keys) {
|
|
32
|
+
if (key === '$ref') {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
results.push({
|
|
36
|
+
message: '$ref must not be placed next to any other properties',
|
|
37
|
+
path: [...actualObjPath, key],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return results;
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=refSiblings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refSiblings.js","sourceRoot":"","sources":["../../../src/oas/functions/refSiblings.ts"],"names":[],"mappings":";;AAAA,2DAAgE;AAGhE,+CAA4C;AAE5C,SAAS,cAAc,CAAC,QAA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AAG,aAAa,EAAE,GAAG,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const openlint_formats_1 = require("@openlint/openlint-formats");
|
|
4
|
+
const openlint_runtime_1 = require("@openlint/openlint-runtime");
|
|
5
|
+
const openlint_core_1 = require("@openlint/openlint-core");
|
|
6
|
+
function getDataType(input, checkForInteger) {
|
|
7
|
+
const type = typeof input;
|
|
8
|
+
switch (type) {
|
|
9
|
+
case 'string':
|
|
10
|
+
case 'boolean':
|
|
11
|
+
return type;
|
|
12
|
+
case 'number':
|
|
13
|
+
if (checkForInteger && Number.isInteger(input)) {
|
|
14
|
+
return 'integer';
|
|
15
|
+
}
|
|
16
|
+
return 'number';
|
|
17
|
+
case 'object':
|
|
18
|
+
if (input === null) {
|
|
19
|
+
return 'null';
|
|
20
|
+
}
|
|
21
|
+
return Array.isArray(input) ? 'array' : 'object';
|
|
22
|
+
default:
|
|
23
|
+
throw TypeError('Unknown input type');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function getTypes(input, formats) {
|
|
27
|
+
const { type } = input;
|
|
28
|
+
if ((input.nullable === true && (formats === null || formats === void 0 ? void 0 : formats.has(openlint_formats_1.oas3_0)) === true) ||
|
|
29
|
+
(input['x-nullable'] === true && (formats === null || formats === void 0 ? void 0 : formats.has(openlint_formats_1.oas2)) === true)) {
|
|
30
|
+
return Array.isArray(type) ? [...type, 'null'] : [type, 'null'];
|
|
31
|
+
}
|
|
32
|
+
return type;
|
|
33
|
+
}
|
|
34
|
+
exports.default = (0, openlint_core_1.createRulesetFunction)({
|
|
35
|
+
input: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
enum: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
},
|
|
41
|
+
type: {
|
|
42
|
+
oneOf: [
|
|
43
|
+
{
|
|
44
|
+
type: 'array',
|
|
45
|
+
items: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: 'string',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: ['enum', 'type'],
|
|
56
|
+
},
|
|
57
|
+
options: null,
|
|
58
|
+
}, function typedEnum(input, opts, context) {
|
|
59
|
+
const { enum: enumValues } = input;
|
|
60
|
+
const type = getTypes(input, context.document.formats);
|
|
61
|
+
const checkForInteger = type === 'integer' || (Array.isArray(type) && type.includes('integer'));
|
|
62
|
+
let results;
|
|
63
|
+
enumValues.forEach((value, i) => {
|
|
64
|
+
const valueType = getDataType(value, checkForInteger);
|
|
65
|
+
if (valueType === type || (Array.isArray(type) && type.includes(valueType))) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
results !== null && results !== void 0 ? results : (results = []);
|
|
69
|
+
results.push({
|
|
70
|
+
message: `Enum value ${(0, openlint_runtime_1.printValue)(enumValues[i])} must be "${String(type)}".`,
|
|
71
|
+
path: [...context.path, 'enum', i],
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return results;
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=typedEnum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedEnum.js","sourceRoot":"","sources":["../../../src/oas/functions/typedEnum.ts"],"names":[],"mappings":";;AAAA,iEAA0D;AAC1D,iEAAwD;AACxD,2DAA2F;AAG3F,SAAS,WAAW,CAClB,KAAc,EACd,eAAwB;IAExB,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,IAAI,CAAC;QACd,KAAK,QAAQ;YACX,IAAI,eAAe,IAAI,MA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
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllOperations = getAllOperations;
|
|
4
|
+
const json_1 = require("@stoplight/json");
|
|
5
|
+
const validOperationKeys = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'];
|
|
6
|
+
function* getAllOperations(paths) {
|
|
7
|
+
if (!(0, json_1.isPlainObject)(paths)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const item = {
|
|
11
|
+
path: '',
|
|
12
|
+
operation: '',
|
|
13
|
+
value: null,
|
|
14
|
+
};
|
|
15
|
+
for (const path of Object.keys(paths)) {
|
|
16
|
+
const operations = paths[path];
|
|
17
|
+
if (!(0, json_1.isPlainObject)(operations)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
item.path = path;
|
|
21
|
+
for (const operation of Object.keys(operations)) {
|
|
22
|
+
if (!(0, json_1.isPlainObject)(operations[operation]) || !validOperationKeys.includes(operation)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
item.operation = operation;
|
|
26
|
+
item.value = operations[operation];
|
|
27
|
+
yield item;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=getAllOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllOperations.js","sourceRoot":"","sources":["../../../../src/oas/functions/utils/getAllOperations.ts"],"names":[],"mappings":";;AAMA,4CA8BC;AApCD,0CAAgD;AAEhD,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAIjG,QAAe,CAAC,CAAC,gBAAgB,CAAC,KAAc;IAC9C,IAAI,CAAC,IAAA,oBAAa,EAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,MAAM,IAAI,GAAS;QAC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