Azure / azure-openapi-validator

Azure Open API Validator
MIT License
44 stars 43 forks source link

Indicate "before/after" in error JSON #676

Open mikeharder opened 3 months ago

mikeharder commented 3 months ago

Errors should include one or more ways to indicate whether they apply to the "before" or "after" spec. Example of current schema:

{
  "pluginName": "spectral",
  "extensionName": "@microsoft.azure/openapi-validator",
  "level": "error",
  "message": "The integer type does not have a format, please add it.",
  "code": "IntegerTypeMustHaveFormat",
  "details": {
    "jsonpath": ["definitions", "TasksState", "properties", "tasks", "properties", "completed" ],
    "validationCategory": "ARMViolation",
    "providerNamespace": false,
    "resourceType": false,
    "range": {"start": { "line": 2251, "column": 26 }, "end": { "line": 2253, "column": 14} } },
    "source": [ {"document": "file:///mnt/vss/_work/1/lint-c93b354fd9c14905bb574a8834c4d69b/specification/cognitiveservices/data-plane/Language/stable/2022-05-01/analyzetext.json", 
    "position": {"line": 2251, "column": 13}
    }
  ]
}

Options:

konrad-jamrozik commented 3 months ago

I understand that before this change goes in we can use this heuristic:

konrad-jamrozik commented 3 months ago

Add property beforeOrAfter with values before and after

I significantly prefer this approach instead of tampering with the path. I understand by path you mean details.source.document.