@redocly/openapi-core 1.25.15 → 1.26.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 +11 -0
- package/__tests__/utils.ts +0 -3
- package/lib/bundle.js +3 -3
- package/lib/config/all.js +130 -48
- package/lib/config/builtIn.d.ts +1 -1
- package/lib/config/builtIn.js +5 -3
- package/lib/config/config-resolvers.js +9 -9
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +38 -20
- package/lib/config/minimal.js +125 -49
- package/lib/config/recommended-strict.js +124 -48
- package/lib/config/recommended.js +123 -47
- package/lib/config/rules.d.ts +2 -2
- package/lib/config/spec.d.ts +3 -0
- package/lib/config/spec.js +31 -0
- package/lib/config/types.d.ts +23 -23
- package/lib/config/utils.d.ts +1 -1
- package/lib/config/utils.js +33 -23
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/lint.js +3 -3
- package/lib/oas-types.d.ts +11 -11
- package/lib/oas-types.js +6 -6
- package/lib/rules/arazzo/criteria-unique.d.ts +2 -2
- package/lib/rules/arazzo/index.d.ts +2 -2
- package/lib/rules/arazzo/index.js +6 -4
- package/lib/rules/arazzo/parameters-unique.d.ts +2 -2
- package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -2
- package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -0
- package/lib/rules/arazzo/{source-description-type.js → sourceDescription-type.js} +5 -3
- package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -2
- package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.js +18 -0
- package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -2
- package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -2
- package/lib/rules/arazzo/stepId-unique.d.ts +2 -2
- package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -2
- package/lib/rules/arazzo/workflowId-unique.d.ts +2 -2
- package/lib/rules/async2/index.js +5 -2
- package/lib/rules/async3/index.js +5 -2
- package/lib/rules/common/assertions/index.d.ts +2 -2
- package/lib/rules/common/struct.d.ts +2 -0
- package/lib/rules/common/{spec.js → struct.js} +3 -3
- package/lib/rules/oas2/index.js +5 -2
- package/lib/rules/oas3/index.js +5 -2
- package/lib/rules/spot/no-actions-type-end.d.ts +2 -2
- package/lib/rules/spot/no-criteria-xpath.d.ts +2 -2
- package/lib/rules/spot/parameters-not-in-body.d.ts +2 -2
- package/lib/rules/spot/version-enum.d.ts +2 -2
- package/lib/types/arazzo.d.ts +1 -1
- package/lib/types/arazzo.js +3 -16
- package/lib/types/redocly-yaml.d.ts +6 -8
- package/lib/types/redocly-yaml.js +47 -12
- package/lib/typings/arazzo.d.ts +1 -6
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +3 -2
- package/lib/visitors.d.ts +5 -6
- package/package.json +1 -1
- package/src/__tests__/lint.test.ts +3 -3
- package/src/bundle.ts +3 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +228 -70
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +16 -3
- package/src/config/__tests__/config-resolvers.test.ts +14 -2
- package/src/config/__tests__/config.test.ts +11 -6
- package/src/config/all.ts +130 -48
- package/src/config/builtIn.ts +10 -8
- package/src/config/config-resolvers.ts +9 -9
- package/src/config/config.ts +46 -22
- package/src/config/minimal.ts +125 -49
- package/src/config/recommended-strict.ts +124 -48
- package/src/config/recommended.ts +123 -47
- package/src/config/rules.ts +2 -2
- package/src/config/spec.ts +32 -0
- package/src/config/types.ts +27 -33
- package/src/config/utils.ts +38 -26
- package/src/index.ts +1 -1
- package/src/lint.ts +6 -6
- package/src/oas-types.ts +19 -20
- package/src/rules/arazzo/__tests__/criteria-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/no-actions-type-end.test.ts +1 -2
- package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +1 -2
- package/src/rules/arazzo/__tests__/parameters-not-in-body.test.ts +1 -2
- package/src/rules/arazzo/__tests__/parameters-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/requestBody-replacements-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/source-description-type.test.ts +2 -4
- package/src/rules/arazzo/__tests__/sourceDescription-name-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/sourceDescriptions-not-empty.test.ts +104 -0
- package/src/rules/arazzo/__tests__/step-onFailure-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/step-onSuccess-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/stepId-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/version-enum.test.ts +1 -2
- package/src/rules/arazzo/__tests__/workflow-dependsOn.test.ts +3 -6
- package/src/rules/arazzo/__tests__/workflowId-unique.test.ts +2 -4
- package/src/rules/arazzo/criteria-unique.ts +2 -2
- package/src/rules/arazzo/index.ts +23 -21
- package/src/rules/arazzo/parameters-unique.ts +2 -2
- package/src/rules/arazzo/requestBody-replacements-unique.ts +2 -2
- package/src/rules/arazzo/{source-description-type.ts → sourceDescription-type.ts} +6 -5
- package/src/rules/arazzo/sourceDescriptions-name-unique.ts +2 -2
- package/src/rules/arazzo/sourceDescriptions-not-empty.ts +17 -0
- package/src/rules/arazzo/step-onFailure-unique.ts +2 -2
- package/src/rules/arazzo/step-onSuccess-unique.ts +2 -2
- package/src/rules/arazzo/stepId-unique.ts +2 -2
- package/src/rules/arazzo/workflow-dependsOn.ts +2 -2
- package/src/rules/arazzo/workflowId-unique.ts +2 -2
- package/src/rules/async2/index.ts +5 -2
- package/src/rules/async3/index.ts +5 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -1
- package/src/rules/common/__tests__/{spec.test.ts → struct.test.ts} +35 -35
- package/src/rules/common/assertions/index.ts +2 -2
- package/src/rules/common/{spec.ts → struct.ts} +2 -2
- package/src/rules/oas2/index.ts +5 -2
- package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -10
- package/src/rules/oas3/index.ts +5 -2
- package/src/rules/spot/no-actions-type-end.ts +2 -2
- package/src/rules/spot/no-criteria-xpath.ts +2 -2
- package/src/rules/spot/parameters-not-in-body.ts +2 -2
- package/src/rules/spot/version-enum.ts +2 -2
- package/src/types/arazzo.ts +2 -14
- package/src/types/redocly-yaml.ts +48 -16
- package/src/typings/arazzo.ts +1 -10
- package/src/utils.ts +4 -2
- package/src/visitors.ts +4 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/arazzo/source-description-type.d.ts +0 -2
- package/lib/rules/common/spec.d.ts +0 -2
package/src/oas-types.ts
CHANGED
|
@@ -3,15 +3,14 @@ import { Oas3Types } from './types/oas3';
|
|
|
3
3
|
import { Oas3_1Types } from './types/oas3_1';
|
|
4
4
|
import { AsyncApi2Types } from './types/asyncapi2';
|
|
5
5
|
import { AsyncApi3Types } from './types/asyncapi3';
|
|
6
|
-
import {
|
|
6
|
+
import { Arazzo1Types } from './types/arazzo';
|
|
7
7
|
import { isPlainObject } from './utils';
|
|
8
8
|
import { VERSION_PATTERN } from './typings/arazzo';
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
11
|
BuiltInAsync2RuleId,
|
|
12
12
|
BuiltInAsync3RuleId,
|
|
13
|
-
|
|
14
|
-
BuiltInArazzoRuleId,
|
|
13
|
+
BuiltInArazzo1RuleId,
|
|
15
14
|
BuiltInOAS2RuleId,
|
|
16
15
|
BuiltInOAS3RuleId,
|
|
17
16
|
} from './types/redocly-yaml';
|
|
@@ -24,8 +23,8 @@ import type {
|
|
|
24
23
|
Async2Rule,
|
|
25
24
|
Async3Preprocessor,
|
|
26
25
|
Async3Rule,
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Arazzo1Preprocessor,
|
|
27
|
+
Arazzo1Rule,
|
|
29
28
|
} from './visitors';
|
|
30
29
|
|
|
31
30
|
export enum SpecVersion {
|
|
@@ -34,7 +33,7 @@ export enum SpecVersion {
|
|
|
34
33
|
OAS3_1 = 'oas3_1',
|
|
35
34
|
Async2 = 'async2',
|
|
36
35
|
Async3 = 'async3',
|
|
37
|
-
|
|
36
|
+
Arazzo1 = 'arazzo1',
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export enum SpecMajorVersion {
|
|
@@ -42,7 +41,7 @@ export enum SpecMajorVersion {
|
|
|
42
41
|
OAS3 = 'oas3',
|
|
43
42
|
Async2 = 'async2',
|
|
44
43
|
Async3 = 'async3',
|
|
45
|
-
|
|
44
|
+
Arazzo1 = 'arazzo1',
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const typesMap = {
|
|
@@ -51,7 +50,7 @@ const typesMap = {
|
|
|
51
50
|
[SpecVersion.OAS3_1]: Oas3_1Types,
|
|
52
51
|
[SpecVersion.Async2]: AsyncApi2Types,
|
|
53
52
|
[SpecVersion.Async3]: AsyncApi3Types,
|
|
54
|
-
[SpecVersion.
|
|
53
|
+
[SpecVersion.Arazzo1]: Arazzo1Types,
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
export type RuleMap<Key extends string, RuleConfig, T> = Record<
|
|
@@ -59,28 +58,28 @@ export type RuleMap<Key extends string, RuleConfig, T> = Record<
|
|
|
59
58
|
RuleConfig
|
|
60
59
|
>;
|
|
61
60
|
export type Oas3RuleSet<T = undefined> = RuleMap<
|
|
62
|
-
|
|
61
|
+
BuiltInOAS3RuleId | 'struct' | 'assertions',
|
|
63
62
|
Oas3Rule,
|
|
64
63
|
T
|
|
65
64
|
>;
|
|
66
65
|
export type Oas2RuleSet<T = undefined> = RuleMap<
|
|
67
|
-
|
|
66
|
+
BuiltInOAS2RuleId | 'struct' | 'assertions',
|
|
68
67
|
Oas2Rule,
|
|
69
68
|
T
|
|
70
69
|
>;
|
|
71
70
|
export type Async2RuleSet<T = undefined> = RuleMap<
|
|
72
|
-
BuiltInAsync2RuleId | 'assertions',
|
|
71
|
+
BuiltInAsync2RuleId | 'struct' | 'assertions',
|
|
73
72
|
Async2Rule,
|
|
74
73
|
T
|
|
75
74
|
>;
|
|
76
75
|
export type Async3RuleSet<T = undefined> = RuleMap<
|
|
77
|
-
BuiltInAsync3RuleId | 'assertions',
|
|
76
|
+
BuiltInAsync3RuleId | 'struct' | 'assertions',
|
|
78
77
|
Async3Rule,
|
|
79
78
|
T
|
|
80
79
|
>;
|
|
81
|
-
export type
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
export type Arazzo1RuleSet<T = undefined> = RuleMap<
|
|
81
|
+
BuiltInArazzo1RuleId | 'struct' | 'assertions',
|
|
82
|
+
Arazzo1Rule,
|
|
84
83
|
T
|
|
85
84
|
>;
|
|
86
85
|
|
|
@@ -88,13 +87,13 @@ export type Oas3PreprocessorsSet = Record<string, Oas3Preprocessor>;
|
|
|
88
87
|
export type Oas2PreprocessorsSet = Record<string, Oas2Preprocessor>;
|
|
89
88
|
export type Async2PreprocessorsSet = Record<string, Async2Preprocessor>;
|
|
90
89
|
export type Async3PreprocessorsSet = Record<string, Async3Preprocessor>;
|
|
91
|
-
export type
|
|
90
|
+
export type Arazzo1PreprocessorsSet = Record<string, Arazzo1Preprocessor>;
|
|
92
91
|
|
|
93
92
|
export type Oas3DecoratorsSet = Record<string, Oas3Preprocessor>;
|
|
94
93
|
export type Oas2DecoratorsSet = Record<string, Oas2Preprocessor>;
|
|
95
94
|
export type Async2DecoratorsSet = Record<string, Async2Preprocessor>;
|
|
96
95
|
export type Async3DecoratorsSet = Record<string, Async3Preprocessor>;
|
|
97
|
-
export type
|
|
96
|
+
export type Arazzo1DecoratorsSet = Record<string, Arazzo1Preprocessor>;
|
|
98
97
|
|
|
99
98
|
export function detectSpec(root: unknown): SpecVersion {
|
|
100
99
|
if (!isPlainObject(root)) {
|
|
@@ -134,7 +133,7 @@ export function detectSpec(root: unknown): SpecVersion {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
if (typeof root.arazzo === 'string' && VERSION_PATTERN.test(root.arazzo)) {
|
|
137
|
-
return SpecVersion.
|
|
136
|
+
return SpecVersion.Arazzo1;
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
throw new Error(`Unsupported specification`);
|
|
@@ -147,8 +146,8 @@ export function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion {
|
|
|
147
146
|
return SpecMajorVersion.Async2;
|
|
148
147
|
} else if (version === SpecVersion.Async3) {
|
|
149
148
|
return SpecMajorVersion.Async3;
|
|
150
|
-
} else if (version === SpecVersion.
|
|
151
|
-
return SpecMajorVersion.
|
|
149
|
+
} else if (version === SpecVersion.Arazzo1) {
|
|
150
|
+
return SpecMajorVersion.Arazzo1;
|
|
152
151
|
} else {
|
|
153
152
|
return SpecMajorVersion.OAS3;
|
|
154
153
|
}
|
|
@@ -71,8 +71,7 @@ describe('Arazzo no-actions-type-end', () => {
|
|
|
71
71
|
externalRefResolver: new BaseResolver(),
|
|
72
72
|
document,
|
|
73
73
|
config: await makeConfig({
|
|
74
|
-
rules: {},
|
|
75
|
-
arazzoRules: { 'no-actions-type-end': 'error' },
|
|
74
|
+
rules: { 'no-actions-type-end': 'error' },
|
|
76
75
|
}),
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -48,8 +48,7 @@ describe('Spot parameters-not-in-body', () => {
|
|
|
48
48
|
externalRefResolver: new BaseResolver(),
|
|
49
49
|
document,
|
|
50
50
|
config: await makeConfig({
|
|
51
|
-
rules: {},
|
|
52
|
-
arazzoRules: { 'parameters-not-in-body': 'error' },
|
|
51
|
+
rules: { 'parameters-not-in-body': 'error' },
|
|
53
52
|
}),
|
|
54
53
|
});
|
|
55
54
|
|
|
@@ -71,8 +71,7 @@ describe('Arazzo requestBody-replacements-unique', () => {
|
|
|
71
71
|
externalRefResolver: new BaseResolver(),
|
|
72
72
|
document,
|
|
73
73
|
config: await makeConfig({
|
|
74
|
-
rules: {},
|
|
75
|
-
arazzoRules: { 'requestBody-replacements-unique': 'error' },
|
|
74
|
+
rules: { 'requestBody-replacements-unique': 'error' },
|
|
76
75
|
}),
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -41,8 +41,7 @@ describe('Arazzo sourceDescription-type', () => {
|
|
|
41
41
|
externalRefResolver: new BaseResolver(),
|
|
42
42
|
document,
|
|
43
43
|
config: await makeConfig({
|
|
44
|
-
rules: {},
|
|
45
|
-
arazzoRules: { 'sourceDescription-type': 'error' },
|
|
44
|
+
rules: { 'sourceDescription-type': 'error' },
|
|
46
45
|
}),
|
|
47
46
|
});
|
|
48
47
|
|
|
@@ -70,8 +69,7 @@ describe('Arazzo sourceDescription-type', () => {
|
|
|
70
69
|
externalRefResolver: new BaseResolver(),
|
|
71
70
|
document,
|
|
72
71
|
config: await makeConfig({
|
|
73
|
-
rules: {},
|
|
74
|
-
arazzoRules: { 'sourceDescription-type': 'off' },
|
|
72
|
+
rules: { 'sourceDescription-type': 'off' },
|
|
75
73
|
}),
|
|
76
74
|
});
|
|
77
75
|
|
|
@@ -41,8 +41,7 @@ describe('Arazzo sourceDescription-name-unique', () => {
|
|
|
41
41
|
externalRefResolver: new BaseResolver(),
|
|
42
42
|
document,
|
|
43
43
|
config: await makeConfig({
|
|
44
|
-
rules: {},
|
|
45
|
-
arazzoRules: { 'sourceDescription-name-unique': 'error' },
|
|
44
|
+
rules: { 'sourceDescription-name-unique': 'error' },
|
|
46
45
|
}),
|
|
47
46
|
});
|
|
48
47
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { outdent } from 'outdent';
|
|
2
|
+
import { lintDocument } from '../../../lint';
|
|
3
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
|
+
import { BaseResolver } from '../../../resolve';
|
|
5
|
+
|
|
6
|
+
describe('Arazzo sourceDescriptions-not-empty', () => {
|
|
7
|
+
const document1 = parseYamlToDocument(
|
|
8
|
+
outdent`
|
|
9
|
+
arazzo: '1.0.0'
|
|
10
|
+
info:
|
|
11
|
+
title: Cool API
|
|
12
|
+
version: 1.0.0
|
|
13
|
+
description: A cool API
|
|
14
|
+
sourceDescriptions:
|
|
15
|
+
- name: museum-api
|
|
16
|
+
type: openapi
|
|
17
|
+
url: openapi.yaml
|
|
18
|
+
- name: museum-api
|
|
19
|
+
type: openapi
|
|
20
|
+
url: openapi.yaml
|
|
21
|
+
workflows:
|
|
22
|
+
- workflowId: get-museum-hours
|
|
23
|
+
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
|
|
24
|
+
parameters:
|
|
25
|
+
- in: header
|
|
26
|
+
name: Authorization
|
|
27
|
+
value: Basic Og==
|
|
28
|
+
steps:
|
|
29
|
+
- stepId: get-museum-hours
|
|
30
|
+
description: >-
|
|
31
|
+
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
|
|
32
|
+
operationId: museum-api.getMuseumHours
|
|
33
|
+
successCriteria:
|
|
34
|
+
- condition: $statusCode == 200
|
|
35
|
+
`,
|
|
36
|
+
'arazzo.yaml'
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const document2 = parseYamlToDocument(
|
|
40
|
+
outdent`
|
|
41
|
+
arazzo: '1.0.0'
|
|
42
|
+
info:
|
|
43
|
+
title: Cool API
|
|
44
|
+
version: 1.0.0
|
|
45
|
+
description: A cool API
|
|
46
|
+
sourceDescriptions: []
|
|
47
|
+
workflows:
|
|
48
|
+
- workflowId: get-museum-hours
|
|
49
|
+
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
|
|
50
|
+
parameters:
|
|
51
|
+
- in: header
|
|
52
|
+
name: Authorization
|
|
53
|
+
value: Basic Og==
|
|
54
|
+
steps:
|
|
55
|
+
- stepId: get-museum-hours
|
|
56
|
+
description: >-
|
|
57
|
+
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
|
|
58
|
+
operationId: museum-api.getMuseumHours
|
|
59
|
+
successCriteria:
|
|
60
|
+
- condition: $statusCode == 200
|
|
61
|
+
`,
|
|
62
|
+
'arazzo.yaml'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
it('should not report an error when sourceDescriptions have at least one entry.', async () => {
|
|
66
|
+
const results = await lintDocument({
|
|
67
|
+
externalRefResolver: new BaseResolver(),
|
|
68
|
+
document: document1,
|
|
69
|
+
config: await makeConfig({
|
|
70
|
+
rules: { 'sourceDescriptions-not-empty': 'error' },
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should report an error when sourceDescriptions is empty list.', async () => {
|
|
78
|
+
const results = await lintDocument({
|
|
79
|
+
externalRefResolver: new BaseResolver(),
|
|
80
|
+
document: document2,
|
|
81
|
+
config: await makeConfig({
|
|
82
|
+
rules: { 'sourceDescriptions-not-empty': 'error' },
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
87
|
+
[
|
|
88
|
+
{
|
|
89
|
+
"location": [
|
|
90
|
+
{
|
|
91
|
+
"pointer": "#/sourceDescriptions",
|
|
92
|
+
"reportOnKey": false,
|
|
93
|
+
"source": "arazzo.yaml",
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
"message": "The \`sourceDescriptions\` list must have at least one entry.",
|
|
97
|
+
"ruleId": "sourceDescriptions-not-empty",
|
|
98
|
+
"severity": "error",
|
|
99
|
+
"suggest": [],
|
|
100
|
+
},
|
|
101
|
+
]
|
|
102
|
+
`);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -60,8 +60,7 @@ describe('Arazzo step-onFailure-unique', () => {
|
|
|
60
60
|
externalRefResolver: new BaseResolver(),
|
|
61
61
|
document,
|
|
62
62
|
config: await makeConfig({
|
|
63
|
-
rules: {},
|
|
64
|
-
arazzoRules: { 'step-onFailure-unique': 'error' },
|
|
63
|
+
rules: { 'step-onFailure-unique': 'error' },
|
|
65
64
|
}),
|
|
66
65
|
});
|
|
67
66
|
|
|
@@ -60,8 +60,7 @@ describe('Arazzo step-onSuccess-unique', () => {
|
|
|
60
60
|
externalRefResolver: new BaseResolver(),
|
|
61
61
|
document,
|
|
62
62
|
config: await makeConfig({
|
|
63
|
-
rules: {},
|
|
64
|
-
arazzoRules: { 'step-onSuccess-unique': 'error' },
|
|
63
|
+
rules: { 'step-onSuccess-unique': 'error' },
|
|
65
64
|
}),
|
|
66
65
|
});
|
|
67
66
|
|
|
@@ -131,8 +131,7 @@ describe('Arazzo workflow-dependsOn', () => {
|
|
|
131
131
|
externalRefResolver: new BaseResolver(),
|
|
132
132
|
document,
|
|
133
133
|
config: await makeConfig({
|
|
134
|
-
rules: {},
|
|
135
|
-
arazzoRules: { 'workflow-dependsOn': 'error' },
|
|
134
|
+
rules: { 'workflow-dependsOn': 'error' },
|
|
136
135
|
}),
|
|
137
136
|
});
|
|
138
137
|
|
|
@@ -160,8 +159,7 @@ describe('Arazzo workflow-dependsOn', () => {
|
|
|
160
159
|
externalRefResolver: new BaseResolver(),
|
|
161
160
|
document,
|
|
162
161
|
config: await makeConfig({
|
|
163
|
-
rules: {},
|
|
164
|
-
arazzoRules: { 'workflow-dependsOn': 'off' },
|
|
162
|
+
rules: { 'workflow-dependsOn': 'off' },
|
|
165
163
|
}),
|
|
166
164
|
});
|
|
167
165
|
|
|
@@ -173,8 +171,7 @@ describe('Arazzo workflow-dependsOn', () => {
|
|
|
173
171
|
externalRefResolver: new BaseResolver(),
|
|
174
172
|
document: documentWithNotExistingWorkflows,
|
|
175
173
|
config: await makeConfig({
|
|
176
|
-
rules: {},
|
|
177
|
-
arazzoRules: { 'workflow-dependsOn': 'error' },
|
|
174
|
+
rules: { 'workflow-dependsOn': 'error' },
|
|
178
175
|
}),
|
|
179
176
|
});
|
|
180
177
|
|
|
@@ -51,8 +51,7 @@ describe('Arazzo workflowId-unique', () => {
|
|
|
51
51
|
externalRefResolver: new BaseResolver(),
|
|
52
52
|
document,
|
|
53
53
|
config: await makeConfig({
|
|
54
|
-
rules: {},
|
|
55
|
-
arazzoRules: { 'workflowId-unique': 'error' },
|
|
54
|
+
rules: { 'workflowId-unique': 'error' },
|
|
56
55
|
}),
|
|
57
56
|
});
|
|
58
57
|
|
|
@@ -80,8 +79,7 @@ describe('Arazzo workflowId-unique', () => {
|
|
|
80
79
|
externalRefResolver: new BaseResolver(),
|
|
81
80
|
document,
|
|
82
81
|
config: await makeConfig({
|
|
83
|
-
rules: {},
|
|
84
|
-
arazzoRules: { 'workflowId-unique': 'off' },
|
|
82
|
+
rules: { 'workflowId-unique': 'off' },
|
|
85
83
|
}),
|
|
86
84
|
});
|
|
87
85
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const CriteriaUnique:
|
|
4
|
+
export const CriteriaUnique: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
FailureActionObject: {
|
|
7
7
|
enter(action, { report, location }: UserContext) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Struct } from '../common/struct';
|
|
2
2
|
import { Assertions } from '../common/assertions';
|
|
3
3
|
import { ParametersNotInBody } from '../spot/parameters-not-in-body';
|
|
4
|
-
import { SourceDescriptionType } from '../arazzo/
|
|
4
|
+
import { SourceDescriptionType } from '../arazzo/sourceDescription-type';
|
|
5
|
+
import { SourceDescriptionsNotEmpty } from './sourceDescriptions-not-empty';
|
|
5
6
|
import { VersionEnum } from '../spot/version-enum';
|
|
6
7
|
import { WorkflowIdUnique } from './workflowId-unique';
|
|
7
8
|
import { StepIdUnique } from './stepId-unique';
|
|
@@ -15,26 +16,27 @@ import { NoCriteriaXpath } from '../spot/no-criteria-xpath';
|
|
|
15
16
|
import { NoActionsTypeEnd } from '../spot/no-actions-type-end';
|
|
16
17
|
import { CriteriaUnique } from './criteria-unique';
|
|
17
18
|
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
19
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
20
|
+
import type { Arazzo1RuleSet } from '../../oas-types';
|
|
20
21
|
|
|
21
|
-
export const rules:
|
|
22
|
-
|
|
23
|
-
assertions: Assertions as
|
|
24
|
-
'parameters-not-in-body': ParametersNotInBody
|
|
25
|
-
'sourceDescription-type': SourceDescriptionType
|
|
26
|
-
'version-enum': VersionEnum
|
|
27
|
-
'workflowId-unique': WorkflowIdUnique
|
|
28
|
-
'stepId-unique': StepIdUnique
|
|
29
|
-
'sourceDescription-name-unique': SourceDescriptionsNameUnique
|
|
30
|
-
'
|
|
31
|
-
'
|
|
32
|
-
'
|
|
33
|
-
'step-
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'no-
|
|
37
|
-
'
|
|
22
|
+
export const rules: Arazzo1RuleSet<'built-in'> = {
|
|
23
|
+
struct: Struct as Arazzo1Rule,
|
|
24
|
+
assertions: Assertions as Arazzo1Rule,
|
|
25
|
+
'parameters-not-in-body': ParametersNotInBody,
|
|
26
|
+
'sourceDescription-type': SourceDescriptionType,
|
|
27
|
+
'version-enum': VersionEnum,
|
|
28
|
+
'workflowId-unique': WorkflowIdUnique,
|
|
29
|
+
'stepId-unique': StepIdUnique,
|
|
30
|
+
'sourceDescription-name-unique': SourceDescriptionsNameUnique,
|
|
31
|
+
'sourceDescriptions-not-empty': SourceDescriptionsNotEmpty,
|
|
32
|
+
'workflow-dependsOn': WorkflowDependsOn,
|
|
33
|
+
'parameters-unique': ParametersUnique,
|
|
34
|
+
'step-onSuccess-unique': StepOnSuccessUnique,
|
|
35
|
+
'step-onFailure-unique': StepOnFailureUnique,
|
|
36
|
+
'requestBody-replacements-unique': RequestBodyReplacementsUnique,
|
|
37
|
+
'no-criteria-xpath': NoCriteriaXpath,
|
|
38
|
+
'no-actions-type-end': NoActionsTypeEnd,
|
|
39
|
+
'criteria-unique': CriteriaUnique,
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
export const preprocessors = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const ParametersUnique:
|
|
4
|
+
export const ParametersUnique: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
Parameters: {
|
|
7
7
|
enter(parameters, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const RequestBodyReplacementsUnique:
|
|
4
|
+
export const RequestBodyReplacementsUnique: Arazzo1Rule = () => {
|
|
5
5
|
const seenReplacements = new Set();
|
|
6
6
|
|
|
7
7
|
return {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const SourceDescriptionType:
|
|
4
|
+
export const SourceDescriptionType: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
SourceDescriptions: {
|
|
7
|
-
enter(
|
|
8
|
-
|
|
7
|
+
enter(sourceDescriptions, { report, location }: UserContext) {
|
|
8
|
+
if (!sourceDescriptions.length) return;
|
|
9
|
+
for (const sourceDescription of sourceDescriptions) {
|
|
9
10
|
if (!['openapi', 'arazzo'].includes(sourceDescription?.type)) {
|
|
10
11
|
report({
|
|
11
12
|
message:
|
|
12
13
|
'The `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.',
|
|
13
|
-
location: location.child([
|
|
14
|
+
location: location.child([sourceDescriptions.indexOf(sourceDescription)]),
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const SourceDescriptionsNameUnique:
|
|
4
|
+
export const SourceDescriptionsNameUnique: Arazzo1Rule = () => {
|
|
5
5
|
const seenSourceDescriptions = new Set();
|
|
6
6
|
|
|
7
7
|
return {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
|
+
import type { UserContext } from '../../walk';
|
|
3
|
+
|
|
4
|
+
export const SourceDescriptionsNotEmpty: Arazzo1Rule = () => {
|
|
5
|
+
return {
|
|
6
|
+
SourceDescriptions: {
|
|
7
|
+
enter(sourceDescriptions, { report, location }: UserContext) {
|
|
8
|
+
if (!sourceDescriptions?.length) {
|
|
9
|
+
report({
|
|
10
|
+
message: 'The `sourceDescriptions` list must have at least one entry.',
|
|
11
|
+
location,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const StepOnFailureUnique:
|
|
4
|
+
export const StepOnFailureUnique: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
OnFailureActionList: {
|
|
7
7
|
enter(onFailureActionList, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const StepOnSuccessUnique:
|
|
4
|
+
export const StepOnSuccessUnique: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
OnSuccessActionList: {
|
|
7
7
|
enter(onSuccessActionList, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const StepIdUnique:
|
|
4
|
+
export const StepIdUnique: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
Workflow: {
|
|
7
7
|
enter(workflow, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const WorkflowDependsOn:
|
|
4
|
+
export const WorkflowDependsOn: Arazzo1Rule = () => {
|
|
5
5
|
const seenWorkflow = new Set();
|
|
6
6
|
const existingSourceDescriptions = new Set();
|
|
7
7
|
const existingWorkflowIds = new Set();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const WorkflowIdUnique:
|
|
4
|
+
export const WorkflowIdUnique: Arazzo1Rule = () => {
|
|
5
5
|
const seenWorkflow = new Set();
|
|
6
6
|
|
|
7
7
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Assertions } from '../common/assertions';
|
|
2
|
-
import {
|
|
2
|
+
import { Struct } from '../common/struct';
|
|
3
3
|
import { InfoContact } from '../common/info-contact';
|
|
4
4
|
import { InfoLicenseStrict } from '../common/info-license-strict';
|
|
5
5
|
import { OperationOperationId } from '../common/operation-operationId';
|
|
@@ -12,7 +12,10 @@ import type { Async2Rule } from '../../visitors';
|
|
|
12
12
|
import type { Async2RuleSet } from '../../oas-types';
|
|
13
13
|
|
|
14
14
|
export const rules: Async2RuleSet<'built-in'> = {
|
|
15
|
-
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
17
|
+
spec: Struct as Async2Rule,
|
|
18
|
+
struct: Struct as Async2Rule,
|
|
16
19
|
assertions: Assertions as Async2Rule,
|
|
17
20
|
'info-contact': InfoContact as Async2Rule,
|
|
18
21
|
'info-license-strict': InfoLicenseStrict as Async2Rule,
|