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

PLR marketplace: strange flattened parameter name

Open changlong-liu opened this issue 3 years ago • 2 comments

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" ?

changlong-liu avatar Mar 10 '21 02:03 changlong-liu

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/[email protected] --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 avatar Mar 19 '21 08:03 qiaozha

move to backlog as this is designed by m4

qiaozha avatar Mar 25 '21 08:03 qiaozha