Azure / Azure/autorest.cli

[MM] Generated go-enum values cannot contains hyphens or underscores

Open
#54 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I am generating `api.yaml` file using `autorest.cli` with input file: `azure-rest-api-specs\specification\compute\resource-manager\readme.md`

# Tag in use
`package-2019-07`.

# Cli section added in `readme.md`

``` yaml $(cli)
cli:
cli-name: compute
azure-arm: true
license-header: MICROSOFT_MIT_NO_VERSION
payload-flattening-threshold: 2
namespace: azure.mgmt.compute
package-name: azure-mgmt-compute
clear-output-folder: false
debug: true
disable-azure-cli: true
```

# Problem encountered

In the generated `magic-module-input` files `computevirtualmachine`, the generated values of go enum variable can contain hyphens or underscores or both. Golang will give warnings about snake cased variable names, so in the generation of Go SDK, hyphens and underscores in enum variables will be removed. For instance, in the generated `api.yaml`, in the representation of an enum variable
```
- !ruby/object:Api::Type::Enum
name: 'storageAccountType'
description: 'Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.'
required: false
sample_value: Standard_LRS
azure_sdk_references: ['/storageProfile/osDisk/managedDisk/storageAccountType', '/properties/storageProfile/osDisk/managedDisk/storageAccountType']
values:
- :Standard_LRS
- :Premium_LRS
- :StandardSSD_LRS
- :UltraSSD_LRS
default_value: :Standard_LRS
```
All these underscores should be removed. In the definition of `vmSize`, there are more enum variables contained hyphens and underscores.
```
- !ruby/object:Api::Type::Enum
name: 'vmSize'
description: 'Specifies the size of the virtual machine. For more information about virtual machine sizes, see [Sizes for virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-sizes?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).

The available VM sizes depend on region and availability set. For a list of available sizes use these APIs:

[List all available virtual machine sizes in an availability set](https://docs.microsoft.com/rest/api/compute/availabilitysets/listavailablesizes)

[List all available virtual machine sizes in a region](https://docs.microsoft.com/rest/api/compute/virtualmachinesizes/list)

[List all available virtual machine sizes for resizing](https://docs.microsoft.com/rest/api/compute/virtualmachines/listavailablesizes)'
required: false
sample_value: Standard_D2_v2
azure_sdk_references: ['/hardwareProfile/vmSize', '/properties/hardwareProfile/vmSize']
values:
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.