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

feat: adds a default warning for 422 and 302 responses #154

Merged
merged 1 commit into from
Mar 16, 2020
Merged

Conversation

barrett-schonefeld
Copy link
Contributor

@barrett-schonefeld barrett-schonefeld commented Mar 10, 2020

Reason:

  • IBM Handbook says 400 response should be used instead of 422
  • IBM Handbook prefers 303 and 307 responses over 302

Changes:

  • added warning for 422 response codes
  • added warning for 302 response codes
  • added ibm_status_code_guidelines config option with default warning

Tests

  • added a test to ensure warning issued for 422 response
  • added a test to ensure warning issued for 302 response

@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #154 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
+ Coverage    93.1%   93.11%   +0.01%     
==========================================
  Files          61       61              
  Lines        2131     2136       +5     
==========================================
+ Hits         1984     1989       +5     
  Misses        147      147
Impacted Files Coverage Δ
src/.defaultsForValidator.js 100% <ø> (ø) ⬆️
...s/validation/oas3/semantic-validators/responses.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 a8ca2e8...ccdb9d3. Read the comment docs.

Copy link
Member

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

I like the idea. We might as well exhaust the discouraged status code in the handbook while we're at it

README.md Show resolved Hide resolved
@barrett-schonefeld barrett-schonefeld changed the title feat: adds a default warning for 422 responses feat: adds a default warning for 422 and 302 responses Mar 13, 2020
@barrett-schonefeld
Copy link
Contributor Author

I changed the structure a bit. Since these 302 and 422 warnings are similar, I put the checks in one for-loop rather than in the top level if-else statement.

Now the module says, "If no status codes, error. Else, check for discouraged status codes and validate success codes."

Copy link
Member

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

Only one small change to make - I will merge after

- IBM Handbook says 400 response should be used instead of 422
- IBM Handbook prefers 303 and 307 responses over 302
- added ibm_status_code_guidelines config option with default warning
- added a test to ensure warning issued for 422 response
- added a test to ensure warning issued for 302 response
Copy link
Member

@dpopp07 dpopp07 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 4d5ba65 into master Mar 16, 2020
@dpopp07 dpopp07 deleted the 422-response branch March 16, 2020 15:57
dpopp07 pushed a commit that referenced this pull request Mar 16, 2020
# [0.26.0](v0.25.0...v0.26.0) (2020-03-16)

### Features

* adds a check for 422 and 302 status codes ([#154](#154)) ([4d5ba65](4d5ba65))
@dpopp07
Copy link
Member

dpopp07 commented Mar 16, 2020

🎉 This PR is included in version 0.26.0 🎉

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.

2 participants