Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ArcturusZhang opened this issue Nov 6, 2019 · 1 comment

Comments

@ArcturusZhang
Copy link
Member

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

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). <br><br> The available VM sizes depend on region and availability set. For a list of available sizes use these APIs:  <br><br> [List all available virtual machine sizes in an availability set](https://docs.microsoft.com/rest/api/compute/availabilitysets/listavailablesizes) <br><br> [List all available virtual machine sizes in a region](https://docs.microsoft.com/rest/api/compute/virtualmachinesizes/list) <br><br> [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:
@ArcturusZhang
Copy link
Member Author

It turns out that some enum values can contain comma even space, these non-character and non-numeric character need to be removed in api.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant