Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5735
Closed
Open
Issue created Mar 28, 2020 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG] [C Client] incorrect generate "object_convertToJSON" function

Created by: Oleg-Stepanenko-owo

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

I use OpenApi3 generator (Openapi-generator-cli-4.1.0) for C client, and found not for clean functional for me.

So, I have some json template where I plan to use "payload" like addition parameter (json Object type) for my functionality:

...
"data": { "type": "object", "properties": { "message": { "type": "string", "minLength": 1, "maxLength": 1024, "description": "human-readable event description" }, "payload": { "type": "object", "description": "(optional) Additional data, some object/property should be added, integer/string/array/object", "properties": {} } }, ....

after generation we have object.h and object.c files for working with object_t type.

Please to correct my if I am wrong. For make "object" type need to do something like:

object_t* _tmp = object_create();
cJSON* obj = object_convertToJSON(_tmp);
if(cJSON_AddNumberToObject(obj, "value", 123)){
return true;
}

but currently looks like that function:"object_convertToJSON" not fully correct or maybe my json template wrong?

cJSON *object_convertToJSON(object_t *object) {
    cJSON *item = cJSON_CreateObject();

    return item;
fail:
    cJSON_Delete(item);
    return NULL;
}

I fix this issue internally, like:

cJSON *object_convertToJSON(object_t *object) {
    **//cJSON *item = cJSON_CreateObject();**
    return (cJSON *)object;
}
...
cJSON * _tmp = cJSON_CreateObject();
bla-bla...
openapi-generator version

Openapi-generator-cli-4.1.0

OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking