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

implement request/response allOf checkers #340

Merged
merged 9 commits into from
Jul 27, 2023

Conversation

tibulca
Copy link
Contributor

@tibulca tibulca commented Jul 24, 2023

No description provided.

if mediaTypeDiff.SchemaDiff.AllOfDiff != nil && mediaTypeDiff.SchemaDiff.AllOfDiff.Added > 0 {
result = append(result, ApiChange{
Id: "request-body-all-of-added",
Level: ERR,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

if mediaTypeDiff.SchemaDiff.AllOfDiff != nil && mediaTypeDiff.SchemaDiff.AllOfDiff.Deleted > 0 {
result = append(result, ApiChange{
Id: "request-body-all-of-removed",
Level: ERR,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why this is breaking:
Suppose a client sends a request body and it matched "All Of" the schemas in the spec, now we remove one of the allOf specs, the same request body will still match.
Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, the request body will still match if one of the allOf specs is removed.
I changed to WARN and the BC message to // BC: removing 'allOf' schema from the request body or request body property is breaking with warn, similar (level + BC message) to what we have for request-property-removed.
They are very similar, in the case of allOf we remove one or more properties from the request.
WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see what you mean, and I agree with your solution, but I'd like to clarify the explanation for the record:
Removing a schema from allOf, could result in the effective removal of a property, and as such, it should be treated like request-property-removed.
However, removing a schema from allOf, doesn't necessarily result in the removal of a property, for example when the 2nd object is removed here:

schema:
  allOf:
    - type: object
      properties:
        prop1:
          type: string
          description: Some description
    - type: object
      properties:
        prop1:
          type: string
          maxLength: 30

if propertyDiff.AllOfDiff.Added > 0 {
result = append(result, ApiChange{
Id: "request-property-all-of-added",
Level: ERR,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

if propertyDiff.AllOfDiff.Deleted > 0 {
result = append(result, ApiChange{
Id: "request-property-all-of-removed",
Level: ERR,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

breaking change

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2023

Codecov Report

Merging #340 (d76b6a0) into main (bf70927) will increase coverage by 0.32%.
The diff coverage is 97.60%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #340      +/-   ##
==========================================
+ Coverage   79.03%   79.36%   +0.32%     
==========================================
  Files         186      188       +2     
  Lines        9601     9768     +167     
==========================================
+ Hits         7588     7752     +164     
- Misses       1724     1725       +1     
- Partials      289      291       +2     
Flag Coverage Δ
unittests 79.36% <97.60%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
checker/check-request-property-all-of-updated.go 97.50% <97.50%> (ø)
checker/check-response-property-all-of-updated.go 97.64% <97.64%> (ø)
checker/default_checks.go 91.37% <100.00%> (+0.15%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@blva blva left a comment

Choose a reason for hiding this comment

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

LGTM

@tibulca tibulca requested a review from reuvenharrison July 27, 2023 00:19
@reuvenharrison reuvenharrison merged commit 3762745 into Tufin:main Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants