Skip to content

Commit 1f4ab20

Browse files
authored
fix(ruleset-migrator): validate aliases correctly (stoplightio#2085)
1 parent c86c504 commit 1f4ab20

File tree

8 files changed

+31
-20
lines changed

8 files changed

+31
-20
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
aliases: {
3-
PathItem: '$.paths[*][*]',
4-
Description: '$..description',
5-
Name: '$..name',
3+
PathItem: ['$.paths[*][*]'],
4+
Description: ['$..description'],
5+
Name: ['$..name'],
66
},
77
};
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
aliases: {
3-
PathItem: '$.paths[*][*]',
4-
Description: '$..description',
5-
Name: '$..name',
3+
PathItem: ['$.paths[*][*]'],
4+
Description: ['$..description'],
5+
Name: ['$..name'],
66
},
77
};
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
aliases:
2-
PathItem: $.paths[*][*]
3-
Description: $..description
4-
Name: $..name
2+
PathItem:
3+
- $.paths[*][*]
4+
Description:
5+
- $..description
6+
Name:
7+
- $..name

packages/ruleset-migrator/src/__tests__/__fixtures__/aliases-variant-2/output.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ module.exports = {
66
targets: [
77
{
88
formats: [oas2],
9-
given: '$.definitions[*]',
9+
given: ['$.definitions[*]'],
1010
},
1111
{
1212
formats: [oas3_0, oas3_1],
13-
given: '$.components.schemas[*]',
13+
given: ['$.components.schemas[*]'],
1414
},
1515
],
1616
},

packages/ruleset-migrator/src/__tests__/__fixtures__/aliases-variant-2/output.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export default {
66
targets: [
77
{
88
formats: [oas2],
9-
given: '$.definitions[*]',
9+
given: ['$.definitions[*]'],
1010
},
1111
{
1212
formats: [oas3_0, oas3_1],
13-
given: '$.components.schemas[*]',
13+
given: ['$.components.schemas[*]'],
1414
},
1515
],
1616
},

packages/ruleset-migrator/src/__tests__/__fixtures__/aliases-variant-2/ruleset.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ aliases:
44
targets:
55
- formats:
66
- oas2
7-
given: $.definitions[*]
7+
given:
8+
- $.definitions[*]
89
- formats:
910
- oas3.0
1011
- oas3.1
11-
given: $.components.schemas[*]
12+
given:
13+
- $.components.schemas[*]

packages/ruleset-migrator/src/validation/schema.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ const schema = {
99
additionalProperties: {
1010
oneOf: [
1111
{
12-
type: 'string',
12+
type: 'array',
13+
items: {
14+
type: 'string',
15+
},
1316
},
1417
{
1518
type: 'object',
@@ -27,7 +30,10 @@ const schema = {
2730
$ref: '#/properties/formats',
2831
},
2932
given: {
30-
type: 'string',
33+
type: 'array',
34+
items: {
35+
type: 'string',
36+
},
3137
},
3238
},
3339
required: ['formats', 'given'],

packages/ruleset-migrator/src/validation/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export interface Ruleset {
44
aliases?: {
55
[k: string]:
6-
| string
6+
| string[]
77
| {
88
description?: string;
99
targets: [
@@ -42,7 +42,7 @@ export interface Ruleset {
4242
| 'json-schema-2020-12'
4343
)[]
4444
];
45-
given: string;
45+
given: string[];
4646
[k: string]: unknown;
4747
},
4848
...{
@@ -80,7 +80,7 @@ export interface Ruleset {
8080
| 'json-schema-2020-12'
8181
)[]
8282
];
83-
given: string;
83+
given: string[];
8484
[k: string]: unknown;
8585
}[]
8686
];

0 commit comments

Comments
 (0)