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: Validate missing response description #186

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

rmkeezer
Copy link
Contributor

Throw error when a description is missing for any response schema since failing to do so will cause a compilier error.

@rmkeezer rmkeezer requested a review from dpopp07 August 10, 2020 15:00
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.

This is a good addition, thanks for the PR. Just two small changes to make

`A ${statusCode} response should include a description.`,
'error'
);
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks good. I actually think we should move this check up to line 55 since this is required of all responses, not just success responses.

@rmkeezer rmkeezer force-pushed the missing_response_description branch 2 times, most recently from b9f5fb5 to bb500d6 Compare August 11, 2020 13:22
@rmkeezer rmkeezer requested a review from dpopp07 August 11, 2020 13:22
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.

Sorry to be a little picky, but requesting one more round of changes and then will approve

@@ -52,6 +52,13 @@ module.exports.validate = function({ resolvedSpec }, config) {
} else {
// default warnings for discouraged status code per IBM API Handbook
Copy link
Member

Choose a reason for hiding this comment

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

Okay I have to be a little obnoxious here but for the sake of clarity, this comment should be moved to be just before if (statusCode === '422') {. Those are the checks the comment describes, so it is a little confusing to leave here as if it applies to everything.

if (!obj[statusCode].description) {
messages.addMessage(
path.concat([statusCode]),
`A ${statusCode} response should include a description.`,
Copy link
Member

Choose a reason for hiding this comment

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

I didn't look at this close enough last time - because this check is an unconditional requirement and applies to every response, this message is slightly misleading. I think it should be changed to

Suggested change
`A ${statusCode} response should include a description.`,
'All responses must include a description.',

@rmkeezer rmkeezer force-pushed the missing_response_description branch from bb500d6 to dda9a63 Compare August 11, 2020 14:57
@rmkeezer rmkeezer requested a review from dpopp07 August 11, 2020 14:58
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! Thanks 👍

@dpopp07 dpopp07 merged commit 751c18d into IBM:master Aug 11, 2020
dpopp07 pushed a commit that referenced this pull request Aug 11, 2020
# [0.29.0](v0.28.1...v0.29.0) (2020-08-11)

### Features

* Validate missing response descriptions ([#186](#186)) ([751c18d](751c18d))
@dpopp07
Copy link
Member

dpopp07 commented Aug 11, 2020

🎉 This PR is included in version 0.29.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