-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(functions): schema should respect "auto" dialect #1771
Conversation
@@ -25,11 +25,13 @@ export default createRulesetFunction<unknown, Options>( | |||
}, | |||
dialect: { | |||
enum: ['auto', 'draft4', 'draft6', 'draft7', 'draft2019-09', 'draft2020-12'], | |||
default: 'auto', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated, but I thought it'd be actually cool to express what the default is.
Going to be useful later on in Studio when building forms.
@@ -56,7 +58,9 @@ export default createRulesetFunction<unknown, Options>( | |||
|
|||
try { | |||
let validator; | |||
const dialect = opts?.dialect ?? detectDialect(schemaObj) ?? 'draft7'; | |||
const dialect = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the only actual change
}, | ||
prepareResults: {}, | ||
prepareResults: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is the same as passing an empty object?
@@ -56,7 +58,9 @@ export default createRulesetFunction<unknown, Options>( | |||
|
|||
try { | |||
let validator; | |||
const dialect = opts?.dialect ?? detectDialect(schemaObj) ?? 'draft7'; | |||
const dialect = | |||
(opts.dialect === void 0 || opts.dialect === 'auto' ? detectDialect(schemaObj) : opts?.dialect) ?? 'draft7'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# [@stoplight/spectral-functions-v1.1.2](https://github.com/stoplightio/spectral/compare/@stoplight/spectral-functions-v1.1.1...@stoplight/spectral-functions-v1.1.2) (2021-08-17) ### Bug Fixes * **functions:** schema should respect "auto" dialect ([#1771](#1771)) ([ed1621c](ed1621c))
🎉 This PR is included in version @stoplight/spectral-functions-v1.1.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Currently when you pass "auto" we don't run
detectDialect
function, so nothing useful happens.Checklist
Does this PR introduce a breaking change?