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

schema-path falsy values and JSON path expression in field #916

Closed
P0lip opened this issue Jan 14, 2020 · 6 comments · Fixed by #917
Closed

schema-path falsy values and JSON path expression in field #916

P0lip opened this issue Jan 14, 2020 · 6 comments · Fixed by #917
Assignees
Labels
t/bug Something isn't working

Comments

@P0lip
Copy link
Contributor

P0lip commented Jan 14, 2020

Describe the bug
Schema-path function cannot take JSON Path expressions as fields. Furthermore, it doesn't lint falsy values correctly.

Additional context
https://community.stoplight.io/t/spectral-validation-of-examples/1037

@P0lip P0lip added the t/bug Something isn't working label Jan 14, 2020
@P0lip P0lip self-assigned this Jan 14, 2020
@m-mohr
Copy link
Contributor

m-mohr commented Jan 15, 2020

I guess that's the same issue as #901?!

@P0lip
Copy link
Contributor Author

P0lip commented Jan 15, 2020

@m-mohr the issue raised in the forum is in fact similar.
What I'm fixing here is the schema-path function, though, so #901 will still need to be addressed.

@m-mohr
Copy link
Contributor

m-mohr commented Jan 15, 2020

@P0lip If it opens the possibility to properly address the examples.*.values in field, I guess that's an easy fix for #901 though?!

@P0lip
Copy link
Contributor Author

P0lip commented Jan 15, 2020

@m-mohr Yes, agreed.
Such a rule should do the trick I believe:

examples-responses-are-valid:
  message: "{{error}}"
  severity: error
  given: "$.components.responses..[?(@property !== 'properties' && @.examples)]"
  then:
    function: schemaPath
    functionOptions:
      field: "$.examples.*"
      schemaPath: "$.schema"

@m-mohr
Copy link
Contributor

m-mohr commented Jan 15, 2020

@P0lip I think it should be $.examples.*.value to ensure it's the value that you check and not an externalValue. And also, we would probably want all the paths from #901 to be checked?!

@P0lip
Copy link
Contributor Author

P0lip commented Jan 15, 2020

@m-mohr
You might be right, as I didn't think of that case you mentioned.

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