Azure / azure-openapi-validator

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

[AvoidAdditionalProperties] Allow under any property matching regex "[Tt]ags" instead of exactly "tags" #698

Closed mikeharder closed 1 month ago

mikeharder commented 1 month ago

Rule AvoidAdditionalProperties raised an error for the following swagger:

"vmTags": {
  "type": "object",
  "additionalProperties": {
    "type": "string"
  },
  "description": "Hashtable that lists key/value pair tags to apply to the VMs"
},

Currently, additionalProperties is only automatically allowed under properties named exactly tags:

https://github.com/Azure/azure-openapi-validator/blob/b95d5eb121c47ab3e110c97da23e583ebfd637ee/packages/rulesets/src/spectral/az-arm.ts#L297-L306

The proposal is to broaden the range of allowed properties, to anything matching regex [Tt]ags (or something similar that would allow vmTags).

We may also need to align with RPC-Policy-V1-05 and RPC-Put-V1-23 which are mentioned here:

https://github.com/Azure/azure-openapi-validator/blob/b95d5eb121c47ab3e110c97da23e583ebfd637ee/docs/avoid-additional-properties.md#related-arm-guideline-code

The status quo is to require suppressions for properties with names similar to (but not exactly) tags.

Spec PR: https://github.com/Azure/azure-rest-api-specs/pull/29101/checks?check_run_id=25631949240

CC: @markcowl, @almat-msft

mikeharder commented 1 month ago

We believe the root cause is more related to #652 than the name of the property.