You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In certain cases when providing an enum as an input the generated C code will attempt to free the enum after it is used.
For the example spec provided it generates this enum:
Originally seen with 6.2.1 and reproduced on 6.5.0 and latest 6.60 snapshot
OpenAPI declaration file content or url
openapi: 3.0.1info:
title: Simple APIversion: 1.0.0servers:
- url: /paths:
/{id}:
delete:
tags:
- controllersummary: Deletes an item and optionally its subitemsdescription: |- Deletes an item Minimum API version: 1.0operationId: deleteitemparameters:
- name: idin: pathdescription: |- Delete the specific item in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Minimum API version: 1.0required: trueschema:
type: string
- name: cascadesin: queryschema:
type: stringenum:
- none
- subitemresponses:
204:
description: Deleted the item and any associated subitemscontent: {}
Generation Details
java -jar ../openapi-generator-cli-6.6.0-20230420.080546-29.jar generate -g c --additional-properties=prependFormOrBodyParameters=true -o out -i ../simple.yaml
Steps to reproduce
Generate the C client with the above command line and the provided spec
Observe the incorrect code output in out/api/ControllerAPI.c
Related issues/PRs
I tried out this PR which mentions fixing C enums but it didn't fix the issue #14434
Suggest a fix
The only extra information I have is that the issue goes away if I define a schema in the response such as the following:
openapi: 3.0.1info:
title: Simple APIversion: 1.0.0servers:
- url: /paths:
/{id}:
delete:
tags:
- controllersummary: Deletes an item and optionally its subitemsdescription: |- Deletes an item Minimum API version: 1.0operationId: deleteitemparameters:
- name: idin: pathdescription: |- Delete the specific item in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Minimum API version: 1.0required: trueschema:
type: string
- name: cascadesin: queryschema:
type: stringenum:
- none
- subitemresponses:
204:
description: Deleted the item and any associated subitemscontent:
application/json:
schema:
type: object
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
In certain cases when providing an enum as an input the generated C code will attempt to free the enum after it is used.
For the example spec provided it generates this enum:
Which is used once
And then for some reason freed which causes a compilation error:
openapi-generator version
Originally seen with 6.2.1 and reproduced on 6.5.0 and latest 6.60 snapshot
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
out/api/ControllerAPI.c
Related issues/PRs
I tried out this PR which mentions fixing C enums but it didn't fix the issue #14434
Suggest a fix
The only extra information I have is that the issue goes away if I define a schema in the response such as the following:
The text was updated successfully, but these errors were encountered: