While comparing spectraI-cli and Linter API results, I noticed the ranges were different while running the same rules on the same content, it appears that the API always returns line range with a 0 value. It seems that the request body is converted to a one line JSON document before processing (whatever the original format, yaml or json).
API outputs
API Output with YAML request body (range correspond to 1 line JSON)
{
"code": "summary-short",
"failure": {
"source": "<REQUEST_BODY_0>",
"range": {
"start": {
"line": 0,
"character": 101
},
"end": {
"line": 0,
"character": 176
}
}
}
}
API output with JSON request body (range correspond to 1 line JSON)
{
"code": "summary-short",
"failure": {
"source": "<REQUEST_BODY_0>",
"range": {
"start": {
"line": 0,
"character": 101
},
"end": {
"line": 0,
"character": 176
}
}
}
}
API output with 1 line JSON request body (same result as CLI)
{
"code": "summary-short",
"failure": {
"source": "<REQUEST_BODY_0>",
"range": {
"start": {
"line": 0,
"character": 101
},
"end": {
"line": 0,
"character": 176
}
}
}
}
CLI outputs
CLI Output with YAML file (correct line ranges)
{
"code": "summary-short",
"range": {
"start": {
"line": 8,
"character": 15
},
"end": {
"line": 8,
"character": 88
}
},
"source": ".../basic-swagger-2.0.yaml"
}
CLI Output with JSON file (correct line ranges)
{
"code": "summary-short",
"path": [
"paths",
"/resources",
"get",
"summary"
],
"message": "An operation's summary must be short",
"severity": 1,
"range": {
"start": {
"line": 9,
"character": 19
},
"end": {
"line": 9,
"character": 94
}
},
"source": ".../basic-swagger-2.0.json"
}
CLI Output with YAML file converted to a 1 line JSON (same ranges as the API)
{
"code": "summary-short",
"range": {
"start": {
"line": 0,
"character": 101
},
"end": {
"line": 0,
"character": 176
}
},
"source": ".../basic-1-line-swagger-2.0.json"
}