Skip to content
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

How to return the key in message prop with configurable rules syntax #1279

Open
jeremyfiel opened this issue Oct 2, 2023 · 5 comments
Open
Labels
configurable rules good first issue Good for newcomers governance Issues relating to problems with or requests for API governance/linting/decorating p3 Type: Bug Something isn't working Type: Enhancement

Comments

@jeremyfiel
Copy link
Contributor

jeremyfiel commented Oct 2, 2023

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}}
@jeremyfiel jeremyfiel changed the title How to return the key in message prop with assertions syntax How to return the key in message prop with configurable rules syntax Oct 2, 2023
@jeremyfiel
Copy link
Contributor Author

jeremyfiel commented Oct 3, 2023

seems I requested something similar in an earlier conversation. Did you ever make an issue for placeholders?
#817 (comment)

@tatomyr
Copy link
Contributor

tatomyr commented Oct 11, 2023

Yeah, the templates seem to be broken. Thanks for reporting! This looks like a bug and an enhancement at the same time.

@tatomyr
Copy link
Contributor

tatomyr commented Oct 11, 2023

The issue is there's no reference in the --stylish mode and this will allow to show some meaningful output.

@tatomyr tatomyr added p3 Type: Bug Something isn't working labels Oct 11, 2023
@lornajane lornajane added the governance Issues relating to problems with or requests for API governance/linting/decorating label Nov 17, 2023
@tatomyr tatomyr added the good first issue Good for newcomers label Dec 28, 2023
@jeremyfiel
Copy link
Contributor Author

circling back to this.. Any news on progress here?

@tatomyr
Copy link
Contributor

tatomyr commented May 20, 2024

Sorry, haven't had a chance to look into it yet. A lot of other priorities at the moment 😄.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configurable rules good first issue Good for newcomers governance Issues relating to problems with or requests for API governance/linting/decorating p3 Type: Bug Something isn't working Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants