redocly-cli
redocly-cli copied to clipboard
How to return the key in message prop with configurable rules syntax
Is there a way to return the key() where an error occurs with the configurable rules syntax in the message property?
this is an example of what I'm looking for.
In this example, I want the endpoint where the error occurred. I suppose that may even be the Parent Key.
rule/post-must-define-requestBody:
severity: error
message: POST must define a "requestBody" schema in `/path/of/endpoint/with/error`
subject:
type: Operation
where:
- subject:
type: Operation
filterInParentKeys:
- post
assertions:
defined: true
assertions:
required:
- requestBody
this is my current error received, but I want the ability to pass the key into the message body.
validating specs/talent/performance-management/v1/performance-management-configuration-swagger_v1.json...
specs\talent\performance-management\v1\performance-management-configuration-swagger_v1.json:
786:4 error rule/post-must-define-requestBody POST must define a "requestBody" schema
I tried following the docs but it doesn't work.
Problem message displayed if the assertion is false. If omitted, the default message is: "{{assertionName}} failed because the {{subject}} {{property}} didn't meet the assertions: {{problems}}" is displayed. The available placeholders are displayed in that message. In the case there are multiple properties, the {{property}} placeholder produces a comma and space separate list of properties. In case there are multiple problems, the {{problems}} placeholder produces a bullet-list with a new line between each problem.
rule/post-must-define-requestBody:
severity: error
message: POST must define a "requestBody" schema {{property}}
subject:
type: Operation
where:
- subject:
type: Operation
filterInParentKeys:
- post
assertions:
defined: true
assertions:
required:
- requestBody
validating specs/core/questionnaires/v3/tax-statutory-questionnaires-swagger_v3.json...
specs\core\questionnaires\v3\tax-statutory-questionnaires-swagger_v3.json:
29:4 error rule/post-must-define-requestBody POST must define a "requestBody" schema {{property}}
seems I requested something similar in an earlier conversation. Did you ever make an issue for placeholders?
https://github.com/Redocly/redocly-cli/issues/817#issuecomment-1222839131
Yeah, the templates seem to be broken. Thanks for reporting! This looks like a bug and an enhancement at the same time.
The issue is there's no reference in the --stylish mode and this will allow to show some meaningful output.
circling back to this.. Any news on progress here?
Sorry, haven't had a chance to look into it yet. A lot of other priorities at the moment 😄.