Azure / azure-openapi-validator

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

LintDiff rule "IntegerTypeMustHaveFormat" false positives #675

Closed tjprescott closed 3 months ago

tjprescott commented 3 months ago

Describe the bug Example Log

{
  "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}
    }
  ]
}",

However, when I look at the actual Swagger: https://github.com/Azure/azure-rest-api-specs/blob/2923f9c6563b296485957fd1ab55114ba7c8c8f7/specification/cognitiveservices/data-plane/Language/stable/2022-05-01/analyzetext.json

image

So I don't understand why this rule is being triggered. int32 is called out as valid in the docs and in the code. I don't see anything obvious in the LintDiff rule code that would be wrong:

image

Expected behavior This should not trigger any kind of violation.

mikeharder commented 3 months ago

I believe the tool is correct, and the error is in the "old" version of the spec:

    "TasksState": {
      "properties": {
        "tasks": {
          "properties": {
            "completed": {
              "type": "integer"
            },

https://github.com/Azure/azure-rest-api-specs/blob/09db900b1d9155361899e5f8fb1331a30055df41/specification/cognitiveservices/data-plane/Language/stable/2022-05-01/analyzetext.json#L2247-L2253