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

Compare inline schemas under AllOf/AnyOf/OneOf by title #527

Conversation

reuvenharrison
Copy link
Collaborator

@reuvenharrison reuvenharrison commented Apr 15, 2024

This PR improves comparison of subschemas under AllOf/AnyOf/OneOf with the following capabilities:

  1. Ability to compare subschemas that have the same title to each other
  2. Improved diff output format
  3. Improved messages for breaking changes and changelog (note: you may need to update exception files)

Diff Before:

anyOf:
    added:
        - Fox
        - RevisionSchema[2]:Rabbit
        - RevisionSchema[4]
    deleted:
        - BaseSchema[2]:Rabbit
        - BaseSchema[3]
    modified:
        '#/components/schemas/Dog':
            properties:
                modified:
                    breed:
                        anyOf:
                            modified:
                                '#/components/schemas/Breed2':
                                    properties:
                                        modified:
                                            name:
                                                type:
                                                    from: string
                                                    to: number

Diff After:

anyOf:
    added:
        - index: 3
          component: Fox
    modified:
        - base:
            index: 0
            component: Dog
          revision:
            index: 0
            component: Dog
          diff:
            properties:
                modified:
                    breed:
                        anyOf:
                            modified:
                                - base:
                                    index: 1
                                    component: Breed2
                                  revision:
                                    index: 0
                                    component: Breed2
                                  diff:
                                    properties:
                                        modified:
                                            name:
                                                type:
                                                    from: string
                                                    to: number
        - base:
            index: 2
            title: Rabbit
          revision:
            index: 2
            title: Rabbit
          diff:
            type:
                from: string
                to: number
        - base:
            index: 3
          revision:
            index: 4
          diff:
            type:
                from: string
                to: number

Changelog Before

3 changes: 1 error, 0 warning, 2 info
error	[response-property-type-changed] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		the '/anyOf[#/components/schemas/Dog]/breed/anyOf[#/components/schemas/Breed2]/name' response's property type/format changed from 'string'/'' to 'number'/'' for status '200'

info	[response-body-any-of-added] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		added 'Fox, RevisionSchema[2]:Rabbit, RevisionSchema[4]' to the response body 'anyOf' list for the response status '200'

info	[response-body-any-of-removed] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		removed 'BaseSchema[2]:Rabbit, BaseSchema[3]' from the response body 'anyOf' list for the response status '200'

Changelog After

4 changes: 3 error, 0 warning, 1 info
error	[response-property-type-changed] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		the '/anyOf[#/components/schemas/Dog]/breed/anyOf[#/components/schemas/Breed2]/name' response's property type/format changed from 'string'/'' to 'number'/'' for status '200'

error	[response-property-type-changed] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		the '/anyOf[subschema #3: Rabbit]/' response's property type/format changed from 'string'/'' to 'number'/'' for status '200'

error	[response-property-type-changed] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		the '/anyOf[subschema #4 -> subschema #5]/' response's property type/format changed from 'string'/'' to 'number'/'' for status '200'

info	[response-body-any-of-added] at /tmp/response_property_any_of_complex_revision.yaml
	in API GET /pets
		added '#/components/schemas/Fox' to the response body 'anyOf' list for the response status '200'

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 84.12698% with 50 lines in your changes are missing coverage. Please review.

Project coverage is 83.86%. Comparing base (051d11e) to head (2cf2ab8).
Report is 5 commits behind head on main.

Files Patch % Lines
diff/subschemas_diff.go 78.64% 27 Missing and 17 partials ⚠️
diff/modified_subschemas.go 94.64% 2 Missing and 1 partial ⚠️
report/report.go 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #527      +/-   ##
==========================================
+ Coverage   83.29%   83.86%   +0.56%     
==========================================
  Files         226      226              
  Lines       12964    13180     +216     
==========================================
+ Hits        10798    11053     +255     
+ Misses       1745     1705      -40     
- Partials      421      422       +1     
Flag Coverage Δ
unittests 83.86% <84.12%> (+0.56%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@reuvenharrison reuvenharrison merged commit 341d77d into main Apr 24, 2024
16 checks passed
@reuvenharrison reuvenharrison deleted the 514-diff-tool-gets-confused-when-a-new-inline-enum-value-is-added-and-a-new-enum-type-is-added-at-the-sime-time branch April 24, 2024 14:01
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.

Diff tool gets confused when a new inline enum value is added and a new enum type is added at the sime time
1 participant