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

fix: schema validation and ajv not working #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jarlah
Copy link

@jarlah jarlah commented Jan 5, 2024

I encountered an issue where missing required fields did not cause test failures. I therefore debugged the contract generator and found ajv was used in a wrong way. https://ajv.js.org shows the usage I have changed it to

@jarlah
Copy link
Author

jarlah commented Jan 5, 2024

plus, I moved console log of errors above pm expect since it doesn't continue if it fails

@jarlah
Copy link
Author

jarlah commented Jan 5, 2024

This is actually a pretty hard bug to spot, if you dont force tests to fail by changing openapi spec to include required schema fields that are not present in response json.

Can you look at this @allenheltondev ?

@jarlah
Copy link
Author

jarlah commented Jan 5, 2024

im unsure if the block above that checks ref is correct, because I have only responses with schema in my spec. But should we change that too? or is it correct, based on the fact that it doesn't compile and just runs validate directly ? maybe some differences in usage in ajv ?

@jarlah
Copy link
Author

jarlah commented Jan 5, 2024

@jarlah
Copy link
Author

jarlah commented Jan 5, 2024

not able to force the if statement for expectedResponse.$ref to be true. Even when I set

responses:
    "200":
      $ref: '../responses/MyResponse.yaml'

it has a schema still. The schema of MyResponse. So maybe the first can be removed ?

I see in should shouldResponseBeEmpty that there is a check against #/components/responses if $ref attribute exists .. but my approach of splitting up the yaml files work pretty ok with postman and all other openapi tools. Even if I use relative paths in the project with the openapi spec, its converted to #/components/ references when I export the openapi spec from the tool that imported it

@jarlah jarlah mentioned this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant