@redocly/openapi-core 1.21.1 → 1.22.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/lib/config/all.js +14 -1
  3. package/lib/config/minimal.js +11 -1
  4. package/lib/config/recommended-strict.js +11 -1
  5. package/lib/config/recommended.js +11 -1
  6. package/lib/oas-types.js +2 -1
  7. package/lib/rules/arazzo/index.js +22 -2
  8. package/lib/rules/arazzo/parameters-unique.d.ts +2 -0
  9. package/lib/rules/arazzo/parameters-unique.js +32 -0
  10. package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -0
  11. package/lib/rules/arazzo/requestBody-replacements-unique.js +28 -0
  12. package/lib/rules/arazzo/source-description-type.d.ts +2 -0
  13. package/lib/rules/arazzo/source-description-type.js +20 -0
  14. package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -0
  15. package/lib/rules/arazzo/sourceDescriptions-name-unique.js +24 -0
  16. package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -0
  17. package/lib/rules/arazzo/step-onFailure-unique.js +32 -0
  18. package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -0
  19. package/lib/rules/arazzo/step-onSuccess-unique.js +32 -0
  20. package/lib/rules/arazzo/stepId-unique.d.ts +2 -0
  21. package/lib/rules/arazzo/stepId-unique.js +26 -0
  22. package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -0
  23. package/lib/rules/arazzo/workflow-dependsOn.js +56 -0
  24. package/lib/rules/arazzo/workflowId-unique.d.ts +2 -0
  25. package/lib/rules/arazzo/workflowId-unique.js +22 -0
  26. package/lib/rules/spot/parameters-not-in-body.d.ts +2 -0
  27. package/lib/rules/spot/{parameters-no-body-inside-in.js → parameters-not-in-body.js} +3 -3
  28. package/lib/rules/spot/version-enum.d.ts +2 -0
  29. package/lib/rules/spot/version-enum.js +21 -0
  30. package/lib/types/arazzo.js +8 -10
  31. package/lib/types/redocly-yaml.d.ts +1 -1
  32. package/lib/types/redocly-yaml.js +14 -1
  33. package/lib/typings/arazzo.d.ts +2 -0
  34. package/lib/typings/arazzo.js +3 -0
  35. package/lib/utils.d.ts +1 -0
  36. package/lib/utils.js +8 -0
  37. package/package.json +2 -2
  38. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +22 -2
  39. package/src/config/all.ts +14 -1
  40. package/src/config/minimal.ts +11 -1
  41. package/src/config/recommended-strict.ts +11 -1
  42. package/src/config/recommended.ts +11 -1
  43. package/src/oas-types.ts +2 -1
  44. package/src/rules/arazzo/__tests__/{parameters-no-body-inside-in.test.ts → parameters-not-in-body.test.ts} +3 -5
  45. package/src/rules/arazzo/__tests__/parameters-unique.test.ts +114 -0
  46. package/src/rules/arazzo/__tests__/requestBody-replacements-unique.test.ts +109 -0
  47. package/src/rules/arazzo/__tests__/source-description-type.test.ts +80 -0
  48. package/src/rules/arazzo/__tests__/sourceDescription-name-unique.test.ts +79 -0
  49. package/src/rules/arazzo/__tests__/step-onFailure-unique.test.ts +111 -0
  50. package/src/rules/arazzo/__tests__/step-onSuccess-unique.test.ts +111 -0
  51. package/src/rules/arazzo/__tests__/stepId-unique.test.ts +95 -0
  52. package/src/rules/arazzo/__tests__/version-enum.test.ts +76 -0
  53. package/src/rules/arazzo/__tests__/workflow-dependsOn.test.ts +212 -0
  54. package/src/rules/arazzo/__tests__/workflowId-unique.test.ts +90 -0
  55. package/src/rules/arazzo/index.ts +22 -2
  56. package/src/rules/arazzo/parameters-unique.ts +33 -0
  57. package/src/rules/arazzo/requestBody-replacements-unique.ts +28 -0
  58. package/src/rules/arazzo/source-description-type.ts +20 -0
  59. package/src/rules/arazzo/sourceDescriptions-name-unique.ts +23 -0
  60. package/src/rules/arazzo/step-onFailure-unique.ts +33 -0
  61. package/src/rules/arazzo/step-onSuccess-unique.ts +33 -0
  62. package/src/rules/arazzo/stepId-unique.ts +24 -0
  63. package/src/rules/arazzo/workflow-dependsOn.ts +56 -0
  64. package/src/rules/arazzo/workflowId-unique.ts +21 -0
  65. package/src/rules/spot/{parameters-no-body-inside-in.ts → parameters-not-in-body.ts} +1 -1
  66. package/src/rules/spot/version-enum.ts +24 -0
  67. package/src/types/arazzo.ts +8 -10
  68. package/src/types/redocly-yaml.ts +14 -1
  69. package/src/typings/arazzo.ts +4 -0
  70. package/src/utils.ts +8 -0
  71. package/tsconfig.tsbuildinfo +1 -1
  72. package/lib/rules/spot/parameters-no-body-inside-in.d.ts +0 -2
@@ -0,0 +1,111 @@
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 step-onFailure-unique', () => {
7
+ const document = 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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ parameters:
22
+ - in: header
23
+ name: Authorization
24
+ value: Basic Og==
25
+ steps:
26
+ - stepId: get-museum-hours
27
+ description: >-
28
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29
+ operationId: museum-api.getMuseumHours
30
+ successCriteria:
31
+ - condition: $statusCode == 200
32
+ onFailure:
33
+ - name: test
34
+ workflowId: events-crud
35
+ type: goto
36
+ - name: test
37
+ workflowId: events-crud
38
+ type: goto
39
+ - reference: $steps.test.outputs.createdEventId
40
+ - reference: $steps.test.outputs.createdEventId
41
+ - workflowId: get-museum-hours-2
42
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
43
+ parameters:
44
+ - in: header
45
+ name: Authorization
46
+ value: Basic Og==
47
+ steps:
48
+ - stepId: get-museum-hours
49
+ description: >-
50
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
51
+ operationId: museum-api.getMuseumHours
52
+ successCriteria:
53
+ - condition: $statusCode == 200
54
+ `,
55
+ 'arazzo.yaml'
56
+ );
57
+
58
+ it('should report when the action `name` or `reference` is not unique amongst all onFailure actions in the step', async () => {
59
+ const results = await lintDocument({
60
+ externalRefResolver: new BaseResolver(),
61
+ document,
62
+ config: await makeConfig({
63
+ rules: {},
64
+ arazzoRules: { 'step-onFailure-unique': 'error' },
65
+ }),
66
+ });
67
+
68
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
69
+ [
70
+ {
71
+ "location": [
72
+ {
73
+ "pointer": "#/workflows/0/steps/0/onFailure/1",
74
+ "reportOnKey": false,
75
+ "source": "arazzo.yaml",
76
+ },
77
+ ],
78
+ "message": "The action \`name\` must be unique amongst listed \`onFailure\` actions.",
79
+ "ruleId": "step-onFailure-unique",
80
+ "severity": "error",
81
+ "suggest": [],
82
+ },
83
+ {
84
+ "location": [
85
+ {
86
+ "pointer": "#/workflows/0/steps/0/onFailure/3",
87
+ "reportOnKey": false,
88
+ "source": "arazzo.yaml",
89
+ },
90
+ ],
91
+ "message": "The action \`reference\` must be unique amongst listed \`onFailure\` actions.",
92
+ "ruleId": "step-onFailure-unique",
93
+ "severity": "error",
94
+ "suggest": [],
95
+ },
96
+ ]
97
+ `);
98
+ });
99
+
100
+ it('should not report when the action `name` or `reference` is not unique amongst all onFailure actions in the step', async () => {
101
+ const results = await lintDocument({
102
+ externalRefResolver: new BaseResolver(),
103
+ document,
104
+ config: await makeConfig({
105
+ rules: {},
106
+ }),
107
+ });
108
+
109
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
110
+ });
111
+ });
@@ -0,0 +1,111 @@
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 step-onSuccess-unique', () => {
7
+ const document = 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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ parameters:
22
+ - in: header
23
+ name: Authorization
24
+ value: Basic Og==
25
+ steps:
26
+ - stepId: get-museum-hours
27
+ description: >-
28
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29
+ operationId: museum-api.getMuseumHours
30
+ successCriteria:
31
+ - condition: $statusCode == 200
32
+ onSuccess:
33
+ - name: test
34
+ workflowId: events-crud
35
+ type: goto
36
+ - name: test
37
+ workflowId: events-crud
38
+ type: goto
39
+ - reference: $steps.test.outputs.createdEventId
40
+ - reference: $steps.test.outputs.createdEventId
41
+ - workflowId: get-museum-hours-2
42
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
43
+ parameters:
44
+ - in: header
45
+ name: Authorization
46
+ value: Basic Og==
47
+ steps:
48
+ - stepId: get-museum-hours
49
+ description: >-
50
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
51
+ operationId: museum-api.getMuseumHours
52
+ successCriteria:
53
+ - condition: $statusCode == 200
54
+ `,
55
+ 'arazzo.yaml'
56
+ );
57
+
58
+ it('should report when the action `name` or `reference` is not unique amongst all onSuccess actions in the step', async () => {
59
+ const results = await lintDocument({
60
+ externalRefResolver: new BaseResolver(),
61
+ document,
62
+ config: await makeConfig({
63
+ rules: {},
64
+ arazzoRules: { 'step-onSuccess-unique': 'error' },
65
+ }),
66
+ });
67
+
68
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
69
+ [
70
+ {
71
+ "location": [
72
+ {
73
+ "pointer": "#/workflows/0/steps/0/onSuccess/1",
74
+ "reportOnKey": false,
75
+ "source": "arazzo.yaml",
76
+ },
77
+ ],
78
+ "message": "The action \`name\` must be unique amongst listed \`onSuccess\` actions.",
79
+ "ruleId": "step-onSuccess-unique",
80
+ "severity": "error",
81
+ "suggest": [],
82
+ },
83
+ {
84
+ "location": [
85
+ {
86
+ "pointer": "#/workflows/0/steps/0/onSuccess/3",
87
+ "reportOnKey": false,
88
+ "source": "arazzo.yaml",
89
+ },
90
+ ],
91
+ "message": "The action \`reference\` must be unique amongst listed \`onSuccess\` actions.",
92
+ "ruleId": "step-onSuccess-unique",
93
+ "severity": "error",
94
+ "suggest": [],
95
+ },
96
+ ]
97
+ `);
98
+ });
99
+
100
+ it('should not report when the action `name` or `reference` is not unique amongst all onSuccess actions in the step', async () => {
101
+ const results = await lintDocument({
102
+ externalRefResolver: new BaseResolver(),
103
+ document,
104
+ config: await makeConfig({
105
+ rules: {},
106
+ }),
107
+ });
108
+
109
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
110
+ });
111
+ });
@@ -0,0 +1,95 @@
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 stepId-unique', () => {
7
+ const document = 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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ parameters:
22
+ - in: header
23
+ name: Authorization
24
+ value: Basic Og==
25
+ steps:
26
+ - stepId: get-museum-hours
27
+ description: >-
28
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29
+ operationId: museum-api.getMuseumHours
30
+ successCriteria:
31
+ - condition: $statusCode == 200
32
+ - workflowId: get-museum-hours-2
33
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
34
+ parameters:
35
+ - in: header
36
+ name: Authorization
37
+ value: Basic Og==
38
+ steps:
39
+ - stepId: get-museum-hours
40
+ description: >-
41
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
42
+ operationId: museum-api.getMuseumHours
43
+ successCriteria:
44
+ - condition: $statusCode == 200
45
+ - stepId: get-museum-hours
46
+ description: >-
47
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
48
+ operationId: museum-api.getMuseumHours
49
+ successCriteria:
50
+ - condition: $statusCode == 200
51
+ `,
52
+ 'arazzo.yaml'
53
+ );
54
+
55
+ it('should report when the `stepId` is not unique amongst all steps described in the workflow', async () => {
56
+ const results = await lintDocument({
57
+ externalRefResolver: new BaseResolver(),
58
+ document,
59
+ config: await makeConfig({
60
+ rules: {},
61
+ arazzoRules: { 'stepId-unique': 'error' },
62
+ }),
63
+ });
64
+
65
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
66
+ [
67
+ {
68
+ "location": [
69
+ {
70
+ "pointer": "#/workflows/1/steps/1",
71
+ "reportOnKey": false,
72
+ "source": "arazzo.yaml",
73
+ },
74
+ ],
75
+ "message": "The \`stepId\` must be unique amongst all steps described in the workflow.",
76
+ "ruleId": "stepId-unique",
77
+ "severity": "error",
78
+ "suggest": [],
79
+ },
80
+ ]
81
+ `);
82
+ });
83
+
84
+ it('should not report when the `stepId` is not unique amongst all steps described in the workflow', async () => {
85
+ const results = await lintDocument({
86
+ externalRefResolver: new BaseResolver(),
87
+ document,
88
+ config: await makeConfig({
89
+ rules: {},
90
+ }),
91
+ });
92
+
93
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
94
+ });
95
+ });
@@ -0,0 +1,76 @@
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 version-enum', () => {
7
+ const document = parseYamlToDocument(
8
+ outdent`
9
+ arazzo: '1.0.1'
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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ parameters:
22
+ - in: header
23
+ name: Authorization
24
+ value: Basic Og==
25
+ steps:
26
+ - stepId: get-museum-hours
27
+ description: >-
28
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29
+ operationId: museum-api.getMuseumHours
30
+ successCriteria:
31
+ - condition: $statusCode == 200
32
+ `,
33
+ 'arazzo.yaml'
34
+ );
35
+
36
+ it('should report on arazzo version error', async () => {
37
+ const results = await lintDocument({
38
+ externalRefResolver: new BaseResolver(),
39
+ document,
40
+ config: await makeConfig({
41
+ rules: {},
42
+ arazzoRules: { 'version-enum': 'error' },
43
+ }),
44
+ });
45
+
46
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
47
+ [
48
+ {
49
+ "location": [
50
+ {
51
+ "pointer": "#/arazzo",
52
+ "reportOnKey": false,
53
+ "source": "arazzo.yaml",
54
+ },
55
+ ],
56
+ "message": "Only 1.0.0 Arazzo version is supported by Spot.",
57
+ "ruleId": "version-enum",
58
+ "severity": "error",
59
+ "suggest": [],
60
+ },
61
+ ]
62
+ `);
63
+ });
64
+
65
+ it('should not report on arazzo version error', async () => {
66
+ const results = await lintDocument({
67
+ externalRefResolver: new BaseResolver(),
68
+ document,
69
+ config: await makeConfig({
70
+ rules: {},
71
+ }),
72
+ });
73
+
74
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
75
+ });
76
+ });
@@ -0,0 +1,212 @@
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 workflow-dependsOn', () => {
7
+ const document = 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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ dependsOn:
22
+ - get-museum-hours-2
23
+ - get-museum-hours-3
24
+ - get-museum-hours-2
25
+ parameters:
26
+ - in: header
27
+ name: Authorization
28
+ value: Basic Og==
29
+ steps:
30
+ - stepId: get-museum-hours
31
+ description: >-
32
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
33
+ operationId: museum-api.getMuseumHours
34
+ successCriteria:
35
+ - condition: $statusCode == 200
36
+ - workflowId: get-museum-hours-2
37
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
38
+ parameters:
39
+ - in: header
40
+ name: Authorization
41
+ value: Basic Og==
42
+ steps:
43
+ - stepId: get-museum-hours
44
+ description: >-
45
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
46
+ operationId: museum-api.getMuseumHours
47
+ successCriteria:
48
+ - condition: $statusCode == 200
49
+ - workflowId: get-museum-hours-3
50
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
51
+ parameters:
52
+ - in: header
53
+ name: Authorization
54
+ value: Basic Og==
55
+ steps:
56
+ - stepId: get-museum-hours
57
+ description: >-
58
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
59
+ operationId: museum-api.getMuseumHours
60
+ successCriteria:
61
+ - condition: $statusCode == 200
62
+ `,
63
+ 'arazzo.yaml'
64
+ );
65
+
66
+ const documentWithNotExistingWorkflows = parseYamlToDocument(
67
+ outdent`
68
+ arazzo: 1.0.0
69
+ info:
70
+ title: Redocly Museum API Test Workflow
71
+ description: >-
72
+ Use the Museum API with Arazzo as an example of describing multi-step workflows.
73
+ Built with love by Redocly.
74
+ version: 1.0.0
75
+
76
+ sourceDescriptions:
77
+ - name: museum-api
78
+ type: openapi
79
+ url: ../openapi.yaml
80
+ - name: tickets-from-museum-api
81
+ type: arazzo
82
+ url: museum-tickets.arazzo.yaml
83
+
84
+ workflows:
85
+ - workflowId: get-museum-hours
86
+ dependsOn:
87
+ - events-crud
88
+ - events-crus
89
+ - $sourceDescriptions.tickets-from-museum-apis.workflows.get-museum-tickets
90
+ description: >-
91
+ This workflow demonstrates how to get the museum opening hours and buy tickets.
92
+ parameters:
93
+ - in: header
94
+ name: Authorization
95
+ value: Basic Og==
96
+ steps:
97
+ - stepId: get-museum-hours
98
+ description: >-
99
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
100
+ operationId: museum-api.getMuseumHours
101
+ successCriteria:
102
+ - condition: $statusCode == 200
103
+ outputs:
104
+ schedule: $response.body
105
+ - stepId: buy-ticket
106
+ description: >-
107
+ Buy a ticket for the museum by calling an external workflow from another Arazzo file.
108
+ workflowId: $sourceDescriptions.tickets-from-museum-api.workflows.get-museum-tickets
109
+ outputs:
110
+ ticketId: $outputs.ticketId
111
+ - workflowId: events-crud
112
+ description: >-
113
+ This workflow demonstrates how to list, create, update, and delete special events at the museum.
114
+ parameters:
115
+ - in: header
116
+ name: Authorization
117
+ value: Basic Og==
118
+ steps:
119
+ - stepId: list-events
120
+ description: >-
121
+ Request the list of events.
122
+ operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/get
123
+ outputs:
124
+ events: $response.body
125
+ `,
126
+ 'arazzo.yaml'
127
+ );
128
+
129
+ it('should report on dependsOn unique violation', async () => {
130
+ const results = await lintDocument({
131
+ externalRefResolver: new BaseResolver(),
132
+ document,
133
+ config: await makeConfig({
134
+ rules: {},
135
+ arazzoRules: { 'workflow-dependsOn': 'error' },
136
+ }),
137
+ });
138
+
139
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
140
+ [
141
+ {
142
+ "location": [
143
+ {
144
+ "pointer": "#/workflows/0/dependsOn",
145
+ "reportOnKey": false,
146
+ "source": "arazzo.yaml",
147
+ },
148
+ ],
149
+ "message": "Every workflow in dependsOn must be unique.",
150
+ "ruleId": "workflow-dependsOn",
151
+ "severity": "error",
152
+ "suggest": [],
153
+ },
154
+ ]
155
+ `);
156
+ });
157
+
158
+ it('should not report on dependsOn unique violation', async () => {
159
+ const results = await lintDocument({
160
+ externalRefResolver: new BaseResolver(),
161
+ document,
162
+ config: await makeConfig({
163
+ rules: {},
164
+ arazzoRules: { 'workflow-dependsOn': 'off' },
165
+ }),
166
+ });
167
+
168
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
169
+ });
170
+
171
+ it('should report on not existing workflows in dependsOn', async () => {
172
+ const results = await lintDocument({
173
+ externalRefResolver: new BaseResolver(),
174
+ document: documentWithNotExistingWorkflows,
175
+ config: await makeConfig({
176
+ rules: {},
177
+ arazzoRules: { 'workflow-dependsOn': 'error' },
178
+ }),
179
+ });
180
+
181
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
182
+ [
183
+ {
184
+ "location": [
185
+ {
186
+ "pointer": "#/workflows/0/dependsOn/1",
187
+ "reportOnKey": false,
188
+ "source": "arazzo.yaml",
189
+ },
190
+ ],
191
+ "message": "Workflow events-crus must be defined in workflows.",
192
+ "ruleId": "workflow-dependsOn",
193
+ "severity": "error",
194
+ "suggest": [],
195
+ },
196
+ {
197
+ "location": [
198
+ {
199
+ "pointer": "#/workflows/0/dependsOn/2",
200
+ "reportOnKey": false,
201
+ "source": "arazzo.yaml",
202
+ },
203
+ ],
204
+ "message": "SourceDescription tickets-from-museum-apis must be defined in sourceDescriptions.",
205
+ "ruleId": "workflow-dependsOn",
206
+ "severity": "error",
207
+ "suggest": [],
208
+ },
209
+ ]
210
+ `);
211
+ });
212
+ });
@@ -0,0 +1,90 @@
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 workflowId-unique', () => {
7
+ const document = 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
+ workflows:
19
+ - workflowId: get-museum-hours
20
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
21
+ parameters:
22
+ - in: header
23
+ name: Authorization
24
+ value: Basic Og==
25
+ steps:
26
+ - stepId: get-museum-hours
27
+ description: >-
28
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
29
+ operationId: museum-api.getMuseumHours
30
+ successCriteria:
31
+ - condition: $statusCode == 200
32
+ - workflowId: get-museum-hours
33
+ description: This workflow demonstrates how to get the museum opening hours and buy tickets.
34
+ parameters:
35
+ - in: header
36
+ name: Authorization
37
+ value: Basic Og==
38
+ steps:
39
+ - stepId: get-museum-hours
40
+ description: >-
41
+ Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
42
+ operationId: museum-api.getMuseumHours
43
+ successCriteria:
44
+ - condition: $statusCode == 200
45
+ `,
46
+ 'arazzo.yaml'
47
+ );
48
+
49
+ it('should report on workflowId unique violation', async () => {
50
+ const results = await lintDocument({
51
+ externalRefResolver: new BaseResolver(),
52
+ document,
53
+ config: await makeConfig({
54
+ rules: {},
55
+ arazzoRules: { 'workflowId-unique': 'error' },
56
+ }),
57
+ });
58
+
59
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
60
+ [
61
+ {
62
+ "location": [
63
+ {
64
+ "pointer": "#/workflows/1/get-museum-hours",
65
+ "reportOnKey": false,
66
+ "source": "arazzo.yaml",
67
+ },
68
+ ],
69
+ "message": "Every workflow must have a unique \`workflowId\`.",
70
+ "ruleId": "workflowId-unique",
71
+ "severity": "error",
72
+ "suggest": [],
73
+ },
74
+ ]
75
+ `);
76
+ });
77
+
78
+ it('should not report on workflowId unique violation', async () => {
79
+ const results = await lintDocument({
80
+ externalRefResolver: new BaseResolver(),
81
+ document,
82
+ config: await makeConfig({
83
+ rules: {},
84
+ arazzoRules: { 'workflowId-unique': 'off' },
85
+ }),
86
+ });
87
+
88
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
89
+ });
90
+ });