-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Swagger LintDiff
Mike Harder edited this page Feb 7, 2025
·
1 revision
When adding suppressions for LintDiff (https://github.com/Azure/autorest/blob/main/docs/generate/suppress-warnings.md), it's recommened to use a where
clause to scope the suppression to one instance of the error How to find the JSON path to use for the suppression.
- In the raw log for the "LintDiff" step of the "LintDiff" check, find the line containing the JSON object representing your error. For example:
{"pluginName":"spectral","extensionName":"@microsoft.azure/openapi-validator","level":"error","message":"Properties of a PATCH request body must not be required, property:endpointType.","code":"PatchBodyParametersSchema","details":{"jsonpath":["paths","/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}","patch","parameters","2","schema","properties","deadLetterDestination"],"validationCategory":"","providerNamespace":false,"resourceType":false,"rpcGuidelineCode":"RPC-Patch-V1-10","range":{"start":{"line":1,"column":0},"end":{"line":1,"column":0}}},"source":[{"document":"file:///mnt/vss/_work/1/azure-rest-api-specs/specification/eventgrid/resource-manager/Microsoft.EventGrid/stable/2025-02-15/EventGrid.json","position":{"line":2908,"column":13}}]}
- Paste into VSCode (or another editor) to format for readability. We are focused on the
jsonpath
property.
{
"pluginName": "spectral",
"extensionName": "@microsoft.azure/openapi-validator",
"level": "error",
"message": "Properties of a PATCH request body must not be required, property:endpointType.",
"code": "PatchBodyParametersSchema",
"details": {
"jsonpath": [
"paths",
"/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}",
"patch",
"parameters",
"2",
"schema",
"properties",
"deadLetterDestination"
],
...
},
"source": [
{
"document": "file:///mnt/vss/_work/1/azure-rest-api-specs/specification/eventgrid/resource-manager/Microsoft.EventGrid/stable/2025-02-15/EventGrid.json",
"position": {
"line": 2908,
"column": 13
}
}
]
}
- Convert the
jsonpath
array to a string, and add to your suppression:
- code: PatchBodyParametersSchema
from: EventGrid.json
where: $.paths["/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"].patch.parameters[2].schema.properties.deadLetterDestination