Azure / autorest.az

Azure CLI Code Generator
MIT License
22 stars 20 forks source link

PLR marketplace: strange flattened parameter name #778

Open changlong-liu opened 3 years ago

changlong-liu commented 3 years ago

swagger: https://github.com/changlong-liu/azure-rest-api-specs/tree/20210210-marketplace/specification/marketplace/resource-manager

for private store id defined in https://github.com/Azure/azure-rest-api-specs/blob/master/specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2020-01-01/Marketplace.json#L588

the generated CLI parameter is : image

Looks it should be "--private-store-properties-private-store-id" instead of "--private-store-properties-private-store-id-private-store-id" ?

qiaozha commented 3 years ago

This is modelerfour original behavior of handling parameter name conflict during flatten. There is actually two private-store-id in this operation after flatten. the second one while is flattened from the privateStoreProperties has a flattenedName array ['privateStoreProperties', 'privateStoreId'].

What modelerfour does to resolve such kind of conflict is simple put all the items in flattenedNames in front of the parameter's original name.

you can also find the same behavior if you set body x-ms-client-flatten as true and run the following command autorest --modelerfour --use=@autorest/modelerfour@4.15.421 --output-artifact=code-model-v4-no-tags ../azure-rest-api-specs/specification/marketplace/resource-manager/readme.md --debug --output-folder=/tmp/aztest --modelerfour.flatten-payloads=true --modelerfour.flatten-models=true

qiaozha commented 3 years ago

move to backlog as this is designed by m4