-
-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Bug
When using the casing
function in validation rule, Spectral and Vacuum are not compatible with its functionOptions
when specifying a separator character.
# Spectral
...
then:
function: casing
functionOptions:
type: pascal
separator:
char: '-'
# Vacuum
...
then:
function: casing
functionOptions:
type: pascal
separator.char: '-'
Repro
Lib versions:
- @quobix/vacuum: 0.16.9
- @stoplight/spectral-cli: 6.15.0
- node: 22.14.0
I have a spectral rule that is defined as follows:
rules:
must-use-pascal-case-on-headers:
description: Headers must be Pascal-Case (w/ hyphens separators).
message: "Header {{property}} must be Pascal-Case (capitalized and separated with hyphens)"
severity: error
given:
- $.paths.*.*.parameters[?(@ && @.in=='header')].name
- $.paths.*.*.responses.*.headers[*]~
then:
function: casing
functionOptions:
type: pascal
separator:
char: '-'
If I try running vacuum, then I get the following error:
'casing' function has invalid options supplied. Example valid options are 'type' = 'camel' or 'disallowDigits' = true: property 'separator' is not a valid property for 'casing'
If I fix my rule functionOptions
this way:
rules:
must-use-pascal-case-on-headers:
description: Headers must be Pascal-Case (w/ hyphens separators).
message: "Header {{property}} must be Pascal-Case (capitalized and separated with hyphens)"
severity: error
given:
- $.paths.*.*.parameters[?(@ && @.in=='header')].name
- $.paths.*.*.responses.*.headers[*]~
then:
function: casing
functionOptions:
type: pascal
separator.char: '-'
Then it works in Vacuum, but fails in Spectral:
Error running Spectral!
Use --verbose flag to print the error stack.
Error #1: "casing" function does not support "separator.char" option
Metadata
Metadata
Assignees
Labels
No labels