Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AvoidAdditionalProperties] Set resolved:false to only report errors at the source #700

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rulesets/generated/spectral/az-arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3159,7 +3159,7 @@ const ruleset = {
message: "{{description}}",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/no-record' rule.",
resolved: true,
resolved: false,
formats: [oas2],
given: "$.definitions..[?(@property !== 'tags' && @property !== 'delegatedResources' && @property !== 'userAssignedIdentities' && @ && @.additionalProperties)]",
then: {
Expand Down
2 changes: 1 addition & 1 deletion packages/rulesets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/openapi-validator-rulesets",
"version": "2.0.6",
"version": "2.0.7",
"description": "Azure OpenAPI Validator",
"main": "dist/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/rulesets/src/spectral/az-arm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ const ruleset: any = {
message: "{{description}}",
disableForTypeSpec: true,
disableForTypeSpecReason: "Covered by TSP's '@azure-tools/typespec-azure-resource-manager/no-record' rule.",
resolved: true,
// Only report errors at the source, not from inside $refs (the resolved document)
resolved: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I believe the resolved is defined here:
https://docs.stoplight.io/docs/spectral/d3482ff0ccae9-rules#resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. After reading that, I feel even more confident this rule should use resolved: false.

formats: [oas2],
// In some cases, variable "@" will be "null" when evaluating the expression, so it must be checked before dereferencing
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ test("AvoidAdditionalProperties should find errors", () => {
},
required: ["type"],
},
ThisRef: {
description: "Ensure error is NOT raised from inside $refs (rule sets resolved:false)",
properties: {
$ref: "#/definitions/This",
},
},
},
}
return linter.run(oasDoc).then((results) => {
Expand Down