api-quality-spectral-ruleset 1.1.1 → 1.2.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/apq-spectral.yaml +168 -97
- package/functions/apq-alternate-paths.js +2 -1
- package/functions/apq-binary-format-check.js +39 -0
- package/functions/apq-check-ambiguous-path.js +52 -0
- package/functions/apq-check-examples-coverage.js +12 -0
- package/functions/apq-compare-insensitive.js +110 -13
- package/functions/apq-has-filter-query-param.js +26 -0
- package/functions/apq-paged-response-check.js +124 -0
- package/functions/apq-password-format.js +35 -0
- package/functions/apq-path-depth.js +20 -0
- package/functions/apq-path-param-query-conflict.js +54 -0
- package/functions/apq-resources-by-verb.js +1 -1
- package/functions/apq-response-headers.js +3 -2
- package/functions/apq-response-media-type.js +43 -0
- package/functions/apq-security-required-response.js +46 -0
- package/functions/apq-standard-response-codes.js +4 -1
- package/functions/apq-status-endpoint-check.js +32 -0
- package/package.json +1 -1
- package/functions/apq-default-value.js +0 -23
- package/functions/apq-naming-convention.js +0 -21
- package/functions/apq-properties-schema-format.js +0 -29
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const { pattern } = require("@stoplight/spectral-functions");
|
|
2
|
-
|
|
3
|
-
const patterns = {
|
|
4
|
-
kebabCase: /^(\/|[a-z0-9-.]+|{[a-zA-Z0-9_]+})+$/,
|
|
5
|
-
camelCase: /^[a-z]+([A-Z][a-z0-9]+)*$/,
|
|
6
|
-
snakeCase: /^[a-z]+(_[a-z0-9]+)*$/,
|
|
7
|
-
pascalCase: /^[A-Z]+([A-Z][a-z0-9]+)*$/
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {object} given
|
|
12
|
-
* @param {object} options
|
|
13
|
-
* @param {string} options.pattern
|
|
14
|
-
* @param {import('@stoplight/spectral-core').RulesetFunctionContext} context
|
|
15
|
-
*/
|
|
16
|
-
module.exports = (given, options, context) => {
|
|
17
|
-
const errors = [];
|
|
18
|
-
if (!given) return errors;
|
|
19
|
-
|
|
20
|
-
return pattern(given, { match: patterns[options.pattern] }, context);
|
|
21
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Check that format is valid for a schema type.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {object} given
|
|
5
|
-
* @param {object} options
|
|
6
|
-
* @param {Array<string>} options.formats
|
|
7
|
-
* @param {Array<string>} options.properties
|
|
8
|
-
* @param {import('@stoplight/spectral-core').RulesetFunctionContext} context
|
|
9
|
-
*/
|
|
10
|
-
module.exports = function checkTypeAndFormat(given, options, context) {
|
|
11
|
-
if (given === null || typeof given !== "object") {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const errors = [];
|
|
16
|
-
const path = context.path || [];
|
|
17
|
-
const name = path.slice(-1)[0].toString();
|
|
18
|
-
|
|
19
|
-
if (options.properties.includes(name)) {
|
|
20
|
-
if (!given.format || !options.formats.includes(given.format)) {
|
|
21
|
-
errors.push({
|
|
22
|
-
message: context.rule.message,
|
|
23
|
-
path: [...path, name]
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return errors;
|
|
29
|
-
};
|