-
Notifications
You must be signed in to change notification settings - Fork 62
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
Breaking change check: New request required default param on existing path #376
Breaking change check: New request required default param on existing path #376
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## main #376 +/- ##
==========================================
+ Coverage 81.74% 81.80% +0.06%
==========================================
Files 194 195 +1
Lines 10589 10624 +35
==========================================
+ Hits 8656 8691 +35
Misses 1635 1635
Partials 298 298
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hi @Jonathan-Rosenberg and thanks for the nice contribution. |
…aultParameterCheck. add NewRequestNonPathDefaultParameterCheck to defaultChecks
Hi @reuvenharrison, |
It seems like this test produces a false-positive when there are no endpoints under the path.
To:
|
Hi @reuvenharrison, |
} | ||
for _, param := range pathItem.Revision.Parameters { | ||
if !paramNameList.Contains(param.Value.Name) { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to report this error on each affected endpoint rather than once per path.
The reason is that ApiChange is designed to report a breaking change at the endpoint (operation level), for example, it has an operation field.
Another reason is that the breaking change may only apply to a subset of the operations, for exampple, consider moving a param from op level to path level.
The downside to this approach is that the error may be reported multiple times, one for each operation, but this is ok since we will eventually support the ability to group breaking changes (see #371).
if !paramNameList.Contains(param.Value.Name) { | ||
continue | ||
} | ||
id := "new-required-request-default-parameter-to-existing-path" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still need to be implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a new issue to handle this
…ram' of https://github.com/jonathan-rosenberg/oasdiff into pr/Jonathan-Rosenberg/376
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check refers to a path rather than an endpoint and because of that the resulting ApiChange lacks the Operation and OperationID fields.
Moreover,
if !paramNameList.Contains(param.Value.Name) { | ||
continue | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of this code makes the check incorrect.
The level will be ERR
even if the parameter wasn't added.
I'm creating a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that it is redundant because we are iterating on pathItem.ParametersDiff.Added
Can you replicate the issue with a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do that, but since the pathItem.Revision.Parameters
field is a slice and not a map, we traverse through it to find the ParameterRef
object that matches the name we found in the Added
map.
PR.
This check will notify a breaking change if a new required default param was added to a request on an existing modified path.