Swagger-codegen: Bug with -l qt5cpp and datatype "Date"

Created on 26 Apr 2016  Â·  11Comments  Â·  Source: swagger-api/swagger-codegen

I have in my Swagger definition

  TransactionsObject:
    type: object
    properties:
      from:
        type: string
        format: date
      to:
        type: string
        format: date

and in my generated code

#include "SWGDate.h"
......
    SWGDate* getFrom();
    void setFrom(SWGDate* from);
   SWGDate* getTo();
    void setTo(SWGDate* to);

private:
    SWGDate* from;
    SWGDate* to;

but there is no SWGDate.hfile. Also https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java#L114 suggests that Date should be mapped to Qts own datatype QDate

I tried with master HEAD aswell as http://editor.swagger.io

C++ Bug

All 11 comments

@philicious thanks for reporting the issue and I've filed #2707 to fix it.

@philicious PR merged into master. Please pull the latest and let us know if you still experience the same issue.

@wing328 awesome. I quickly tested it and its fixed indeed :+1:

#include "QDate.h"
......
    QDate* getFrom();
    void setFrom(QDate* from);
QDate* getTo();
    void setTo(QDate* to);

private:
    QDate* from;
QDate* to;

@wing328 editor.swagger.io still generates faulty client SDK

@philicious thanks for letting me know. I think editor.swagger.io is using the latest "stable" version (not the latest master) of swagger codegen

@wing328 I just noticed, there is a similar bug in here https://github.com/wing328/swagger-codegen/blob/2b71165584cda00294cd57d6bd58d93b406ecde7/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java#L115 it should read datetime not DateTime

Now it generates QString for a format: datetime instead of QDateTime

@philicious thanks for pinpointing the issue. Do you have cycle to contribute a PR so that the credit goes back to you?

@wing328 yes. Will do in a few hours

Am Dienstag, 24. Mai 2016 um 14:51 schrieb wing328:

@philicious (https://github.com/philicious) thanks for pinpointing the issue. Do you have cycle to contribute a PR so that the credit goes back to you?

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub (https://github.com/swagger-api/swagger-codegen/issues/2706#issuecomment-221258573)

@wing328 I noticed I had put format: datetime instead of format: date-time .. with the latter its producing QDateTime as it should. No fix needed. :+1:

However I'm confused now, maybe you can shed some light into it to clear my confusion:
(or point me to code where the typeMappings are used)

For format: date to produce QDate it needs lowercase date in typeMapping.put("date", "QDate"); (which is what you fixed) but for format: date-time to produce QDateTime this typeMapping.put("DateTime", "QDateTime"); seems to be correct. Why doesnt it need to be lowercased or even with a dash as the format reads?!
So the format seems to be mapped another time before the language-specific generator is invoked?

Was this page helpful?
0 / 5 - 0 ratings