-
Hey folks, I am trying to follow: https://github.com/stoplightio/spectral/pull/939/files which I can't find the documentation for it (probably I missed it for the nth time) I have the following linter error: 40:24 error upper-case-enums Enums must be written in uppercase separated by underscores. paths./compliance/v1/notifications/entities.get.parameters[0].schema.enum[0] I am trying to figure out how to add the rules:
upper-case-enums:
description: Enums must be written in uppercase separated by underscores.
type: validation
recommended: true
severity: error
given: '$..enum.*'
then:
function: casing
functionOptions:
type: macro
except:
"my-file.json#/paths/compliance/v1/notifications/entities/get/parameters[0]/schema/enum[0]":
- upper-case-enums Code snippet about the spec {
"paths": {
"/compliance/v1/notifications/entities": {
"parameters": [],
"get": {
"parameters": [
{
"name": "accountType",
"in": "query",
"allowEmptyValue": false,
"schema": {
"type": "string",
"enum": [
"Credit",
"Debit"
]
}
}
]
}
}
}
} But at this point, I can't tell what is the format in the JSON Path since I tried multiple things, and doesn't work. I would appreciate some help on it, Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey! |
Beta Was this translation helpful? Give feedback.
Hey!
First of all,
exceptions
were superseded by a more powerful feature calledoverrides
. You can find some documentation on them here https://github.com/stoplightio/spectral/blob/develop/docs/guides/4-custom-rulesets.md#overridesThey still work in JSON/YAML rulesets, because ruleset-migrator (the project we use to translate the rulesets into a more native format Spectral can operate on) transforms
exceptions
intooverrides
.Answering your initial question - I think you might need to escape things more properly.
The value after the filepath / glob, has to be a valid JSON Pointer (https://datatracker.ietf.org/doc/html/rfc6901), so I suspect the following should work fine
my-file.json#/~1p…