You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In case the built-in schema function is used for validation and custom errorMessages are provided (including the configuration allErrors: true), the messages only show up if neither message or description of the rule is provided.
extends: ["spectral:oas"]
rules:
must-use-valid-special-property:
message: Must use special property definition
description: Checks for special property definition
severity: error
given:
- $..special_property
then:
- function: schema
functionOptions:
schema:
type: object
properties:
type:
type: string
const: string
errorMessage: "\"type\" property must be equal to `\"string\"` instead of `${0}`."
maxLength:
type: integer
const: 3
errorMessage: "\"maxLength\" of special property must be set to `3` instead of `${0}`."
required: [type, maxLength]
allErrors: true
Run this CLI command npx spectral lint -r .spectral.yaml spec.yaml
See the output
spec.yaml
32:17 error must-use-valid-special-property Must use special property definition components.schemas.Response.properties.special_property.type
33:22 error must-use-valid-special-property Must use special property definition components.schemas.Response.properties.special_property.maxLength
Expected behavior
As individual errorMessages are provided and the option allErrors: true is set, I'd expect to receive the following instead:
spec.yaml
32:17 error must-use-valid-special-property "type" property must be equal to `"string"` instead of `"integer"`. components.schemas.Response.properties.special_property.type
33:22 error must-use-valid-special-property "maxLength" of special property must be set to `3` instead of `2`. components.schemas.Response.properties.special_property.maxLength
In case I comment message: Must use special property definition the description text is shown instead which also doesn't meet my expectations.
Only if both message and description properties of the rule are not set I'm getting the expected behavior.
Environment (remove any that are not applicable):
npx spectral --version
6.14.2
The text was updated successfully, but these errors were encountered:
Describe the bug
In case the built-in
schema
function is used for validation and customerrorMessage
s are provided (including the configurationallErrors: true
), the messages only show up if neithermessage
ordescription
of the rule is provided.To Reproduce
spec.yaml
and the rules file
.spectral.yaml
npx spectral lint -r .spectral.yaml spec.yaml
Expected behavior
As individual
errorMessage
s are provided and the optionallErrors: true
is set, I'd expect to receive the following instead:In case I comment
message: Must use special property definition
thedescription
text is shown instead which also doesn't meet my expectations.Only if both
message
anddescription
properties of the rule are not set I'm getting the expected behavior.Environment (remove any that are not applicable):
6.14.2
The text was updated successfully, but these errors were encountered: