Skip to content

TypeScript generation forces lower case first character #1926

Closed
@dicko2

Description

@dicko2

To give some background, we use a C# WebAPI service, so we use Pascal casing in our objects. We have both C# cleints and TypeScript Clients that access the API.

When using the codegen to generate a TypeScript client for angularJS, the TypeScript code appears to be forcing the property names to camel case using the second variable in the camelize function on this line: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java#L86

This causing issue for us because our we service returns an object like this:

{
"ObjectId": 203
"ObjectName" : "My Object Name"
}

And the object in TypeScript looks like this:

export interface MyObject {
 objectId: number;
 objectName: string;
}

So the object name is fine, its the properties that are wrong.

So when the javascript runs its failing as the names don't line up.

I think this second parameter in the camelize function should be added as a config option for those that need it compatible with C# services.

I understand that MS recommend camel casing for TypeScript properties (here https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines), but this makes it incompatible with services written in C#, so I think the config option for the language is the best option.

Regards,
Joel

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions