autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Can autorest support a flag to control the removeDuplicates of model naming property

Open hquangthinh opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe. There's issue that I posted here https://github.com/Azure/autorest.csharp/issues/1667

I consume swagger file from vendor product so I cannot control the swagger file. Sometimes the swagger file contains property definition such as

BaseCurrSymbol BaseCurrSymbolCurrSymbol

The CodeModel.yaml output will contains

`

  • !Property schema: *ref_33 serializedName: BaseCurrSymbol language: !Languages default: name: baseCurrSymbol description: ''

  • !Property schema: *ref_74 serializedName: BaseCurrSymbolCurrSymbol language: !Languages default: name: baseCurrSymbol description: ''`

With this autorest csharp will generate a model with 2 property name BaseCurrSymbol

Describe the solution you'd like As I observe the fix from here https://github.com/Azure/autorest/pull/4166

Look like the naming is removing duplicated is control by this option

From the file autorest\packages\extensions\modelerfour\src\prenamer\naming-utils.ts const setNameDefaultOptions: SetNameOptions = Object.freeze({ removeDuplicates: true, nameEmptyErrorMessage: Name cannot be empty., });

Can we have a flag or kind of setting to control this option removeDuplicates

hquangthinh avatar Nov 13 '21 02:11 hquangthinh

Can you confirm you are using the latest version of modelerfour and @autorest/core (docs. Bugs around deduplicate consecutive words naming have been resolved in the past.

timotheeguerin avatar Nov 15 '21 16:11 timotheeguerin

Can you confirm you are using the latest version of modelerfour and @autorest/core (docs. Bugs around deduplicate consecutive words naming have been resolved in the past.

Yes I use the latest version of autorest and plugins. The deduplicate consecutive words naming works. In this case I want turn it off, I want it keeps the name as is in swagger file. As I understand when deduplicate consecutive naming It can produce duplicate property in the result model.

I think It also related to this issue https://github.com/Azure/autorest.csharp/issues/1613 when deduplicate consecutive naming turn on

hquangthinh avatar Nov 17 '21 03:11 hquangthinh

I see, seems like that problem was still present for model properties. I fixed that instead of adding a new configuration.

PR here has some steps to try it out https://github.com/Azure/autorest/pull/4378, can you confirm this resolve your issue.

timotheeguerin avatar Nov 17 '21 23:11 timotheeguerin