mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 18:45:23 +00:00
[qt5cpp] Add nullptr guard to prevent crash when empty model is being serialized (#7434)
* Small fixes to prevent crash when empty json body is provided. * Updated PetStore example for Qt5
This commit is contained in:
parent
30c1448d78
commit
ea4b948428
@ -3,6 +3,8 @@
|
||||
#define {{prefix}}_HELPERS_H
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
{{#cppNamespaceDeclarations}}
|
||||
namespace {{this}} {
|
||||
|
@ -105,7 +105,7 @@ QJsonObject*
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
{{#vars}}
|
||||
{{^isContainer}}{{#complexType}}{{^isString}}{{^isDate}}{{^isDateTime}}{{^isByteArray}}
|
||||
if({{name}}->isSet()){
|
||||
if(({{name}} != nullptr) && ({{name}}->isSet())){
|
||||
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));
|
||||
}{{/isByteArray}}{{/isDateTime}}{{/isDate}}{{/isString}}{{#isString}}
|
||||
if({{name}} != nullptr && *{{name}} != QString("")){
|
||||
|
@ -14,6 +14,8 @@
|
||||
#define SWG_HELPERS_H
|
||||
|
||||
#include <QJsonValue>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
namespace Swagger {
|
||||
|
||||
|
@ -122,7 +122,7 @@ SWGPet::asJsonObject() {
|
||||
obj->insert("id", QJsonValue(id));
|
||||
}
|
||||
|
||||
if(category->isSet()){
|
||||
if((category != nullptr) && (category->isSet())){
|
||||
toJsonValue(QString("category"), category, obj, QString("SWGCategory"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user