-
Notifications
You must be signed in to change notification settings - Fork 42
Ensure properties are dereferenced before comparing equality #329
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
Conversation
|
I see the test fails with I took the spec: {
"swagger": "2.0",
"info": {
"title": "compatible-properties-ref",
"version": "1.0"
},
"paths": {
},
"definitions": {
"FooBarString": {
"type":"object",
"properties": {
"bar": {
"type":"string"
}
},
"allOf": [
{
"$ref": "#/definitions/FooBarStringRef"
}
]
},
"FooBarStringRef": {
"type":"object",
"properties": {
"bar": {
"$ref":"#/definitions/MyString"
}
}
},
"MyString": {
"type": "string"
}
}
}and pasted it here: I got no errors in both cases. Looking at that screenshot, both definitions have the same Interestingly, when I make Then |
|
OK I think I know what is the root-cause. The problem lies in openapi-diff logic. We throw error from here Which will happen if this line returns true:
On the failing test it evaluates to:
Now inside the
On the failing test it evaluates to:
which is As a result, the
which will evaluate like that:
Basically, the logic of |
Co-authored-by: Mike Harder <mharder@microsoft.com>
Fix the `incompatible properties` problem
|
@mikeharder I think you may want to change the PR title before merging to mention it fixes the bug. |
mikekistler
left a comment
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.
Looks good! 👍



@johanste, @markcowl, @JeffreyRichter, @allenjzhang, @mikekistler: Please object if anything about this change looks wrong to you.
In summary, the change always calls
dereference()on a property with a$ref, before comparing equality.This looks pretty safe to me and @konrad-jamrozik, and passes the new unit test we wrote (plus all existing tests).