autorest
autorest copied to clipboard
Align property type name to re-named object type name
Sometimes it is necessary to rename client type names to deal with extremely long names as described in #4470 .
When renaming an object using x-ms-client-name
, unfortunately the property type name is not also updated.
For example, in the following code OBReadBalance1
is renamed to MyTest1
. Yet the property type name (in C#) for the Data property remains OBReadBalance1Data
and there is no way to change this. I believe the property type name should respect the x-ms-client-name
setting for the object and become MyTest1Data
.
OBReadBalance1:
type: "object"
x-ms-client-name: "MyTest1"
required:
- "Data"
properties:
Data:
type: "object"
I believe solving this would mean there is a way to reduce the length of any type name (this seems the only unsolved case) and thus deal with problems caused by heavily nested OpenAPI files (see #4470 for an example).
BR, Mark
Just to be clear I am not proposing any change to the behaviour of x-ms-client-name
on properties (which currently determines the property name but not the property type name).
I am merely suggesting an enhancement to x-ms-client-name
when used on objects!
Hope that's clear.
Are you saying you want x-ms-client-name to apply to both the property name and the object name? If so the current behavior is expliclity deciding not to do that, I think in most cases people wouldn't want the name to apply to both.
I think the solution to this really would be to introduce 1 or 2 new extensions(x-ms-client-property-name
, x-ms-client-schema-name
) as we can't change the current behavior without introducing a lot of breaking changes.
I was just thinking that currently the convention is for a property Y on an object X to have type name XY. I thought therefore that if the object X was renamed to X2, the property type name could also update accordingly to X2Y. However, yes this is breaking and yeah new extensions would be fantastic!
Oh I see, so the feature we were talking about on the other issue. Yeah that could be an option as well. This is not that breaking IMO specially if the previous name is a very long meaningless generated name. This one could potentially have the change with maybe a flag to revert to previous behavior.
Sure, agreed it's not that breaking. Really I don't mind what you think is best - just looking for some way to be able to tame the runaway long type names! (I think all the other ones can now be handled except the property type names.)