Skip to content

Commit

Permalink
fix(ruleset-migrator): validate aliases correctly (#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip authored Mar 10, 2022
1 parent c86c504 commit 1f4ab20
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
aliases: {
PathItem: '$.paths[*][*]',
Description: '$..description',
Name: '$..name',
PathItem: ['$.paths[*][*]'],
Description: ['$..description'],
Name: ['$..name'],
},
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
aliases: {
PathItem: '$.paths[*][*]',
Description: '$..description',
Name: '$..name',
PathItem: ['$.paths[*][*]'],
Description: ['$..description'],
Name: ['$..name'],
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
aliases:
PathItem: $.paths[*][*]
Description: $..description
Name: $..name
PathItem:
- $.paths[*][*]
Description:
- $..description
Name:
- $..name
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module.exports = {
targets: [
{
formats: [oas2],
given: '$.definitions[*]',
given: ['$.definitions[*]'],
},
{
formats: [oas3_0, oas3_1],
given: '$.components.schemas[*]',
given: ['$.components.schemas[*]'],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export default {
targets: [
{
formats: [oas2],
given: '$.definitions[*]',
given: ['$.definitions[*]'],
},
{
formats: [oas3_0, oas3_1],
given: '$.components.schemas[*]',
given: ['$.components.schemas[*]'],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ aliases:
targets:
- formats:
- oas2
given: $.definitions[*]
given:
- $.definitions[*]
- formats:
- oas3.0
- oas3.1
given: $.components.schemas[*]
given:
- $.components.schemas[*]
10 changes: 8 additions & 2 deletions packages/ruleset-migrator/src/validation/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const schema = {
additionalProperties: {
oneOf: [
{
type: 'string',
type: 'array',
items: {
type: 'string',
},
},
{
type: 'object',
Expand All @@ -27,7 +30,10 @@ const schema = {
$ref: '#/properties/formats',
},
given: {
type: 'string',
type: 'array',
items: {
type: 'string',
},
},
},
required: ['formats', 'given'],
Expand Down
6 changes: 3 additions & 3 deletions packages/ruleset-migrator/src/validation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export interface Ruleset {
aliases?: {
[k: string]:
| string
| string[]
| {
description?: string;
targets: [
Expand Down Expand Up @@ -42,7 +42,7 @@ export interface Ruleset {
| 'json-schema-2020-12'
)[]
];
given: string;
given: string[];
[k: string]: unknown;
},
...{
Expand Down Expand Up @@ -80,7 +80,7 @@ export interface Ruleset {
| 'json-schema-2020-12'
)[]
];
given: string;
given: string[];
[k: string]: unknown;
}[]
];
Expand Down

0 comments on commit 1f4ab20

Please sign in to comment.