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

document and test that errors are spat out in a defined order #223

Merged
merged 6 commits into from Oct 5, 2020
Merged

document and test that errors are spat out in a defined order #223

merged 6 commits into from Oct 5, 2020

Conversation

DrHyde
Copy link
Contributor

@DrHyde DrHyde commented Oct 2, 2020

The code change in lib/JSON/Validator.pm appears to be redundant at
the moment, as the tests passed without it, but I'm putting it there
anyway so that any future internals changes that affect ordering don't
suddenly start causing test failures.

Summary

The list of errors spat out by ...->validate() are now guaranteed to be in
a predictable order, which is documented.

Motivation

Documenting the order of errors makes it easier to write tests for error conditions.

References

#222

The code change in lib/JSON/Validator.pm appears to be redundant at
the moment, as the tests passed without it, but I'm putting it there
anyway so that any future internals changes that affect ordering don't
suddenly start causing test failures.
Copy link
Owner

@jhthorsen jhthorsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR 👍

In addition to the inline comments: I don’t think the code is run through perltidy. Please do so, if not.

lib/JSON/Validator.pm Outdated Show resolved Hide resolved
t/predictable-errors.t Outdated Show resolved Hide resolved
t/predictable-errors.t Outdated Show resolved Hide resolved
t/predictable-errors.t Outdated Show resolved Hide resolved
We now rely on perl's hash order randomisation to perturb the order in which
errors are generated internally before we sort them on output
@jhthorsen jhthorsen merged commit 55c488e into jhthorsen:master Oct 5, 2020
jhthorsen pushed a commit that referenced this pull request Oct 5, 2020
 - Errors are now reported in a predictable order #223
   Contributor: David Cantrell
@jhthorsen
Copy link
Owner

Thanks for the PR. This is now part of version 4.05.

I did forget to squash the commits though. Please help me next time, by force pushing changes.

@DrHyde
Copy link
Contributor Author

DrHyde commented Oct 6, 2020

Thanks

jhthorsen pushed a commit that referenced this pull request Jan 24, 2021
 - Add JSON::Validator::Schema::OpenAPIv2
   * Extends JSON::Validator::Schema::Draft4
   * Can validate OpenAPIv2 API specifiation
   * Can validate HTTP request and response
   * Can validate "Accept" and "Content-Type"
   * Can handle "discriminator"
   * Can handle "readOnly" parameters
   * Can handle collectionFormat
   * Can handle default values for parameters
   * Can convert specifiation with invalid "$ref" into a valid OpenAPIv2 specifiation
   * Will coerce query parameters and headers into arrays if needed
 - Add JSON::Validator::Schema::OpenAPIv3
   * Extends JSON::Validator::Schema::Draft201909
   * Can validate OpenAPIv3 API specifiation
   * Can validate HTTP request and response
   * Can validate "Accept" and "Content-Type"
   * Can handle "discriminator"
   * Can handle "nullable" parameters
   * Can handle "readOnly" parameters
   * Can handle "style" and "explode" for arrays and objects parameters
   * Can handle "writeOnly" parameters
   * Can handle default values for parameters
   * Will coerce query parameters and headers into arrays if needed
 - Add negotiate_content_type() utility function
 - Fix t/load-file.t on Windows #234
 - Fix not checking if input schema is a file if it has a newline #223 #233
   Contributor: David Cantrell
 - Improved error message when loading non-existing file #231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants