swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[QT5CPP] modelNamePrefix has to be set to SWG

Open stmeyer opened this issue 9 years ago • 2 comments

Description

If modelNamePrefix in QT5CPP client code gen is different to SWG the deserialazation form JSON to C++ object is not possible. The method setValue(void* value, QJsonValue obj, QString type, QString complexType) checks the name of the value in line 122 (https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache#L122) and is has to start with SWG. If the model name starts with a different string, the models could not be converted.

Swagger-codegen version

2.2.3 and current master

Swagger declaration file content or url

I think no example is needed. If so please ask

Command line used for generation

Should not be needed, too.

Steps to reproduce

compile swagger code gen jar file with different modelNamePrefix. In my case the modelNamePrefix is empty by default.

Related issues/PRs

#1255

Suggest a fix/enhancement

In Qt5CPPGenerator.java add

        // set modelNamePrefix as default for QT5CPP
        if (modelNamePrefix == "") {
            modelNamePrefix = PREFIX;
        }

in the constructor, so that the default is set to SWG if no modelNamePrefix is set. But in file https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache#L122 the modelNamePrefix has to be set, too. Is it possible to add it to mustache file?

stmeyer avatar Aug 15 '17 14:08 stmeyer

fix is included in #6315

stmeyer avatar Aug 16 '17 13:08 stmeyer

#6315 is merged

stmeyer avatar Aug 25 '17 10:08 stmeyer