[v6] Declarative way to avoid name case conversion
Currently, if we need to keep a name as described in the swagger that doesn't conform to modeler four namer config, for example if we want a property key_ops in the generated code, to avoid the generator making it keyOps we'd need to set a complex transform (see example)
directive:
- from: swagger-document
where: $.definitions.JsonWebKey.properties.key_ops
transform: >
$["x-ms-client-name"] = "key_ops_keep_snakecase";
modelerfour:
naming:
override:
key_ops_keep_snakecase: $DO_NOT_NORMALIZE$key_ops
I think this can be improved in 2 different ways
- Have a new extension in the Swagger
x-ms-keep-namewhich if set to true, M4 would not pass it through the namer. - Even if we don't implement the new extension, if we stop doing custom case conversion in
autorest.typescript(see this comment for context) I think we could reduce the transform to the following?
modelerfour:
naming:
override:
key_ops: key_ops
I think option 1 would provide a better experience overall since it could be set in the swagger which would remove the need for any transforms at all. This would probably be interesting for other languages as well
It took me a lot of time to arrive at this thread. It would be great if this was documented better in the official docs. My config looked like this:
modelerfour:
lenient-model-deduplication: true
naming:
override:
_id: _id
And I was frustrated that it is not working. After reading this thread, I changed it to:
modelerfour:
lenient-model-deduplication: true
naming:
override:
_id: $DO_NOT_NORMALIZE$_id
And it works!
https://github.com/Azure/autorest.typescript/issues/1546
Thanks for the feedback @MarcErdmann.
@sarangan12, would you mind adding this to the documentation?