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: do not crash when operation has illegal $ref, print error instead #103

Merged
merged 1 commit into from
Aug 28, 2019

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented Aug 27, 2019

Currently, the validator will crash if an operation is illegally defined by a $ref. This PR addresses that issue and also prints a warning for an illegal $ref in an operation.

I also added a module to check for $refs when working with the resolved spec as it was needed in a couple of places.

Todo:

  • Write tests for validators that changed

Resolves #100

* add hasRefProperty utility module, refactor some logic to use it
@codecov
Copy link

codecov bot commented Aug 28, 2019

Codecov Report

Merging #103 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #103      +/-   ##
==========================================
+ Coverage   92.04%   92.09%   +0.04%     
==========================================
  Files          52       53       +1     
  Lines        1873     1884      +11     
==========================================
+ Hits         1724     1735      +11     
  Misses        149      149
Impacted Files Coverage Δ
src/plugins/utils/caseConventionCheck.js 93.33% <ø> (ø) ⬆️
src/plugins/utils/hasRefProperty.js 100% <100%> (ø)
...ion/2and3/semantic-validators/operations-shared.js 98.61% <100%> (+0.03%) ⬆️
.../validation/oas3/semantic-validators/operations.js 97.29% <100%> (ø) ⬆️
src/plugins/utils/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3383114...0cd98e0. Read the comment docs.


module.exports.validate = function({ resolvedSpec, isOAS3 }, config) {
module.exports.validate = function({ jsSpec, resolvedSpec, isOAS3 }, config) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Of course! I always thought of validators as operating on either the jsSpec or resolvedSpec, but no reason you can't use both. Nice!

Copy link
Contributor

@mkistler mkistler left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@dpopp07 dpopp07 merged commit 3d34205 into master Aug 28, 2019
@dpopp07 dpopp07 deleted the ref-in-paths branch August 28, 2019 15:56
dpopp07 pushed a commit that referenced this pull request Aug 28, 2019
## [0.13.5](v0.13.4...v0.13.5) (2019-08-28)

### Bug Fixes

* do not crash when operation has illegal $ref, print error instead ([#103](#103)) ([3d34205](3d34205))
@dpopp07
Copy link
Member Author

dpopp07 commented Aug 28, 2019

🎉 This PR is included in version 0.13.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validator fails unexpressively when $ref appears in invalid location
2 participants