Azure / openapi-diff

Command line tool to detect breaking changes between two openapi specifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes made to "$ref" files, and not swagger.json

rao-anant opened this issue · comments

Hello,
If I made changes to swagger.file, the tool has no issues to find any backward-incompatible problems.
If I, however, made changes to the "object" files that are referenced, by way of "$ref", from the swagger.json file and run this tool against the two "object" files, say X-before.json and X-after.json, it doesn't show any discrepancies. Is it the way it currently works?

Just to be clear:
swagger.json
{
...
"abc": {
"schema": {
"$ref": "X.json"
}
....
}
}

X.json:
{
"type": "object",
"properties": {
"foo": { ...
},
"bar": {...
}
}
}

I change it to a swagger-like file as:
X-mod.json:
{
"swagger": "...",
"version": "..."
"paths": {
"/": {
"parameters": [
{"name": "foo",...},
{"name": "bar",...}
]
}
}
}

How I fixed the problem is I convert the 'X.json' (object) file into a proper swagger file like adding definitions, and converting the properties into parameters of a fake GET path, which is a lot of JSON jugglery. Now, as the file X.json is a proper swagger API file, the tool has no issues finding any problems.

Why am I running the tool against each file individually, instead of a single swagger.file with all "$ref"s resolved? The reason is the line numbers shown in that case are out of whack - they point to the combined file and it's very difficult to map them back to the individual files like X.json. I agree even in my approach, a similar issue remains; however, the file name is always correct and the line numbers are very close to the problem site.

Is there a better way to solve it?
Thanks very much!

Is it the way it currently works?
yes, currently it's used to diff two swagger files, which means it will only compare properties like 'definitions','paths','parameters' in the object which are considered as swagger objects

Thanks!