@redocly/openapi-core 1.26.0 → 1.27.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 +17 -0
- package/lib/config/all.js +2 -4
- package/lib/config/config-resolvers.d.ts +3 -1
- package/lib/config/config-resolvers.js +7 -5
- package/lib/config/minimal.js +1 -3
- package/lib/config/recommended-strict.js +2 -4
- package/lib/config/recommended.js +2 -4
- package/lib/config/rules.js +3 -0
- package/lib/config/spec.js +2 -4
- package/lib/config/types.d.ts +2 -3
- package/lib/rules/arazzo/index.js +2 -6
- package/lib/rules/spot/spot-supported-versions.d.ts +2 -0
- package/lib/rules/spot/{version-enum.js → spot-supported-versions.js} +3 -3
- package/lib/types/redocly-yaml.d.ts +1 -1
- package/lib/types/redocly-yaml.js +1 -3
- package/lib/visitors.d.ts +3 -0
- package/lib/visitors.js +2 -2
- package/lib/walk.js +14 -11
- package/package.json +1 -3
- package/src/__tests__/walk.test.ts +51 -0
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +4 -8
- package/src/config/all.ts +2 -4
- package/src/config/config-resolvers.ts +28 -36
- package/src/config/minimal.ts +1 -3
- package/src/config/recommended-strict.ts +2 -4
- package/src/config/recommended.ts +2 -4
- package/src/config/rules.ts +3 -1
- package/src/config/spec.ts +2 -4
- package/src/config/types.ts +2 -6
- package/src/rules/arazzo/__tests__/{version-enum.test.ts → spot-supported-versions.test.ts} +3 -3
- package/src/rules/arazzo/index.ts +2 -6
- package/src/rules/spot/{version-enum.ts → spot-supported-versions.ts} +1 -1
- package/src/types/redocly-yaml.ts +1 -3
- package/src/visitors.ts +5 -2
- package/src/walk.ts +20 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/spot/no-actions-type-end.d.ts +0 -2
- package/lib/rules/spot/no-actions-type-end.js +0 -28
- package/lib/rules/spot/parameters-not-in-body.d.ts +0 -2
- package/lib/rules/spot/parameters-not-in-body.js +0 -18
- package/lib/rules/spot/version-enum.d.ts +0 -2
- package/src/rules/arazzo/__tests__/no-actions-type-end.test.ts +0 -121
- package/src/rules/arazzo/__tests__/parameters-not-in-body.test.ts +0 -73
- package/src/rules/spot/no-actions-type-end.ts +0 -27
- package/src/rules/spot/parameters-not-in-body.ts +0 -17
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoActionsTypeEnd = void 0;
|
|
4
|
-
const NoActionsTypeEnd = () => {
|
|
5
|
-
return {
|
|
6
|
-
FailureActionObject: {
|
|
7
|
-
enter(action, { report, location }) {
|
|
8
|
-
if (action.type === 'end') {
|
|
9
|
-
report({
|
|
10
|
-
message: 'The `end` type action is not supported by Spot.',
|
|
11
|
-
location: location.child(['type']),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
SuccessActionObject: {
|
|
17
|
-
enter(action, { report, location }) {
|
|
18
|
-
if (action.type === 'end') {
|
|
19
|
-
report({
|
|
20
|
-
message: 'The `end` type action is not supported by Spot.',
|
|
21
|
-
location: location.child(['type']),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.NoActionsTypeEnd = NoActionsTypeEnd;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParametersNotInBody = void 0;
|
|
4
|
-
const ParametersNotInBody = () => {
|
|
5
|
-
return {
|
|
6
|
-
Parameter: {
|
|
7
|
-
enter(parameter, { report, location }) {
|
|
8
|
-
if (parameter.in === 'body') {
|
|
9
|
-
report({
|
|
10
|
-
message: 'The `body` value of the `in` property is not supported by Spot.',
|
|
11
|
-
location: location.child(['in']),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.ParametersNotInBody = ParametersNotInBody;
|
|
@@ -1,121 +0,0 @@
|
|
|
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 no-actions-type-end', () => {
|
|
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: create-event
|
|
27
|
-
description: >-
|
|
28
|
-
Create a new special event.
|
|
29
|
-
operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/post
|
|
30
|
-
requestBody:
|
|
31
|
-
payload:
|
|
32
|
-
name: 'Mermaid Treasure Identification and Analysis'
|
|
33
|
-
location: 'Under the seaaa 🦀 🎶 🌊.'
|
|
34
|
-
eventDescription: 'Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.'
|
|
35
|
-
dates:
|
|
36
|
-
- '2023-09-05'
|
|
37
|
-
- '2023-09-08'
|
|
38
|
-
price: 0
|
|
39
|
-
successCriteria:
|
|
40
|
-
- condition: $statusCode == 201
|
|
41
|
-
onSuccess:
|
|
42
|
-
- name: 'onSuccessActionName'
|
|
43
|
-
type: 'end'
|
|
44
|
-
stepId: 'buy-ticket'
|
|
45
|
-
onFailure:
|
|
46
|
-
- name: 'onFailureActionName'
|
|
47
|
-
type: 'end'
|
|
48
|
-
stepId: 'buy-ticket'
|
|
49
|
-
outputs:
|
|
50
|
-
createdEventId: $response.body.eventId
|
|
51
|
-
name: $response.body.name
|
|
52
|
-
- workflowId: get-museum-hours-2
|
|
53
|
-
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
|
|
54
|
-
parameters:
|
|
55
|
-
- in: header
|
|
56
|
-
name: Authorization
|
|
57
|
-
value: Basic Og==
|
|
58
|
-
steps:
|
|
59
|
-
- stepId: get-museum-hours
|
|
60
|
-
description: >-
|
|
61
|
-
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
|
|
62
|
-
operationId: museum-api.getMuseumHours
|
|
63
|
-
successCriteria:
|
|
64
|
-
- condition: $statusCode == 200
|
|
65
|
-
`,
|
|
66
|
-
'arazzo.yaml'
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
it('should report when the type `end` action exists', async () => {
|
|
70
|
-
const results = await lintDocument({
|
|
71
|
-
externalRefResolver: new BaseResolver(),
|
|
72
|
-
document,
|
|
73
|
-
config: await makeConfig({
|
|
74
|
-
rules: { 'no-actions-type-end': 'error' },
|
|
75
|
-
}),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
79
|
-
[
|
|
80
|
-
{
|
|
81
|
-
"location": [
|
|
82
|
-
{
|
|
83
|
-
"pointer": "#/workflows/0/steps/0/onSuccess/0/type",
|
|
84
|
-
"reportOnKey": false,
|
|
85
|
-
"source": "arazzo.yaml",
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
"message": "The \`end\` type action is not supported by Spot.",
|
|
89
|
-
"ruleId": "no-actions-type-end",
|
|
90
|
-
"severity": "error",
|
|
91
|
-
"suggest": [],
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"location": [
|
|
95
|
-
{
|
|
96
|
-
"pointer": "#/workflows/0/steps/0/onFailure/0/type",
|
|
97
|
-
"reportOnKey": false,
|
|
98
|
-
"source": "arazzo.yaml",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
"message": "The \`end\` type action is not supported by Spot.",
|
|
102
|
-
"ruleId": "no-actions-type-end",
|
|
103
|
-
"severity": "error",
|
|
104
|
-
"suggest": [],
|
|
105
|
-
},
|
|
106
|
-
]
|
|
107
|
-
`);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should not report when the type `end` action exists', async () => {
|
|
111
|
-
const results = await lintDocument({
|
|
112
|
-
externalRefResolver: new BaseResolver(),
|
|
113
|
-
document,
|
|
114
|
-
config: await makeConfig({
|
|
115
|
-
rules: {},
|
|
116
|
-
}),
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
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('Spot parameters-not-in-body', () => {
|
|
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: body
|
|
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 not report on `body` inside parameter `in` field', async () => {
|
|
37
|
-
const results = await lintDocument({
|
|
38
|
-
externalRefResolver: new BaseResolver(),
|
|
39
|
-
document,
|
|
40
|
-
config: await makeConfig({ rules: {} }),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should report on `body` inside parameter `in` field', async () => {
|
|
47
|
-
const results = await lintDocument({
|
|
48
|
-
externalRefResolver: new BaseResolver(),
|
|
49
|
-
document,
|
|
50
|
-
config: await makeConfig({
|
|
51
|
-
rules: { 'parameters-not-in-body': 'error' },
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
56
|
-
[
|
|
57
|
-
{
|
|
58
|
-
"location": [
|
|
59
|
-
{
|
|
60
|
-
"pointer": "#/workflows/0/parameters/0/in",
|
|
61
|
-
"reportOnKey": false,
|
|
62
|
-
"source": "arazzo.yaml",
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
"message": "The \`body\` value of the \`in\` property is not supported by Spot.",
|
|
66
|
-
"ruleId": "parameters-not-in-body",
|
|
67
|
-
"severity": "error",
|
|
68
|
-
"suggest": [],
|
|
69
|
-
},
|
|
70
|
-
]
|
|
71
|
-
`);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Arazzo1Rule } from '../../visitors';
|
|
2
|
-
import type { UserContext } from '../../walk';
|
|
3
|
-
|
|
4
|
-
export const NoActionsTypeEnd: Arazzo1Rule = () => {
|
|
5
|
-
return {
|
|
6
|
-
FailureActionObject: {
|
|
7
|
-
enter(action, { report, location }: UserContext) {
|
|
8
|
-
if (action.type === 'end') {
|
|
9
|
-
report({
|
|
10
|
-
message: 'The `end` type action is not supported by Spot.',
|
|
11
|
-
location: location.child(['type']),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
SuccessActionObject: {
|
|
17
|
-
enter(action, { report, location }: UserContext) {
|
|
18
|
-
if (action.type === 'end') {
|
|
19
|
-
report({
|
|
20
|
-
message: 'The `end` type action is not supported by Spot.',
|
|
21
|
-
location: location.child(['type']),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Arazzo1Rule } from '../../visitors';
|
|
2
|
-
import type { UserContext } from '../../walk';
|
|
3
|
-
|
|
4
|
-
export const ParametersNotInBody: Arazzo1Rule = () => {
|
|
5
|
-
return {
|
|
6
|
-
Parameter: {
|
|
7
|
-
enter(parameter, { report, location }: UserContext) {
|
|
8
|
-
if (parameter.in === 'body') {
|
|
9
|
-
report({
|
|
10
|
-
message: 'The `body` value of the `in` property is not supported by Spot.',
|
|
11
|
-
location: location.child(['in']),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|