autorest.typescript icon indicating copy to clipboard operation
autorest.typescript copied to clipboard

Enum Value with only one option is always present in the request

Open sarangan12 opened this issue 3 years ago • 0 comments

In the Storage Blob Data Plane SDK - file, we have the following swagger definition:

"EncryptionAlgorithm": {
      "name": "x-ms-encryption-algorithm",
      "x-ms-client-name": "encryptionAlgorithm",
      "type": "string",
      "in": "header",
      "required": false,
      "enum": [
        "AES256"
      ],
      "x-ms-enum": {
        "name": "EncryptionAlgorithmType",
        "modelAsString": false
      },
      "x-ms-parameter-location": "method",
      "x-ms-parameter-grouping": {
        "name": "cpk-info"
      },
      "description": "The algorithm used to produce the encryption key hash. Currently, the only accepted value is \"AES256\". Must be provided if the x-ms-encryption-key header is provided."
}

With the above swagger definition, the parameter definition looks as:

export const encryptionAlgorithm: OperationParameter = {
  parameterPath: ["options", "cpkInfo", "encryptionAlgorithm"],
  mapper: {
    defaultValue: "AES256",
    isConstant: true,
    serializedName: "x-ms-encryption-algorithm",
    type: {
      name: "String"
    }
  }
};

With the above code, the request always has this encryptionAlgorithm even when the user does not specify anything. Such behavior is not present in the old generator.

CC: @ramya-rao-a @EmmaZhu

sarangan12 avatar Aug 05 '21 05:08 sarangan12