@redocly/openapi-core 1.30.0 → 1.31.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/CHANGELOG.md +6 -4
- package/lib/config/all.js +1 -1
- package/lib/config/minimal.js +1 -1
- package/lib/config/recommended-strict.js +1 -1
- package/lib/config/recommended.js +1 -1
- package/lib/config/spec.js +1 -1
- package/lib/logger.d.ts +4 -1
- package/lib/logger.js +3 -2
- package/lib/rules/arazzo/index.js +3 -3
- package/lib/rules/arazzo/requestBody-replacements-unique.js +21 -16
- package/lib/rules/{spot → respect}/no-criteria-xpath.js +1 -1
- package/lib/rules/respect/respect-supported-versions.d.ts +2 -0
- package/lib/rules/{spot/spot-supported-versions.js → respect/respect-supported-versions.js} +6 -6
- package/lib/types/redocly-yaml.d.ts +1 -1
- package/lib/types/redocly-yaml.js +1 -1
- package/lib/typings/arazzo.d.ts +1 -1
- package/lib/typings/arazzo.js +2 -2
- package/package.json +2 -1
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +2 -2
- package/src/config/all.ts +1 -1
- package/src/config/minimal.ts +1 -1
- package/src/config/recommended-strict.ts +1 -1
- package/src/config/recommended.ts +1 -1
- package/src/config/spec.ts +1 -1
- package/src/logger.ts +3 -1
- package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +2 -2
- package/src/rules/arazzo/__tests__/{spot-supported-versions.test.ts → respect-supported-versions.test.ts} +5 -5
- package/src/rules/arazzo/index.ts +3 -3
- package/src/rules/arazzo/requestBody-replacements-unique.ts +20 -15
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +2 -0
- package/src/rules/{spot → respect}/no-criteria-xpath.ts +1 -1
- package/src/rules/{spot/spot-supported-versions.ts → respect/respect-supported-versions.ts} +6 -6
- package/src/types/redocly-yaml.ts +1 -1
- package/src/typings/arazzo.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/spot/spot-supported-versions.d.ts +0 -2
- /package/lib/rules/{spot → respect}/no-criteria-xpath.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @redocly/openapi-core
|
|
2
2
|
|
|
3
|
+
## 1.31.0
|
|
4
|
+
|
|
3
5
|
## 1.30.0
|
|
4
6
|
|
|
5
7
|
### Patch Changes
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
|
|
33
35
|
### Patch Changes
|
|
34
36
|
|
|
35
|
-
- Added support for Arazzo version 1.0.1 in
|
|
37
|
+
- Added support for Arazzo version 1.0.1 in Respect validation rules.
|
|
36
38
|
|
|
37
39
|
## 1.28.1
|
|
38
40
|
|
|
@@ -73,13 +75,13 @@
|
|
|
73
75
|
|
|
74
76
|
### Patch Changes
|
|
75
77
|
|
|
76
|
-
- Updated
|
|
78
|
+
- Updated Respect validation rules.
|
|
77
79
|
|
|
78
80
|
## 1.26.1
|
|
79
81
|
|
|
80
82
|
### Patch Changes
|
|
81
83
|
|
|
82
|
-
- Removed the `no-actions-type-end`
|
|
84
|
+
- Removed the `no-actions-type-end` Respect rule.
|
|
83
85
|
- Removed unused lodash.isequal dependency.
|
|
84
86
|
|
|
85
87
|
## 1.26.0
|
|
@@ -202,7 +204,7 @@
|
|
|
202
204
|
|
|
203
205
|
### Minor Changes
|
|
204
206
|
|
|
205
|
-
- Added
|
|
207
|
+
- Added Respect and Arazzo rules: `no-criteria-xpath`, `no-actions-type-end`, `criteria-unique`.
|
|
206
208
|
|
|
207
209
|
### Patch Changes
|
|
208
210
|
|
package/lib/config/all.js
CHANGED
|
@@ -222,7 +222,7 @@ const all = {
|
|
|
222
222
|
'stepId-unique': 'error',
|
|
223
223
|
'sourceDescription-name-unique': 'error',
|
|
224
224
|
'sourceDescriptions-not-empty': 'error',
|
|
225
|
-
'
|
|
225
|
+
'respect-supported-versions': 'off',
|
|
226
226
|
'workflowId-unique': 'error',
|
|
227
227
|
'workflow-dependsOn': 'error',
|
|
228
228
|
},
|
package/lib/config/minimal.js
CHANGED
|
@@ -198,7 +198,7 @@ const minimal = {
|
|
|
198
198
|
'step-onFailure-unique': 'off',
|
|
199
199
|
'stepId-unique': 'error',
|
|
200
200
|
'sourceDescription-name-unique': 'off',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'off',
|
|
204
204
|
},
|
|
@@ -198,7 +198,7 @@ const recommendedStrict = {
|
|
|
198
198
|
'stepId-unique': 'error',
|
|
199
199
|
'sourceDescription-name-unique': 'error',
|
|
200
200
|
'sourceDescriptions-not-empty': 'error',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'error',
|
|
204
204
|
},
|
|
@@ -198,7 +198,7 @@ const recommended = {
|
|
|
198
198
|
'stepId-unique': 'error',
|
|
199
199
|
'sourceDescription-name-unique': 'error',
|
|
200
200
|
'sourceDescriptions-not-empty': 'error',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'error',
|
|
204
204
|
},
|
package/lib/config/spec.js
CHANGED
|
@@ -12,7 +12,7 @@ const spec = {
|
|
|
12
12
|
async3Rules: {},
|
|
13
13
|
arazzo1Rules: {
|
|
14
14
|
'sourceDescription-type': 'error',
|
|
15
|
-
'
|
|
15
|
+
'respect-supported-versions': 'off',
|
|
16
16
|
'workflowId-unique': 'error',
|
|
17
17
|
'stepId-unique': 'error',
|
|
18
18
|
'sourceDescription-name-unique': 'error',
|
package/lib/logger.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as colorette from 'colorette';
|
|
2
|
-
export
|
|
2
|
+
export declare const colorOptions: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
};
|
|
3
5
|
export declare const colorize: typeof colorette;
|
|
4
6
|
declare class Logger {
|
|
5
7
|
protected stderr(str: string): boolean;
|
|
@@ -8,3 +10,4 @@ declare class Logger {
|
|
|
8
10
|
error(str: string): boolean | void;
|
|
9
11
|
}
|
|
10
12
|
export declare const logger: Logger;
|
|
13
|
+
export {};
|
package/lib/logger.js
CHANGED
|
@@ -4,8 +4,9 @@ exports.logger = exports.colorize = exports.colorOptions = void 0;
|
|
|
4
4
|
const colorette = require("colorette");
|
|
5
5
|
const env_1 = require("./env");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore this works but some types are not working
|
|
9
|
+
exports.colorOptions = colorette.options;
|
|
9
10
|
exports.colorize = new Proxy(colorette, {
|
|
10
11
|
get(target, prop) {
|
|
11
12
|
if (env_1.isBrowser) {
|
|
@@ -5,7 +5,7 @@ const struct_1 = require("../common/struct");
|
|
|
5
5
|
const assertions_1 = require("../common/assertions");
|
|
6
6
|
const sourceDescription_type_1 = require("../arazzo/sourceDescription-type");
|
|
7
7
|
const sourceDescriptions_not_empty_1 = require("./sourceDescriptions-not-empty");
|
|
8
|
-
const
|
|
8
|
+
const respect_supported_versions_1 = require("../respect/respect-supported-versions");
|
|
9
9
|
const workflowId_unique_1 = require("./workflowId-unique");
|
|
10
10
|
const stepId_unique_1 = require("./stepId-unique");
|
|
11
11
|
const sourceDescriptions_name_unique_1 = require("./sourceDescriptions-name-unique");
|
|
@@ -14,13 +14,13 @@ const parameters_unique_1 = require("./parameters-unique");
|
|
|
14
14
|
const step_onSuccess_unique_1 = require("./step-onSuccess-unique");
|
|
15
15
|
const step_onFailure_unique_1 = require("./step-onFailure-unique");
|
|
16
16
|
const requestBody_replacements_unique_1 = require("./requestBody-replacements-unique");
|
|
17
|
-
const no_criteria_xpath_1 = require("../
|
|
17
|
+
const no_criteria_xpath_1 = require("../respect/no-criteria-xpath");
|
|
18
18
|
const criteria_unique_1 = require("./criteria-unique");
|
|
19
19
|
exports.rules = {
|
|
20
20
|
struct: struct_1.Struct,
|
|
21
21
|
assertions: assertions_1.Assertions,
|
|
22
22
|
'sourceDescription-type': sourceDescription_type_1.SourceDescriptionType,
|
|
23
|
-
'
|
|
23
|
+
'respect-supported-versions': respect_supported_versions_1.RespectSupportedVersions,
|
|
24
24
|
'workflowId-unique': workflowId_unique_1.WorkflowIdUnique,
|
|
25
25
|
'stepId-unique': stepId_unique_1.StepIdUnique,
|
|
26
26
|
'sourceDescription-name-unique': sourceDescriptions_name_unique_1.SourceDescriptionsNameUnique,
|
|
@@ -4,23 +4,28 @@ exports.RequestBodyReplacementsUnique = void 0;
|
|
|
4
4
|
const RequestBodyReplacementsUnique = () => {
|
|
5
5
|
const seenReplacements = new Set();
|
|
6
6
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
Step: {
|
|
8
|
+
leave() {
|
|
9
|
+
seenReplacements.clear();
|
|
10
|
+
},
|
|
11
|
+
RequestBody: {
|
|
12
|
+
enter(requestBody, { report, location }) {
|
|
13
|
+
if (!requestBody.replacements)
|
|
14
|
+
return;
|
|
15
|
+
for (const replacement of requestBody.replacements) {
|
|
16
|
+
if (seenReplacements.has(replacement.target)) {
|
|
17
|
+
report({
|
|
18
|
+
message: 'Every `replacement` in `requestBody` must be unique.',
|
|
19
|
+
location: location.child([
|
|
20
|
+
'replacements',
|
|
21
|
+
requestBody.replacements.indexOf(replacement),
|
|
22
|
+
`target`,
|
|
23
|
+
]),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
seenReplacements.add(replacement.target);
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
}
|
|
28
|
+
},
|
|
24
29
|
},
|
|
25
30
|
},
|
|
26
31
|
};
|
|
@@ -10,7 +10,7 @@ const NoCriteriaXpath = () => {
|
|
|
10
10
|
}
|
|
11
11
|
if (criteria?.type?.type === 'xpath' || criteria?.type === 'xpath') {
|
|
12
12
|
report({
|
|
13
|
-
message: 'The `xpath` type criteria is not supported by
|
|
13
|
+
message: 'The `xpath` type criteria is not supported by Respect.',
|
|
14
14
|
location: location.child(['type']),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RespectSupportedVersions = void 0;
|
|
4
4
|
const arazzo_1 = require("../../typings/arazzo");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
|
-
const
|
|
7
|
-
const supportedVersions = arazzo_1.
|
|
6
|
+
const RespectSupportedVersions = () => {
|
|
7
|
+
const supportedVersions = arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.join(', ');
|
|
8
8
|
return {
|
|
9
9
|
Root: {
|
|
10
10
|
enter(root, { report, location }) {
|
|
11
|
-
if (!arazzo_1.
|
|
11
|
+
if (!arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.includes(root.arazzo)) {
|
|
12
12
|
report({
|
|
13
|
-
message: `Only ${supportedVersions} Arazzo ${(0, utils_1.pluralize)('version is', arazzo_1.
|
|
13
|
+
message: `Only ${supportedVersions} Arazzo ${(0, utils_1.pluralize)('version is', arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.length)} supported by Respect.`,
|
|
14
14
|
location: location.child('arazzo'),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -18,4 +18,4 @@ const SpotSupportedVersions = () => {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
21
|
+
exports.RespectSupportedVersions = RespectSupportedVersions;
|
|
@@ -9,7 +9,7 @@ declare const builtInAsync2Rules: readonly ["info-contact", "info-license-strict
|
|
|
9
9
|
declare const builtInAsync3Rules: readonly ["info-contact", "info-license-strict", "operation-operationId", "tag-description", "tags-alphabetical", "channels-kebab-case", "no-channel-trailing-slash"];
|
|
10
10
|
export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
|
|
11
11
|
export type BuiltInAsync3RuleId = typeof builtInAsync3Rules[number];
|
|
12
|
-
declare const builtInArazzo1Rules: readonly ["sourceDescription-type", "workflowId-unique", "stepId-unique", "sourceDescription-name-unique", "sourceDescriptions-not-empty", "workflow-dependsOn", "parameters-unique", "step-onSuccess-unique", "step-onFailure-unique", "
|
|
12
|
+
declare const builtInArazzo1Rules: readonly ["sourceDescription-type", "workflowId-unique", "stepId-unique", "sourceDescription-name-unique", "sourceDescriptions-not-empty", "workflow-dependsOn", "parameters-unique", "step-onSuccess-unique", "step-onFailure-unique", "respect-supported-versions", "requestBody-replacements-unique", "no-criteria-xpath", "criteria-unique"];
|
|
13
13
|
export type BuiltInArazzo1RuleId = typeof builtInArazzo1Rules[number];
|
|
14
14
|
declare const oas2NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "ParameterItems", "Operation", "Example", "ExamplesMap", "Examples", "Header", "Responses", "Response", "Schema", "Xml", "SchemaProperties", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedSecuritySchemes", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XServer", "XServerList"];
|
|
15
15
|
export type Oas2NodeType = typeof oas2NodeTypesList[number];
|
|
@@ -139,7 +139,7 @@ const builtInArazzo1Rules = [
|
|
|
139
139
|
'parameters-unique',
|
|
140
140
|
'step-onSuccess-unique',
|
|
141
141
|
'step-onFailure-unique',
|
|
142
|
-
'
|
|
142
|
+
'respect-supported-versions',
|
|
143
143
|
'requestBody-replacements-unique',
|
|
144
144
|
'no-criteria-xpath',
|
|
145
145
|
'criteria-unique',
|
package/lib/typings/arazzo.d.ts
CHANGED
package/lib/typings/arazzo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = exports.VERSION_PATTERN = void 0;
|
|
4
4
|
exports.VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;
|
|
5
|
-
exports.
|
|
5
|
+
exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = ['1.0.1'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"OpenAPI linter",
|
|
29
29
|
"Swagger linter",
|
|
30
30
|
"AsyncAPI linter",
|
|
31
|
+
"Arazzo linter",
|
|
31
32
|
"oas"
|
|
32
33
|
],
|
|
33
34
|
"contributors": [
|
|
@@ -9,10 +9,10 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
|
|
|
9
9
|
"no-criteria-xpath": "off",
|
|
10
10
|
"parameters-unique": "error",
|
|
11
11
|
"requestBody-replacements-unique": "warn",
|
|
12
|
+
"respect-supported-versions": "off",
|
|
12
13
|
"sourceDescription-name-unique": "error",
|
|
13
14
|
"sourceDescription-type": "error",
|
|
14
15
|
"sourceDescriptions-not-empty": "error",
|
|
15
|
-
"spot-supported-versions": "off",
|
|
16
16
|
"step-onFailure-unique": "warn",
|
|
17
17
|
"step-onSuccess-unique": "warn",
|
|
18
18
|
"stepId-unique": "error",
|
|
@@ -238,10 +238,10 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
|
|
|
238
238
|
"no-criteria-xpath": "off",
|
|
239
239
|
"parameters-unique": "error",
|
|
240
240
|
"requestBody-replacements-unique": "warn",
|
|
241
|
+
"respect-supported-versions": "off",
|
|
241
242
|
"sourceDescription-name-unique": "error",
|
|
242
243
|
"sourceDescription-type": "error",
|
|
243
244
|
"sourceDescriptions-not-empty": "error",
|
|
244
|
-
"spot-supported-versions": "off",
|
|
245
245
|
"step-onFailure-unique": "warn",
|
|
246
246
|
"step-onSuccess-unique": "warn",
|
|
247
247
|
"stepId-unique": "error",
|
package/src/config/all.ts
CHANGED
|
@@ -222,7 +222,7 @@ const all: PluginStyleguideConfig<'built-in'> = {
|
|
|
222
222
|
'stepId-unique': 'error',
|
|
223
223
|
'sourceDescription-name-unique': 'error',
|
|
224
224
|
'sourceDescriptions-not-empty': 'error',
|
|
225
|
-
'
|
|
225
|
+
'respect-supported-versions': 'off',
|
|
226
226
|
'workflowId-unique': 'error',
|
|
227
227
|
'workflow-dependsOn': 'error',
|
|
228
228
|
},
|
package/src/config/minimal.ts
CHANGED
|
@@ -198,7 +198,7 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
|
|
|
198
198
|
'step-onFailure-unique': 'off',
|
|
199
199
|
'stepId-unique': 'error',
|
|
200
200
|
'sourceDescription-name-unique': 'off',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'off',
|
|
204
204
|
},
|
|
@@ -198,7 +198,7 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
|
|
|
198
198
|
'stepId-unique': 'error',
|
|
199
199
|
'sourceDescription-name-unique': 'error',
|
|
200
200
|
'sourceDescriptions-not-empty': 'error',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'error',
|
|
204
204
|
},
|
|
@@ -198,7 +198,7 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
|
|
|
198
198
|
'stepId-unique': 'error',
|
|
199
199
|
'sourceDescription-name-unique': 'error',
|
|
200
200
|
'sourceDescriptions-not-empty': 'error',
|
|
201
|
-
'
|
|
201
|
+
'respect-supported-versions': 'off',
|
|
202
202
|
'workflowId-unique': 'error',
|
|
203
203
|
'workflow-dependsOn': 'error',
|
|
204
204
|
},
|
package/src/config/spec.ts
CHANGED
|
@@ -12,7 +12,7 @@ const spec: PluginStyleguideConfig<'built-in'> = {
|
|
|
12
12
|
async3Rules: {},
|
|
13
13
|
arazzo1Rules: {
|
|
14
14
|
'sourceDescription-type': 'error',
|
|
15
|
-
'
|
|
15
|
+
'respect-supported-versions': 'off',
|
|
16
16
|
'workflowId-unique': 'error',
|
|
17
17
|
'stepId-unique': 'error',
|
|
18
18
|
'sourceDescription-name-unique': 'error',
|
package/src/logger.ts
CHANGED
|
@@ -2,7 +2,9 @@ import * as colorette from 'colorette';
|
|
|
2
2
|
import { isBrowser } from './env';
|
|
3
3
|
import { identity } from './utils';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore this works but some types are not working
|
|
7
|
+
export const colorOptions = colorette.options;
|
|
6
8
|
|
|
7
9
|
export const colorize = new Proxy(colorette, {
|
|
8
10
|
get(target: typeof colorette, prop: string): typeof identity {
|
|
@@ -90,7 +90,7 @@ describe('Arazzo no-criteria-xpath', () => {
|
|
|
90
90
|
"source": "arazzo.yaml",
|
|
91
91
|
},
|
|
92
92
|
],
|
|
93
|
-
"message": "The \`xpath\` type criteria is not supported by
|
|
93
|
+
"message": "The \`xpath\` type criteria is not supported by Respect.",
|
|
94
94
|
"ruleId": "no-criteria-xpath",
|
|
95
95
|
"severity": "error",
|
|
96
96
|
"suggest": [],
|
|
@@ -103,7 +103,7 @@ describe('Arazzo no-criteria-xpath', () => {
|
|
|
103
103
|
"source": "arazzo.yaml",
|
|
104
104
|
},
|
|
105
105
|
],
|
|
106
|
-
"message": "The \`xpath\` type criteria is not supported by
|
|
106
|
+
"message": "The \`xpath\` type criteria is not supported by Respect.",
|
|
107
107
|
"ruleId": "no-criteria-xpath",
|
|
108
108
|
"severity": "error",
|
|
109
109
|
"suggest": [],
|
|
@@ -3,7 +3,7 @@ import { lintDocument } from '../../../lint';
|
|
|
3
3
|
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
5
|
|
|
6
|
-
describe('Arazzo
|
|
6
|
+
describe('Arazzo respect-supported-versions', () => {
|
|
7
7
|
const documentWithUnsupportedVersion = parseYamlToDocument(
|
|
8
8
|
outdent`
|
|
9
9
|
arazzo: '1.0.2'
|
|
@@ -67,7 +67,7 @@ describe('Arazzo spot-supported-versions', () => {
|
|
|
67
67
|
externalRefResolver: new BaseResolver(),
|
|
68
68
|
document: documentWithUnsupportedVersion,
|
|
69
69
|
config: await makeConfig({
|
|
70
|
-
rules: { '
|
|
70
|
+
rules: { 'respect-supported-versions': 'error' },
|
|
71
71
|
}),
|
|
72
72
|
});
|
|
73
73
|
|
|
@@ -81,8 +81,8 @@ describe('Arazzo spot-supported-versions', () => {
|
|
|
81
81
|
"source": "arazzo.yaml",
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
|
-
"message": "Only 1.0.1 Arazzo version is supported by
|
|
85
|
-
"ruleId": "
|
|
84
|
+
"message": "Only 1.0.1 Arazzo version is supported by Respect.",
|
|
85
|
+
"ruleId": "respect-supported-versions",
|
|
86
86
|
"severity": "error",
|
|
87
87
|
"suggest": [],
|
|
88
88
|
},
|
|
@@ -95,7 +95,7 @@ describe('Arazzo spot-supported-versions', () => {
|
|
|
95
95
|
externalRefResolver: new BaseResolver(),
|
|
96
96
|
document: documentWithSupportedVersion,
|
|
97
97
|
config: await makeConfig({
|
|
98
|
-
rules: { '
|
|
98
|
+
rules: { 'respect-supported-versions': 'error' },
|
|
99
99
|
}),
|
|
100
100
|
});
|
|
101
101
|
|
|
@@ -2,7 +2,7 @@ import { Struct } from '../common/struct';
|
|
|
2
2
|
import { Assertions } from '../common/assertions';
|
|
3
3
|
import { SourceDescriptionType } from '../arazzo/sourceDescription-type';
|
|
4
4
|
import { SourceDescriptionsNotEmpty } from './sourceDescriptions-not-empty';
|
|
5
|
-
import {
|
|
5
|
+
import { RespectSupportedVersions } from '../respect/respect-supported-versions';
|
|
6
6
|
import { WorkflowIdUnique } from './workflowId-unique';
|
|
7
7
|
import { StepIdUnique } from './stepId-unique';
|
|
8
8
|
import { SourceDescriptionsNameUnique } from './sourceDescriptions-name-unique';
|
|
@@ -11,7 +11,7 @@ import { ParametersUnique } from './parameters-unique';
|
|
|
11
11
|
import { StepOnSuccessUnique } from './step-onSuccess-unique';
|
|
12
12
|
import { StepOnFailureUnique } from './step-onFailure-unique';
|
|
13
13
|
import { RequestBodyReplacementsUnique } from './requestBody-replacements-unique';
|
|
14
|
-
import { NoCriteriaXpath } from '../
|
|
14
|
+
import { NoCriteriaXpath } from '../respect/no-criteria-xpath';
|
|
15
15
|
import { CriteriaUnique } from './criteria-unique';
|
|
16
16
|
|
|
17
17
|
import type { Arazzo1Rule } from '../../visitors';
|
|
@@ -21,7 +21,7 @@ export const rules: Arazzo1RuleSet<'built-in'> = {
|
|
|
21
21
|
struct: Struct as Arazzo1Rule,
|
|
22
22
|
assertions: Assertions as Arazzo1Rule,
|
|
23
23
|
'sourceDescription-type': SourceDescriptionType,
|
|
24
|
-
'
|
|
24
|
+
'respect-supported-versions': RespectSupportedVersions,
|
|
25
25
|
'workflowId-unique': WorkflowIdUnique,
|
|
26
26
|
'stepId-unique': StepIdUnique,
|
|
27
27
|
'sourceDescription-name-unique': SourceDescriptionsNameUnique,
|
|
@@ -5,23 +5,28 @@ export const RequestBodyReplacementsUnique: Arazzo1Rule = () => {
|
|
|
5
5
|
const seenReplacements = new Set();
|
|
6
6
|
|
|
7
7
|
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
Step: {
|
|
9
|
+
leave() {
|
|
10
|
+
seenReplacements.clear();
|
|
11
|
+
},
|
|
12
|
+
RequestBody: {
|
|
13
|
+
enter(requestBody, { report, location }: UserContext) {
|
|
14
|
+
if (!requestBody.replacements) return;
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
for (const replacement of requestBody.replacements) {
|
|
17
|
+
if (seenReplacements.has(replacement.target)) {
|
|
18
|
+
report({
|
|
19
|
+
message: 'Every `replacement` in `requestBody` must be unique.',
|
|
20
|
+
location: location.child([
|
|
21
|
+
'replacements',
|
|
22
|
+
requestBody.replacements.indexOf(replacement),
|
|
23
|
+
`target`,
|
|
24
|
+
]),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
seenReplacements.add(replacement.target);
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
}
|
|
29
|
+
},
|
|
25
30
|
},
|
|
26
31
|
},
|
|
27
32
|
};
|
|
@@ -3,6 +3,8 @@ import { lintDocument } from '../../../lint';
|
|
|
3
3
|
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
5
|
|
|
6
|
+
jest.setTimeout(10000);
|
|
7
|
+
|
|
6
8
|
describe('no-invalid-media-type-examples', () => {
|
|
7
9
|
it('should report on invalid example', async () => {
|
|
8
10
|
const document = parseYamlToDocument(
|
|
@@ -10,7 +10,7 @@ export const NoCriteriaXpath: Arazzo1Rule = () => {
|
|
|
10
10
|
}
|
|
11
11
|
if (criteria?.type?.type === 'xpath' || criteria?.type === 'xpath') {
|
|
12
12
|
report({
|
|
13
|
-
message: 'The `xpath` type criteria is not supported by
|
|
13
|
+
message: 'The `xpath` type criteria is not supported by Respect.',
|
|
14
14
|
location: location.child(['type']),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT } from '../../typings/arazzo';
|
|
2
2
|
import { pluralize } from '../../utils';
|
|
3
3
|
|
|
4
4
|
import type { Arazzo1Rule } from '../../visitors';
|
|
5
5
|
import type { UserContext } from '../../walk';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
const supportedVersions =
|
|
7
|
+
export const RespectSupportedVersions: Arazzo1Rule = () => {
|
|
8
|
+
const supportedVersions = ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.join(', ');
|
|
9
9
|
return {
|
|
10
10
|
Root: {
|
|
11
11
|
enter(root, { report, location }: UserContext) {
|
|
12
|
-
if (!
|
|
12
|
+
if (!ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.includes(root.arazzo)) {
|
|
13
13
|
report({
|
|
14
14
|
message: `Only ${supportedVersions} Arazzo ${pluralize(
|
|
15
15
|
'version is',
|
|
16
|
-
|
|
17
|
-
)} supported by
|
|
16
|
+
ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.length
|
|
17
|
+
)} supported by Respect.`,
|
|
18
18
|
location: location.child('arazzo'),
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -152,7 +152,7 @@ const builtInArazzo1Rules = [
|
|
|
152
152
|
'parameters-unique',
|
|
153
153
|
'step-onSuccess-unique',
|
|
154
154
|
'step-onFailure-unique',
|
|
155
|
-
'
|
|
155
|
+
'respect-supported-versions',
|
|
156
156
|
'requestBody-replacements-unique',
|
|
157
157
|
'no-criteria-xpath',
|
|
158
158
|
'criteria-unique',
|
package/src/typings/arazzo.ts
CHANGED