mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-30 12:40:52 +00:00
[C-libcurl] The JSON key name in request/response body should not be escaped even though it is a C key word. (#4893)
This commit is contained in:
parent
178a3e24bd
commit
85f6ed5338
@ -282,18 +282,18 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
{{^isContainer}}
|
{{^isContainer}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
{{#isNumeric}}
|
{{#isNumeric}}
|
||||||
if(cJSON_AddNumberToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Numeric
|
goto fail; //Numeric
|
||||||
}
|
}
|
||||||
{{/isNumeric}}
|
{{/isNumeric}}
|
||||||
{{#isBoolean}}
|
{{#isBoolean}}
|
||||||
if(cJSON_AddBoolToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddBoolToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Bool
|
goto fail; //Bool
|
||||||
}
|
}
|
||||||
{{/isBoolean}}
|
{{/isBoolean}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
{{#isString}}
|
{{#isString}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{name}}}{{classname}}_ToString({{{classname}}}->{{{name}}})) == NULL)
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{name}}}{{classname}}_ToString({{{classname}}}->{{{name}}})) == NULL)
|
||||||
{
|
{
|
||||||
goto fail; //Enum
|
goto fail; //Enum
|
||||||
}
|
}
|
||||||
@ -301,30 +301,30 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{#isString}}
|
{{#isString}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //String
|
goto fail; //String
|
||||||
}
|
}
|
||||||
{{/isString}}
|
{{/isString}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#isByteArray}}
|
{{#isByteArray}}
|
||||||
if(cJSON_AddNumberToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Byte
|
goto fail; //Byte
|
||||||
}
|
}
|
||||||
{{/isByteArray}}
|
{{/isByteArray}}
|
||||||
{{#isBinary}}
|
{{#isBinary}}
|
||||||
char* encoded_str_{{{name}}} = base64encode({{{classname}}}->{{{name}}}->data,{{{classname}}}->{{{name}}}->len);
|
char* encoded_str_{{{name}}} = base64encode({{{classname}}}->{{{name}}}->data,{{{classname}}}->{{{name}}}->len);
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", encoded_str_{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", encoded_str_{{{name}}}) == NULL) {
|
||||||
goto fail; //Binary
|
goto fail; //Binary
|
||||||
}
|
}
|
||||||
free (encoded_str_{{{name}}});
|
free (encoded_str_{{{name}}});
|
||||||
{{/isBinary}}
|
{{/isBinary}}
|
||||||
{{#isDate}}
|
{{#isDate}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Date
|
goto fail; //Date
|
||||||
}
|
}
|
||||||
{{/isDate}}
|
{{/isDate}}
|
||||||
{{#isDateTime}}
|
{{#isDateTime}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Date-Time
|
goto fail; //Date-Time
|
||||||
}
|
}
|
||||||
{{/isDateTime}}
|
{{/isDateTime}}
|
||||||
@ -336,7 +336,7 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
if({{{name}}}_enum_local_JSON == NULL) {
|
if({{{name}}}_enum_local_JSON == NULL) {
|
||||||
goto fail; // enum
|
goto fail; // enum
|
||||||
}
|
}
|
||||||
cJSON_AddItemToObject(item, "{{{name}}}", {{{name}}}_enum_local_JSON);
|
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_enum_local_JSON);
|
||||||
if(item->child == NULL) {
|
if(item->child == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -346,19 +346,19 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
if({{{name}}}_local_JSON == NULL) {
|
if({{{name}}}_local_JSON == NULL) {
|
||||||
goto fail; //model
|
goto fail; //model
|
||||||
}
|
}
|
||||||
cJSON_AddItemToObject(item, "{{{name}}}", {{{name}}}_local_JSON);
|
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_local_JSON);
|
||||||
if(item->child == NULL) {
|
if(item->child == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{/isModel}}
|
{{/isModel}}
|
||||||
{{#isUuid}}
|
{{#isUuid}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //uuid
|
goto fail; //uuid
|
||||||
}
|
}
|
||||||
{{/isUuid}}
|
{{/isUuid}}
|
||||||
{{#isEmail}}
|
{{#isEmail}}
|
||||||
if(cJSON_AddStringToObject(item, "{{{name}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
|
||||||
goto fail; //Email
|
goto fail; //Email
|
||||||
}
|
}
|
||||||
{{/isEmail}}
|
{{/isEmail}}
|
||||||
@ -367,7 +367,7 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
if({{{name}}}_object == NULL) {
|
if({{{name}}}_object == NULL) {
|
||||||
goto fail; //model
|
goto fail; //model
|
||||||
}
|
}
|
||||||
cJSON_AddItemToObject(item, "{{{name}}}", {{{name}}}_object);
|
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_object);
|
||||||
if(item->child == NULL) {
|
if(item->child == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
{{#isListContainer}}
|
{{#isListContainer}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{name}}}");
|
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
|
||||||
if({{{name}}} == NULL) {
|
if({{{name}}} == NULL) {
|
||||||
goto fail; //primitive container
|
goto fail; //primitive container
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
}
|
}
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{^isPrimitiveType}}
|
{{^isPrimitiveType}}
|
||||||
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{name}}}");
|
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
|
||||||
if({{{name}}} == NULL) {
|
if({{{name}}} == NULL) {
|
||||||
goto fail; //nonprimitive container
|
goto fail; //nonprimitive container
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
|
|||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/isListContainer}}
|
{{/isListContainer}}
|
||||||
{{#isMapContainer}}
|
{{#isMapContainer}}
|
||||||
cJSON *{{{name}}} = cJSON_AddObjectToObject(item, "{{{name}}}");
|
cJSON *{{{name}}} = cJSON_AddObjectToObject(item, "{{{baseName}}}");
|
||||||
if({{{name}}} == NULL) {
|
if({{{name}}} == NULL) {
|
||||||
goto fail; //primitive map container
|
goto fail; //primitive map container
|
||||||
}
|
}
|
||||||
@ -466,7 +466,7 @@ fail:
|
|||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
// {{{classname}}}->{{{name}}}
|
// {{{classname}}}->{{{name}}}
|
||||||
cJSON *{{{name}}} = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{name}}}");
|
cJSON *{{{name}}} = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{baseName}}}");
|
||||||
{{#required}}
|
{{#required}}
|
||||||
if (!{{{name}}}) {
|
if (!{{{name}}}) {
|
||||||
goto end;
|
goto end;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user