aliases_json: |
  [
    {
      "namespace": "Microsoft.Storage",
      "resourceTypes": [
        {
          "resourceType": "storageAccounts",
          "aliases": [
            {
              "name": "Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly",
              "defaultPath": "properties.supportsHttpsTrafficOnly",
              "paths": []
            },
            {
              "name": "Microsoft.Storage/storageAccounts/accessTier",
              "defaultPath": "properties.accessTier",
              "paths": []
            },
            {
              "name": "Microsoft.Storage/storageAccounts/sku.name",
              "defaultPath": "sku.name",
              "paths": []
            }
          ]
        }
      ]
    },
    {
      "namespace": "Microsoft.Network",
      "resourceTypes": [
        {
          "resourceType": "networkSecurityGroups",
          "aliases": [
            {
              "name": "Microsoft.Network/networkSecurityGroups/securityRules[*].protocol",
              "defaultPath": "properties.securityRules[*].properties.protocol",
              "paths": []
            },
            {
              "name": "Microsoft.Network/networkSecurityGroups/securityRules[*].access",
              "defaultPath": "properties.securityRules[*].properties.access",
              "paths": []
            },
            {
              "name": "Microsoft.Network/networkSecurityGroups/securityRules[*].name",
              "defaultPath": "properties.securityRules[*].name",
              "paths": []
            }
          ]
        },
        {
          "resourceType": "virtualNetworks",
          "aliases": [
            {
              "name": "Microsoft.Network/virtualNetworks/subnets[*].addressPrefix",
              "defaultPath": "properties.subnets[*].properties.addressPrefix",
              "paths": []
            },
            {
              "name": "Microsoft.Network/virtualNetworks/subnets[*].name",
              "defaultPath": "properties.subnets[*].name",
              "paths": []
            },
            {
              "name": "Microsoft.Network/virtualNetworks/subnets[*].ipConfigurations[*].privateIPAddress",
              "defaultPath": "properties.subnets[*].properties.ipConfigurations[*].properties.privateIPAddress",
              "paths": []
            },
            {
              "name": "Microsoft.Network/virtualNetworks/subnets[*].ipConfigurations[*].name",
              "defaultPath": "properties.subnets[*].properties.ipConfigurations[*].name",
              "paths": []
            }
          ]
        }
      ]
    },
    {
      "namespace": "Microsoft.Web",
      "resourceTypes": [
        {
          "resourceType": "sites",
          "aliases": [
            {
              "name": "Microsoft.Web/sites/isEnabled",
              "defaultPath": "properties.isEnabled",
              "paths": [
                {
                  "path": "properties.enabled",
                  "apiVersions": ["2020-01-01"]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "namespace": "test",
      "resourceTypes": [
        {
          "resourceType": "resource",
          "aliases": [
            {
              "name": "test/resource/type",
              "defaultPath": "properties.type",
              "paths": []
            }
          ]
        },
        {
          "resourceType": "versionedEnvelope",
          "aliases": [
            {
              "name": "test/versionedEnvelope/items[*].status",
              "defaultPath": "properties.items[*].properties.status",
              "paths": [
                {
                  "path": "properties.items[*].status",
                  "apiVersions": ["2025-01-01"]
                }
              ]
            },
            {
              "name": "test/versionedEnvelope/items[*].name",
              "defaultPath": "properties.items[*].name",
              "paths": []
            }
          ]
        }
      ]
    }
  ]

cases:
  - note: restores casing from aliases
    input:
      name: myStorage
      type: "Microsoft.Storage/storageAccounts"
      supportshttpstrafficonly: true
      accesstier: Hot
    expected_denormalized:
      name: myStorage
      type: "Microsoft.Storage/storageAccounts"
      properties:
        supportsHttpsTrafficOnly: true
        accessTier: Hot
    reverse_round_trip: true

  - note: versioned path - default
    input:
      type: "Microsoft.Web/sites"
      isenabled: true
    expected_denormalized:
      type: "Microsoft.Web/sites"
      properties:
        isEnabled: true
    reverse_round_trip: true

  - note: versioned path - matching version
    input:
      type: "Microsoft.Web/sites"
      isenabled: true
    api_version: "2020-01-01"
    expected_denormalized:
      type: "Microsoft.Web/sites"
      properties:
        enabled: true
    reverse_round_trip: true
    expected_reverse_round_trip:
      type: "Microsoft.Web/sites"
      enabled: true
      isenabled: true

  - note: collision safe key
    input:
      type: "test/resource"
      _p_type: SubType
    expected_denormalized:
      type: "test/resource"
      properties:
        type: SubType
    reverse_round_trip: true

  - note: sub-resource array
    input:
      name: myNsg
      type: "Microsoft.Network/networkSecurityGroups"
      securityrules:
        - name: rule1
          protocol: Tcp
          access: Allow
        - name: rule2
          protocol: "*"
          access: Deny
    expected_denormalized:
      name: myNsg
      type: "Microsoft.Network/networkSecurityGroups"
      properties:
        securityRules:
          - name: rule1
            properties:
              protocol: Tcp
              access: Allow
          - name: rule2
            properties:
              protocol: "*"
              access: Deny
    reverse_round_trip: true

  - note: nested sub-resource arrays
    input:
      name: myVnet
      type: "Microsoft.Network/virtualNetworks"
      subnets:
        - name: subnet1
          addressprefix: "10.0.0.0/24"
          ipconfigurations:
            - name: ipconfig1
              privateipaddress: "10.0.0.4"
    expected_denormalized:
      name: myVnet
      type: "Microsoft.Network/virtualNetworks"
      properties:
        subnets:
          - name: subnet1
            properties:
              addressPrefix: "10.0.0.0/24"
              ipConfigurations:
                - name: ipconfig1
                  properties:
                    privateIPAddress: "10.0.0.4"
    reverse_round_trip: true

  - note: root level alias (sku.name)
    input:
      type: "Microsoft.Storage/storageAccounts"
      sku:
        name: Standard_LRS
    expected_denormalized:
      type: "Microsoft.Storage/storageAccounts"
      sku:
        name: Standard_LRS
    reverse_round_trip: true

  - note: versioned envelope classification — default (status under properties)
    resource_type: "test/versionedEnvelope"
    sub_resource_arrays: ["items"]
    input:
      type: "test/versionedEnvelope"
      items:
        - name: item1
          status: active
    expected_denormalized:
      type: "test/versionedEnvelope"
      properties:
        items:
          - name: item1
            properties:
              status: active

  - note: versioned envelope classification — version promotes status to envelope
    resource_type: "test/versionedEnvelope"
    sub_resource_arrays: ["items"]
    api_version: "2025-01-01"
    input:
      type: "test/versionedEnvelope"
      items:
        - name: item1
          status: active
    expected_denormalized:
      type: "test/versionedEnvelope"
      properties:
        items:
          - name: item1
            status: active

  - note: versioned casing restoration from versioned alias paths
    aliases_json: |
      [
        {
          "namespace": "Microsoft.Test",
          "resourceTypes": [
            {
              "resourceType": "widgets",
              "aliases": [
                {
                  "name": "Microsoft.Test/widgets/items[*].rating",
                  "defaultPath": "properties.items[*].properties.oldField",
                  "paths": [
                    {
                      "path": "properties.items[*].properties.RenamedField",
                      "apiVersions": ["2025-06-01"]
                    }
                  ]
                },
                {
                  "name": "Microsoft.Test/widgets/items[*].name",
                  "defaultPath": "properties.items[*].name",
                  "paths": []
                }
              ]
            }
          ]
        }
      ]
    api_version: "2025-06-01"
    input:
      type: "Microsoft.Test/widgets"
      items:
        - name: w1
          rating: 5
    expected_denormalized:
      type: "Microsoft.Test/widgets"
      properties:
        items:
          - name: w1
            properties:
              RenamedField: 5
