As a developer I expect the modelPropertyNaming='original' to keep property names equal to the name provided in the openapi spec file. Not all variable names are accepted in TypeScript (and JavaScript) so for variable names it is expected to sanitize the names to generate valid code. For property names this is not the case, but the property names are still sanitized and altered. This should only happen when not doing this would produce invalid code. This is not the case, property names can be quoted to allow all possible names.
At the moment this generates clients that are not interoperable with the server
Actual:
/**
*
* @export
* @interface Example
*/
export interface Example {
/**
*
* @type {string}
* @memberof Example
*/
type?: string;
/**
*
* @type {string}
* @memberof Example
*/
mime_type?: string;
}
Expected:
/**
*
* @export
* @interface Example
*/
export interface Example {
/**
*
* @type {string}
* @memberof Example
*/
"@type"?: string;
/**
*
* @type {string}
* @memberof Example
*/
"mime-type"?: string;
}
4.1.2
openapi: 3.0.0
info:
title: modelNamingExample
version: v1
paths:
/example:
post:
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
responses:
"200":
description: ""
content:
application/json:
schema:
$ref: "#/components/schemas/Example"
components:
schemas:
Example:
description: ""
type: object
properties:
"@type":
type: string
"mime-type":
type: string
Note: This is not only limited to the typescript-axios generator but all typescript-* generators. The AbstractTypeScriptClientCodegen.java file, which is used in all / most TypeScript generators, causes the problem.
openapi-generator generate \
-i example.yaml \
-g typescript-axios \
-o generated-sources/openapi \
--additional-properties=supportsES6=true,modelPropertyNaming='original'
Example interface in generated api.ts file.I know there are some similar issues, but those are more on a specific case, like an @ being removed or a - being replaced by an _. This issue is more focussed on the sanitizing of property names in general which shouldn't happen unless needed.
https://github.com/OpenAPITools/openapi-generator/issues/4065
I would suggest wrapping all property names (so not variable names) in quotes. You could argue that to keep it clean you should only wrap property names that require quotes to be valid should have quotes, but it would add complexity that is not really needed.
馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
I agree with this.
Any update related with this issue ?
yes please, this would really be helpful.
or maybe, if you don't want to change existing behaviour make it configurable by a new value for the modelNamingProperty, like "originalNoSanitation" or something along this line...
Most helpful comment
I agree with this.