Skip to content

Commit

Permalink
fix datetime and map type for qt5cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Apr 5, 2018
1 parent d882ad2 commit a4bcb3b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
}

if (p instanceof DateSchema || SchemaTypeUtil.DATE_FORMAT.equals(p.getFormat())) {
property.isString = false; // for backward compatibility with 2.x
property.isDate = true;
if (p.getEnum() != null) {
List<String> _enum = p.getEnum();
Expand All @@ -1710,6 +1711,7 @@ public CodegenProperty fromProperty(String name, Schema p) {
}

if (p instanceof DateTimeSchema || SchemaTypeUtil.DATE_TIME_FORMAT.equals(p.getFormat())) {
property.isString = false; // for backward compatibility with 2.x
property.isDateTime = true;
if (p.getEnum() != null) {
List<String> _enum = p.getEnum();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,24 @@ bool
bool isObjectUpdated = false;
do{
{{#vars}}
{{#isPrimitiveType}}if(m_{{name}}_isSet){ isObjectUpdated = true; break;}{{/isPrimitiveType}}{{#isContainer}}if({{name}}->size() > 0){ isObjectUpdated = true; break;}{{/isContainer}}{{^isContainer}}{{#complexType}}{{^isString}}{{^isDateTime}}if({{name}} != nullptr && {{name}}->isSet()){ isObjectUpdated = true; break;}{{/isDateTime}}{{/isString}}{{#isString}}if({{name}} != nullptr && *{{name}} != QString("")){ isObjectUpdated = true; break;}{{/isString}}{{/complexType}}{{/isContainer}}
{{#isPrimitiveType}}
if(m_{{name}}_isSet){ isObjectUpdated = true; break;}
{{/isPrimitiveType}}
{{#isContainer}}
if({{name}}->size() > 0){ isObjectUpdated = true; break;}
{{/isContainer}}
{{^isContainer}}
{{#complexType}}
{{^isString}}
{{^isDateTime}}
if({{name}} != nullptr && {{name}}->isSet()){ isObjectUpdated = true; break;}
{{/isDateTime}}
{{/isString}}
{{#isString}}
if({{name}} != nullptr && *{{name}} != QString("")){ isObjectUpdated = true; break;}
{{/isString}}
{{/complexType}}
{{/isContainer}}
{{/vars}}
}while(false);
return isObjectUpdated;
Expand Down
4 changes: 0 additions & 4 deletions samples/client/petstore/qt5cpp/client/SWGOrder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ SWGOrder::asJsonObject() {
if(m_quantity_isSet){
obj.insert("quantity", QJsonValue(quantity));
}
if(ship_date != nullptr && *ship_date != QString("")){
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
if(ship_date != nullptr) {
toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime"));
}
Expand Down Expand Up @@ -195,7 +192,6 @@ SWGOrder::isSet(){
if(m_id_isSet){ isObjectUpdated = true; break;}
if(m_pet_id_isSet){ isObjectUpdated = true; break;}
if(m_quantity_isSet){ isObjectUpdated = true; break;}
if(ship_date != nullptr && *ship_date != QString("")){ isObjectUpdated = true; break;}
if(status != nullptr && *status != QString("")){ isObjectUpdated = true; break;}
if(m_complete_isSet){ isObjectUpdated = true; break;}
}while(false);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/qt5cpp/client/SWGStoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ SWGStoreApi::getInventoryCallback(SWGHttpRequestWorker * worker) {
msg = "Error: " + worker->error_str;
}

QMap<QString, qint32>* output = NULL;
QMap<QString, qint32>* output = new QMap<QString, qint32>();
QString json(worker->response);
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
Expand Down

0 comments on commit a4bcb3b

Please sign in to comment.