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

Missing source in result object #1515

Closed
stanleynguyen opened this issue Feb 23, 2021 · 3 comments · Fixed by #1531
Closed

Missing source in result object #1515

stanleynguyen opened this issue Feb 23, 2021 · 3 comments · Fixed by #1531
Assignees
Labels
t/bug Something isn't working
Milestone

Comments

@stanleynguyen
Copy link

For support questions, please use the Stoplight Community Forum. This repository's issues are reserved for feature requests and bug reports. If you are unsure if you are experiencing a bug, the Community Forum is a great place to start.

Please delete this section, any any sections below that you don't use, before creating the issue.

Describe the bug
I'm not able to see an error in the list of issues. After a bit of debugging, I found that this function is leaving that error out due to missing source

Screenshot 2021-02-23 at 17 46 37

To Reproduce

Given this custom function

function errorStructure(schemaToBeTested, _, paths) {
  const results = [];
  if (schemaToBeTested.type !== "object") {
    results.push({
      message: "Error response must be a JSON object",
      path: paths.target,
    });
  }
  return results
}

Applied on an empty schema ref

schema:
  $ref: ""

Expected behavior
The error should be displayed

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (remove any that are not applicable):

  • Library version: 5.8.1
  • OS: Mac
  • I'm using Spectral CLI

Additional context
Add any other context about the problem here.

@stanleynguyen stanleynguyen added the t/bug Something isn't working label Feb 23, 2021
@P0lip
Copy link
Contributor

P0lip commented Feb 26, 2021

Hey!
Could you provide a rule definition you use?

@stanleynguyen
Copy link
Author

Hey @P0lip the rule definite is as below:

error-response-structure:
    description: 4xx and 5xx response body must follow error response structure
    message: "{{error}}"
    given: $.paths.*.*.responses.[400,401,403,404,500].content.application/json.schema
    severity: error
    then:
      function: errorStructure

@stanleynguyen
Copy link
Author

Thanks @P0lip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants