Swagger-codegen: Deserialization failed due to change of property name

Created on 26 Feb 2017  路  4Comments  路  Source: swagger-api/swagger-codegen

Description

The issue is originally reported via https://github.com/swagger-api/swagger-codegen/issues/4805#issuecomment-280615622

For typescript-angular2:

"Request": {
                "device_type": {
                    "type": "string"
                },
            }
        },

generates:

export interface Request { 
    deviceType?: string;
}

The deserialization does not work as there's no mapping between deviceType and device_type (original attribute name in JSON)

Swagger-codegen version

latest master and 2.3.0

cc @Ondra09, @ataraxus, @Tifu

TypeScript Bug help wanted

Most helpful comment

@ard61 please submit a PR as I don't think anyone has started working on a solution for Typescript-angular2 regarding this problem.

All 4 comments

@Ondra09, @ataraxus may I know if you've tried the typescript-node generator (not typescript-angular2) in 2.3.0 branch to see if the deserialization works? I'd a look at the code and I think it should work.

I tried till now only the typescript-angular2 generator. If it helps, I could also test the node one.

@wing328 I've encountered this same issue (deserialization failed because no property name mapping in typescript-angular2).

So, I implemented property name mappings for typescript-angular2 in my fork of swagger-codegen:2.3.0, reusing @TiFu 's solution from PR #4264 . I am ready to submit a pull request with this fix, if you want.

I have also come across PR #4267, which discussed the long-term goal of implementing property name mappings in a common way across all Typescript code generators. Is this still being implemented (which would make my fix unnecessary)?

Thanks!

@ard61 please submit a PR as I don't think anyone has started working on a solution for Typescript-angular2 regarding this problem.

Was this page helpful?
0 / 5 - 0 ratings