Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
110 stars 172 forks source link

Swagger LintDiff false positives for PatchBodyParametersSchema #7802

Open cataggar opened 6 months ago

cataggar commented 6 months ago

There look to be 3 false positives for PatchBodyParametersSchema in this PR check: https://github.com/Azure/azure-rest-api-specs/pull/28023/checks?check_run_id=22174134612

It is using Swagger LintDiff via openapi-validator v2.2.0.

cataggar commented 6 months ago

Here are an example error:

{"pluginName":"spectral","extensionName":"@microsoft.azure/openapi-validator","level":"error","message":"Properties of a PATCH request body must not be required, property:type.","code":"PatchBodyParametersSchema","details":{"jsonpath":["paths","/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}","patch","parameters","4","schema","properties","identity"],"validationCategory":"","providerNamespace":false,"resourceType":false,"rpcGuidelineCode":"RPC-Patch-V1-10","range":{"start":{"line":470,"column":21},"end":{"line":471,"column":56}}},"source":[{"document":"file:///Users/cameron/ms/azure-rest-api-specs/specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/vmware.json","position":{"line":470,"column":13}}]}

I do not understand why that error is happening. Here is the OpenAPI secutions:

      "patch": {
        "operationId": "PrivateClouds_Update",
        "tags": [
          "PrivateClouds"
        ],
        "description": "Update a PrivateCloud",
        "parameters": [
          {
            "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter"
          },
          {
            "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter"
          },
          {
            "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ResourceGroupNameParameter"
          },
          {
            "name": "privateCloudName",
            "in": "path",
            "description": "Name of the private cloud",
            "required": true,
            "type": "string",
            "pattern": "^[-\\w\\._]+$"
          },
          {
            "name": "privateCloudUpdate",
            "in": "body",
            "description": "The private cloud properties to be updated.",
            "required": true,
            "schema": {
              "$ref": "#/definitions/PrivateCloudUpdate"
            }
          }
        ],

    "PrivateCloudUpdate": {
      "type": "object",
      "description": "An update to a private cloud resource",
      "properties": {
        "tags": {
          "type": "object",
          "description": "Resource tags.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "sku": {
          "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/Sku",
          "description": "The SKU (Stock Keeping Unit) assigned to this resource."
        },
        "identity": {
          "$ref": "../../../../../common-types/resource-management/v5/managedidentity.json#/definitions/SystemAssignedServiceIdentity",
          "description": "The managed service identities assigned to this resource."
        },
        "properties": {
          "$ref": "#/definitions/PrivateCloudUpdateProperties",
          "description": "The updatable properties of a private cloud resource",
          "x-ms-client-flatten": true
        }
      }
    },
    "PrivateCloudUpdateProperties": {
      "type": "object",
      "description": "The properties of a private cloud resource that may be updated",
      "properties": {
        "managementCluster": {
          "$ref": "#/definitions/ManagementCluster",
          "description": "The default cluster used for management"
        },
        "internet": {
          "$ref": "#/definitions/InternetEnum",
          "description": "Connectivity to internet is enabled or disabled"
        },
        "identitySources": {
          "type": "array",
          "description": "vCenter Single Sign On Identity Sources",
          "items": {
            "$ref": "#/definitions/IdentitySource"
          },
          "x-ms-identifiers": []
        },
        "availability": {
          "$ref": "#/definitions/AvailabilityProperties",
          "description": "Properties describing how the cloud is distributed across availability zones",
          "x-ms-mutability": [
            "read",
            "create"
          ]
        },
        "encryption": {
          "$ref": "#/definitions/Encryption",
          "description": "Customer managed key encryption, can be enabled or disabled"
        },
        "extendedNetworkBlocks": {
          "type": "array",
          "description": "Array of additional networks noncontiguous with networkBlock. Networks must be\nunique and non-overlapping across VNet in your subscription, on-premise, and\nthis privateCloud networkBlock attribute. Make sure the CIDR format conforms to\n(A.B.C.D/X).",
          "items": {
            "type": "string"
          }
        },
        "dnsZoneType": {
          "$ref": "#/definitions/DnsZoneType",
          "description": "The type of DNS zone to use."
        }
      }
    },

There are no required properties.

petrkotas commented 3 months ago

Hi, I believe I have the same issue on this PR https://github.com/Azure/azure-rest-api-specs-pr/pull/18316

I made sure there are no required properties in the models I am inputting. But the linters are still not happy.