We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When generating code containing enums we assign a default value of -1 when reading the item from JSON.
In item_resource.c
item_resource_local_var = item_resource_create ( value ? valueVariable : -1 );
Expected
item_resource_local_var = item_resource_create ( value ? valueVariable : simple_api_item_resource_VALUE_NULL );
Tested with 6.6.0 originally but reproduced on 7.2.0 and master (8b5b5a7).
openapi: 3.0.1 info: title: Simple API version: 1.0.0 servers: - url: / paths: /{id}: get: summary: Get item description: |- Gets the item. parameters: - name: id in: path description: |- Gets the specific item in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx required: true schema: type: string - name: content in: query schema: type: string enum: - all - subset responses: '200': $ref: '#/components/responses/GetItem' components: schemas: ItemResource: type: object properties: value: type: string enum: - value1 - value2 GetItemResult: type: object properties: key: $ref: '#/components/schemas/ItemResource' description: |- Representation of an item responses: GetItem: description: |- Representation of an item returned content: application/json: schema: $ref: '#/components/schemas/GetItemResult'
java -jar ../openapi-generator-cli-7.2.0.jar generate -g c --additional-properties=prependFormOrBodyParameters=true -o out -i ../simple.yaml
out/model/item_resource.c
I have looked through all the issues marked with [C] and can't see any duplicates. I also can't find any open PRs attempting to fix this.
I think this is the fix but I don't know if it's complete or if it will break anything else.
diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache index 98bbfd3799..e8f0841d60 100644 --- a/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache +++ b/modules/openapi-generator/src/main/resources/C-libcurl/model-body.mustache @@ -845,7 +845,7 @@ fail: {{^isPrimitiveType}} {{#isModel}} {{#isEnum}} - {{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim_enum{{^required}} : -1{{/required}}{{^-last}},{{/-last}} + {{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim_enum{{^required}} : {{projectName}}_{{classVarName}}_{{enumName}}_NULL{{/required}}{{^-last}},{{/-last}} {{/isEnum}} {{^isEnum}} {{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim{{^required}} : NULL{{/required}}{{^-last}},{{/-last}} @@ -875,7 +875,7 @@ fail: {{/isBoolean}} {{#isEnum}} {{#isString}} - {{^required}}{{{name}}} ? {{/required}}{{name}}Variable{{^required}} : -1{{/required}}{{^-last}},{{/-last}} + {{^required}}{{{name}}} ? {{/required}}{{name}}Variable{{^required}} : {{projectName}}_{{classVarName}}_{{enumName}}_NULL{{/required}}{{ ^-last}},{{/-last}} {{/isString}} {{/isEnum}} {{^isEnum}}
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Bug Report Checklist
Description
When generating code containing enums we assign a default value of -1 when reading the item from JSON.
In item_resource.c
Expected
openapi-generator version
Tested with 6.6.0 originally but reproduced on 7.2.0 and master (8b5b5a7).
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
out/model/item_resource.c
Related issues/PRs
I have looked through all the issues marked with [C] and can't see any duplicates. I also can't find any open PRs attempting to fix this.
Suggest a fix
I think this is the fix but I don't know if it's complete or if it will break anything else.
The text was updated successfully, but these errors were encountered: