Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
8 stars 28 forks source link

Add linting rule that prevents adding ArmTagsProperty to TrackedResource #542

Open mikeharder opened 3 months ago

mikeharder commented 3 months ago

Add linting rule that prevents adding ArmTagsProperty to TrackedResource. This TypeSpec:

model PrivateCloud is TrackedResource<PrivateCloudProperties> {
  ...ArmTagsProperty;

Generates this swagger:

    "PrivateCloud": {
      "properties": {
        "tags": {
          "type": "object",
          "description": "Resource tags.",
          "additionalProperties": {
            "type": "string"
          }
        },
      },
      "allOf": [
        {
          "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/TrackedResource"
        }
      ]

    "TrackedResource": {
      "title": "Tracked Resource",
      "description": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'",
      "type": "object",
      "properties": {
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "x-ms-mutability": [
            "read",
            "create",
            "update"
          ],
          "description": "Resource tags."
        },

Which fails Breaking Change(Cross-Version) since the tags.x-ms-mutability properties differ.

Example

https://github.com/Azure/azure-rest-api-specs/blob/6fc313ed7a6e926d4409d4ddb435f6532922652f/specification/vmware/Microsoft.AVS/models.tsp#L549-L550

https://github.com/Azure/azure-rest-api-specs/blob/6fc313ed7a6e926d4409d4ddb435f6532922652f/specification/common-types/resource-management/v5/types.json#L61-L72

https://github.com/Azure/azure-sdk-tools/issues/7917

markcowl commented 3 months ago

add SystemData check as well.

markcowl commented 3 months ago

est: 3