Skip to content

[CDN] Model validation fails with errors #766

Open

Description

Results from running model validation on cnd.json spec, using examples from .net tests recordings:

Validating "examples" and "x-ms-examples" in /Users/Veronica/github/openapi-validation-tools/arm-cdn/swagger/cdn.json:
> Operation: Endpoints_ListByProfile
> x-ms-examples
> Scenario: EndpointDeleteTestGET59
> InnerErrors:
1. code: INVALID_TYPE
message: Expected type string but found type null
path: value,0,properties,optimizationType
description: Customer can specify what scenario they want this CDN endpoint to optimize. (e.g. Download, Media services, and etc.) With this information we can apply scenario driven optimization.
2. code: INVALID_TYPE
message: Expected type string but found type null
path: value,0,properties,originPath
description: The path used for origin requests.
3. code: INVALID_TYPE
message: Expected type string but found type null
path: value,0,properties,originHostHeader
description: The host header the CDN provider will send along with content requests to origins. The default value is the host name of the origin.

From swagger model definition:

   "EndpointUpdateParameters": {
      "type": "object",
      "description": "Endpoint properties required for new endpoint creation.",
      "properties": {
        "tags": {
          "description": "Endpoint tags.",
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "properties": {
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/EndpointPropertiesUpdateParameters"
        }
      },
      "x-ms-azure-resource": true
    },
    "EndpointPropertiesUpdateParameters": {
      "description": "Result of the request to list endpoints. It contains a list of endpoints and a URL link to get the next set of results.",
      "properties": {
        "originHostHeader": {
          "description": "The host header the CDN provider will send along with content requests to origins. The default value is the host name of the origin.",
          "type": "string"
        },
        "originPath": {
          "description": "The path used for origin requests.",
          "type": "string"
        },
        "contentTypesToCompress": {
          "description": "List of content types on which compression will be applied. The value for the elements should be a valid MIME type.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "isCompressionEnabled": {
          "description": "Indicates whether content compression is enabled. The default value is false. If compression is enabled, the content transferred from the CDN endpoint to the end user will be compressed. The requested content must be larger than 1 byte and smaller than 1 MB.",
          "type": "boolean"
        },
        "isHttpAllowed": {
          "description": "Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed.",
          "type": "boolean"
        },
        "isHttpsAllowed": {
          "description": "Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one protocol (HTTP or HTTPS) must be allowed.",
          "type": "boolean"
        },
        "queryStringCachingBehavior": {
          "description": "Defines the query string caching behavior",
          "$ref": "#/definitions/QueryStringCachingBehavior"
        },
        "optimizationType": {
          "description": "Customer can specify what scenario they want this CDN endpoint to optimize. (e.g. Download, Media services, and etc.) With this information we can apply scenario driven optimization.",
          "type": "string"
        },
        "geoFilters": {
          "description": "The list of geo filters for the CDN endpoint.",
          "type": "array",
          "items": {
            "$ref": "#/definitions/GeoFilter"
          }
        }
      }
    }

From example:

{
  "parameters": {
    "subscriptionId": "8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4",
    "resourceGroupName": "cdnResourceGroup9341",
    "profileName": "profile1751",
    "api-version": "2016-10-02"
  },
  "responses": {
    "200": {
      "body": {
        "value": [
          {
            "name": "endpoint6444",
            "id": "/subscriptions/8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4/resourcegroups/cdnResourceGroup9341/providers/Microsoft.Cdn/profiles/profile1751/endpoints/endpoint6444",
            "type": "Microsoft.Cdn/profiles/endpoints",
            "tags": {},
            "location": "WestUs",
            "properties": {
              "hostName": "endpoint6444.azureedge.net",
              "originHostHeader": null,
              "provisioningState": "Succeeded",
              "resourceState": "Running",
              "isHttpAllowed": true,
              "isHttpsAllowed": true,
              "queryStringCachingBehavior": "IgnoreQueryString",
              "originPath": null,
              "origins": [
                {
                  "name": "origin1",
                  "properties": {
                    "hostName": "host1.hello.com",
                    "httpPort": null,
                    "httpsPort": null
                  }
                }
              ],
              "customDomains": [],
              "contentTypesToCompress": [],
              "isCompressionEnabled": false,
              "optimizationType": null,
              "geoFilters": []
            }
          }
        ]
      }
    }
  }
}
                             4. code: INVALID_TYPE
			     message: Expected type integer but found type null
			     path: value,0,properties,origins,0,properties,httpsPort
			     description: The value of the HTTPS port. Must be between 1 and 65535
			  5. code: INVALID_TYPE
			     message: Expected type integer but found type null
			     path: value,0,properties,origins,0,properties,httpPort
			     description: The value of the HTTP port. Must be between 1 and 65535

Model from swagger:

    "DeepCreatedOriginProperties": {
      "description": "Properties of origins Properties of the origin created on the CDN endpoint.",
      "type": "object",
      "required": [
        "hostName"
      ],
      "properties": {
        "hostName": {
          "description": "The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported.",
          "type": "string"
        },
        "httpPort": {
          "description": "The value of the HTTP port. Must be between 1 and 65535",
          "type": "integer",
          "maximum": 65535,
          "exclusiveMaximum": false,
          "minimum": 1,
          "exclusiveMinimum": false
        },
        "httpsPort": {
          "description": "The value of the HTTPS port. Must be between 1 and 65535",
          "type": "integer",
          "maximum": 65535,
          "exclusiveMaximum": false,
          "minimum": 1,
          "exclusiveMinimum": false
        }
      },
      "x-ms-azure-resource": true
    }
> Operation: Endpoints_Start
	> x-ms-examples
		> Scenario: CustomDomainCRUDTestPOST722
			> InnerErrors:
			  **1. code: OBJECT_MISSING_REQUIRED_PROPERTY**
			     message: Missing required property: location
			     path: 
			     description: The Resource definition.

Model definition from swagger:

    "Endpoint": {
      "description": "CDN endpoint is the entity within a CDN profile containing configuration information regarding caching behaviors and origins. The CDN endpoint is exposed using the URL format <endpointname>.azureedge.net by default, but custom domains can also be created.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/definitions/Resource"
        }
      ],
      "properties": {
        "properties": {
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/EndpointProperties"
        }
      }
    }

Example:

{
  "parameters": {
    "subscriptionId": "8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4",
    "resourceGroupName": "cdnResourceGroup8419",
    "profileName": "profile4423",
    "endpointName": "endpoint-f3757d2a3e10",
    "api-version": "2016-10-02"
  },
  "responses": {
    "202": {
      "body": {
        "hostName": "endpoint-f3757d2a3e10.azureedge.net",
        "originHostHeader": null,
        "provisioningState": "Succeeded",
        "resourceState": "Starting",
        "isHttpAllowed": true,
        "isHttpsAllowed": true,
        "queryStringCachingBehavior": "IgnoreQueryString",
        "originPath": null,
        "origins": [
          {
            "name": "origin1",
            "properties": {
              "hostName": "host1.hello.com",
              "httpPort": null,
              "httpsPort": null
            }
          }
        ],
        "customDomains": [
          {
            "name": "customDomain690",
            "properties": {
              "hostName": "sdk-1-f3757d2a3e10.azureedge-test.net",
              "validationData": null
            }
          }
        ],
        "contentTypesToCompress": [],
        "isCompressionEnabled": false,
        "optimizationType": null,
        "geoFilters": []
      }
    }
  }
}
> Operation: Endpoints_ValidateCustomDomain
	> x-ms-examples
		> Scenario: ValidateCustomDomainTestPOST119
			> InnerErrors:
			  1. **code: INVALID_TYPE**
			     message: Expected type string but found type null
			     path: reason
			     description: The reason why the custom domain is not valid.
			  2. **code: INVALID_TYPE**
			     message: Expected type string but found type null
			     path: message
			     description: The message describing why the custom domain is not valid.

From swagger model:

    "ValidateCustomDomainOutput": {
      "description": "Output of custom domain validation.",
      "type": "object",
      "properties": {
        "customDomainValidated": {
          "description": "Indicates whether the custom domain is validated or not.",
          "type": "boolean"
        },
        "reason": {
          "description": "The reason why the custom domain is not valid.",
          "type": "string"
        },
        "message": {
          "description": "The message describing why the custom domain is not valid.",
          "type": "string"
        }
      }
    }

From example:

{
  "parameters": {
    "subscriptionId": "8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4",
    "resourceGroupName": "cdnResourceGroup556",
    "profileName": "profile69",
    "endpointName": "endpoint-8e02deffed3c",
    "api-version": "2016-10-02",
    "customDomainProperties": {
      "hostName": "customdomain34.azureedge-test.net"
    }
  },
  "responses": {
    "200": {
      "body": {
        "customDomainValidated": true,
        "message": null,
        "reason": null
      }
    }
  }
}
> Operation: Origins_ListByEndpoint
	> x-ms-examples
		> Scenario: OriginDeleteTestGET129
			> InnerErrors:
			  **1. code: OBJECT_MISSING_REQUIRED_PROPERTY**
			     message: Missing required property: location
			     path: value,0
			     description: The Resource definition.
			  2. **code: INVALID_TYPE**
			     message: Expected type integer but found type null
			     path: value,0,properties,httpsPort
			     description: The value of the https port. Must be between 1 and 65535.
			  3. **code: INVALID_TYPE**
			     message: Expected type integer but found type null
			     path: value,0,properties,httpPort
			     description: The value of the HTTP port. Must be between 1 and 65535.

From swagger model:

    "Origin": {
      "description": "CDN origin is the source of the content being delivered via CDN. When the edge nodes represented by an endpoint do not have the requested content cached, they attempt to fetch it from one or more of the configured origins.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/definitions/Resource"
        }
      ],
      "properties": {
        "properties": {
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/OriginProperties"
        }
      }
    }

From example:

{
  "parameters": {
    "subscriptionId": "06adb0b3-baaa-4e5f-9df6-ca770f7902cd",
    "resourceGroupName": "cdnResourceGroup1971",
    "profileName": "profile560",
    "endpointName": "endpoint5398",
    "api-version": "2016-04-02"
  },
  "responses": {
    "200": {
      "body": {
        "value": [
          {
            "name": "origin1",
            "id": "/subscriptions/06adb0b3-baaa-4e5f-9df6-ca770f7902cd/resourcegroups/cdnResourceGroup1971/providers/Microsoft.Cdn/profiles/profile560/endpoints/endpoint5398/origins/origin1",
            "type": "Microsoft.Cdn/profiles/endpoints/origins",
            "properties": {
              "provisioningState": "Succeeded",
              "resourceState": "Active",
              "hostName": "host1.hello.com",
              "httpPort": null,
              "httpsPort": null
            }
          }
        ]
      }
    }
  }
}
> Operation: CustomDomains_ListByEndpoint
	> x-ms-examples
		> Scenario: CustomDomainCRUDTestGET149
			> InnerErrors:
			  1. code: OBJECT_MISSING_REQUIRED_PROPERTY
			     message: Missing required property: location
			     path: value,0
			     description: The Resource definition.
			  2. code: INVALID_TYPE
			     message: Expected type string but found type null
			     path: value,0,properties,validationData
			     description: Special validation or data may be required when delivering CDN to some regions due to local compliance reasons. (e.g. ICP license number of a custom domain is required to deliver content in China.)

From swagger model:

    "CustomDomain": {
      "description": "CDN CustomDomain represents a mapping between a user-specified domain name and a CDN endpoint. This is to use custom domain names to represent the URLs for branding purposes.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/definitions/Resource"
        }
      ],
      "properties": {
        "properties": {
          "x-ms-client-flatten": true,
          "$ref": "#/definitions/CustomDomainProperties"
        }
      }
    },

From example:

{
  "parameters": {
    "subscriptionId": "8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4",
    "resourceGroupName": "cdnResourceGroup8419",
    "profileName": "profile4423",
    "endpointName": "endpoint-f3757d2a3e10",
    "api-version": "2016-10-02"
  },
  "responses": {
    "200": {
      "body": {
        "value": [
          {
            "name": "customDomain690",
            "id": "/subscriptions/8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4/resourcegroups/cdnResourceGroup8419/providers/Microsoft.Cdn/profiles/profile4423/endpoints/endpoint-f3757d2a3e10/customdomains/customDomain690",
            "type": "Microsoft.Cdn/profiles/endpoints/customdomains",
            "properties": {
              "provisioningState": "Succeeded",
              "resourceState": "Active",
              "hostName": "sdk-1-f3757d2a3e10.azureedge-test.net",
              "customHttpsProvisioningState": "Disabled",
              "validationData": null
            }
          }
        ]
      }
    }
  }
}
> Operation: CustomDomains_Delete
	> x-ms-examples
		> Scenario: CustomDomainCRUDTestDELETE1524
			> InnerErrors:
			  1. code: INVALID_TYPE
			     message: Expected type object but found type string
			     path: 
			     description: CDN CustomDomain represents a mapping between a user-specified domain name and a CDN endpoint. This is to use custom domain names to represent the URLs for branding purposes.

From swagger:

        "responses": {
          "200": {
            "description": "OK. The request has succeeded."
          },
          "202": {
            "description": "Accepted and the operation will complete asynchronously.",
            "schema": {
              "$ref": "#/definitions/CustomDomain"
            }
          },

From example:

{
  "parameters": {
    "subscriptionId": "8fbd19e9-e8e0-4224-89f6-b1d5d86fb4c4",
    "resourceGroupName": "cdnResourceGroup8419",
    "profileName": "profile4423",
    "endpointName": "endpoint-f3757d2a3e10",
    "customDomainName": "customDomain690",
    "api-version": "2016-10-02"
  },
  "responses": {
    "202": {
      "body": ""
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions