-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: wip config validation, extend types before
- Loading branch information
1 parent
9456460
commit 43a7883
Showing
21 changed files
with
368 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@redocly/openapi-core": minor | ||
"@redocly/cli": minor | ||
--- | ||
|
||
Changed resolution process to include extendedTypes and plugins before linting. |
7 changes: 7 additions & 0 deletions
7
__tests__/check-config/config-type-extensions-in-assertions/openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Food Empire API | ||
version: 0.5.1 | ||
x-metadata: | ||
lifecycle: production | ||
owner-team: Engineering/Integrations |
27 changes: 27 additions & 0 deletions
27
__tests__/check-config/config-type-extensions-in-assertions/plugins/type-extention.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const XMetaData = { | ||
properties: { | ||
lifecycle: { type: 'string', enum: ['development', 'staging', 'production'] }, | ||
'owner-team': { type: 'string' }, | ||
}, | ||
required: ['lifecycle'], | ||
}; | ||
|
||
module.exports = { | ||
id: 'type-extension', | ||
typeExtension: { | ||
oas3(types) { | ||
newTypes = { | ||
...types, | ||
XMetaData: XMetaData, | ||
Info: { | ||
...types.Info, | ||
properties: { | ||
...types.Info.properties, | ||
'x-metadata': 'XMetaData', | ||
}, | ||
}, | ||
}; | ||
return newTypes; | ||
}, | ||
}, | ||
}; |
13 changes: 13 additions & 0 deletions
13
__tests__/check-config/config-type-extensions-in-assertions/redocly.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends: [] | ||
|
||
plugins: | ||
- plugins/type-extention.js | ||
|
||
rules: | ||
spec: warn | ||
rule/metadata-lifecycle: | ||
subject: | ||
type: XMetaData | ||
property: 'lifecycle' | ||
assertions: | ||
enum: ['alpha', 'beta', 'production', 'deprecated'] |
7 changes: 7 additions & 0 deletions
7
__tests__/check-config/config-type-extensions-in-assertions/snapshot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E check-config config type extension in assertions 1`] = ` | ||
✅ Your config is valid. | ||
`; |
7 changes: 7 additions & 0 deletions
7
__tests__/check-config/wrong-config-type-extensions-in-assertions/openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Food Empire API | ||
version: 0.5.1 | ||
x-metadata: | ||
lifecycle: production | ||
owner-team: Engineering/Integrations |
27 changes: 27 additions & 0 deletions
27
__tests__/check-config/wrong-config-type-extensions-in-assertions/plugins/type-extention.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const XMetaData = { | ||
properties: { | ||
lifecycle: { type: 'string', enum: ['development', 'staging', 'production'] }, | ||
'owner-team': { type: 'string' }, | ||
}, | ||
required: ['lifecycle'], | ||
}; | ||
|
||
module.exports = { | ||
id: 'type-extension', | ||
typeExtension: { | ||
oas3(types) { | ||
newTypes = { | ||
...types, | ||
XMetaData: XMetaData, | ||
Info: { | ||
...types.Info, | ||
properties: { | ||
...types.Info.properties, | ||
'x-metadata': 'XMetaData', | ||
}, | ||
}, | ||
}; | ||
return newTypes; | ||
}, | ||
}, | ||
}; |
13 changes: 13 additions & 0 deletions
13
__tests__/check-config/wrong-config-type-extensions-in-assertions/redocly.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends: [] | ||
|
||
plugins: | ||
- plugins/type-extention.js | ||
|
||
rules: | ||
spec: warn | ||
rule/metadata-lifecycle: | ||
subject: | ||
type: WrongXMetaData | ||
property: 'lifecycle' | ||
assertions: | ||
enum: ['alpha', 'beta', 'production', 'deprecated'] |
22 changes: 22 additions & 0 deletions
22
__tests__/check-config/wrong-config-type-extensions-in-assertions/snapshot.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
__tests__/lint-config/invalid-config-assertation-config-type/snapshot.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.