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

References under paths are compared only by ref name - oasdiff should compare the ref values. #276

Open
reuvenharrison opened this issue Jun 1, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@reuvenharrison
Copy link
Collaborator

Describe the bug
When a Path Item Object contains a $ref, oasdiff compares only textual changes to the $ref field.
Ideally, oasdiff should compare the referenced definitions of this path item(s) to each-other.

To Reproduce
Steps to reproduce the behavior:
Run oasdiff -base ref1.yaml -revision ref2.yaml

ref1.yaml

openapi: 3.0.1
info:
  title: Test API
  version: v1
paths:
  /partner-api/test/some-method:
    $ref: '#/components/paths/path1'
components:
  paths:
    path1:
      get:
        responses:
          "200":
            description: Success

ref2.yaml

openapi: 3.0.1
info:
  title: Test API
  version: v1
paths:
  /partner-api/test/some-method:
    $ref: '#/components/paths/path2'
components:
  paths:
    path2:
      get:
        responses:
          "200":
            description: Success

Result:

paths:
    modified:
        /partner-api/test/some-method:
            ref:
                from: '#/components/paths/path1'
                to: '#/components/paths/path2'
@reuvenharrison reuvenharrison added the bug Something isn't working label Jun 1, 2023
@reuvenharrison reuvenharrison changed the title paths $refs are compared only by name References under paths are compared only by ref name - oasdiff should compare the ref values. Jun 1, 2023
@wtrocki
Copy link
Contributor

wtrocki commented Jun 1, 2023

I'm happy to work on this issue.

@wtrocki
Copy link
Contributor

wtrocki commented Jun 21, 2023

@reuvenharrison I had some attempts to fix this by creating new diff category:

// RefDiff describes the changes between content refs
type RefDiff struct {
	RefModifled []string `json:"refModified,omitempty" yaml:"refModified,omitempty"`
}

type RequestBodyDiff struct {
        ... 
	RefDiff			*RefDiff     	    `json:"ref,omitempty" yaml:"ref,omitempty"`
}

Do you think this is the good way to approach this problem?

I noticed we also have RefDiff *ValueDiff in PathDiff object.

@wtrocki
Copy link
Contributor

wtrocki commented Jun 23, 2023

Going to use RefDiff *ValueDif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants