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.
@@ -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
- };