OpenAPITools / OpenAPITools/openapi-generator

[BUG][C] Enumerate missing in parameters

Open
#10,834 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I have a problem generating c code from my swagger specification.

I tried to follow the compilation instructions. The cmake .. command was ok. But when I tried to run the command make I got several errors :

[ 26%] Building C object CMakeFiles/swagger_finanting.dir/model/banking_transaction_dto.c.o
/home/jbwittner/Workspace/openapi/c/model/banking_transaction_dto.c: In function ‘banking_transaction_dto_create’:
/home/jbwittner/Workspace/openapi/c/model/banking_transaction_dto.c:61:38: error: ‘banking_transaction_dto_t’ {aka ‘struct banking_transaction_dto_t’} has no member named ‘transaction_type_enum’
   61 |     banking_transaction_dto_local_var->transaction_type_enum = transaction_type_enum;
      |                                      ^~
/home/jbwittner/Workspace/openapi/c/model/banking_transaction_dto.c:61:64: error: ‘transaction_type_enum’ undeclared (first use in this function); did you mean ‘transaction_type_enum_t’?
   61 | g_transaction_dto_local_var->transaction_type_enum = transaction_type_enum;
      |                                                      ^~~~~~~~~~~~~~~~~~~~~
      |                                                      transaction_type_enum_t
/home/jbwittner/Workspace/openapi/c/model/banking_transaction_dto.c:61:64: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [CMakeFiles/swagger_finanting.dir/build.make:238: CMakeFiles/swagger_finanting.dir/model/banking_transaction_dto.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/swagger_finanting.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

And when i check the code i have :

banking_transaction_dto_t *banking_transaction_dto_create(
    int id,
    banking_account_dto_t *banking_account_dto,
    banking_account_dto_t *linked_banking_account_dto,
    third_dto_t *third_dto,
    category_dto_t *category_dto,
    classification_dto_t *classification_dto,
    char *transaction_date,
    char *amount_date,
    double amount,
    double currency_amount,
    currency_dto_t *currency_dto,
    char *description,
    char *create_timestamp,
    char *update_timestamp,
    int is_conciliate,
    int is_cleared
    ) {
    banking_transaction_dto_t *banking_transaction_dto_local_var = malloc(sizeof(banking_transaction_dto_t));
    if (!banking_transaction_dto_local_var) {
        return NULL;
    }
    banking_transaction_dto_local_var->id = id;
    banking_transaction_dto_local_var->banking_account_dto = banking_account_dto;
    banking_transaction_dto_local_var->linked_banking_account_dto = linked_banking_account_dto;
    banking_transaction_dto_local_var->third_dto = third_dto;
    banking_transaction_dto_local_var->category_dto = category_dto;
    banking_transaction_dto_local_var->classification_dto = classification_dto;
    banking_transaction_dto_local_var->transaction_date = transaction_date;
    banking_transaction_dto_local_var->amount_date = amount_date;
    banking_transaction_dto_local_var->amount = amount;
    banking_transaction_dto_local_var->currency_amount = currency_amount;
    banking_transaction_dto_local_var->currency_dto = currency_dto;
    banking_transaction_dto_local_var->description = description;
    banking_transaction_dto_local_var->create_timestamp = create_timestamp;
    banking_transaction_dto_local_var->update_timestamp = update_timestamp;
    banking_transaction_dto_local_var->transaction_type_enum = transaction_type_enum;
    banking_transaction_dto_local_var->is_conciliate = is_conciliate;
    banking_transaction_dto_local_var->is_cleared = is_cleared;

    return banking_transaction_dto_local_var;
}

I'm not sure but the transaction_type_enum_t *transaction_type_enum is missing ??

Someone can help me ?

openapi-generator version

Version 5.3.0

(i have tried with the package openapi-generator-cli-6.0.0-20211109.082840-24.jar and the bug is still there).

OpenAPI declaration file content or url

My specification is here.
The specification is valid.

Generation Details

I have generate the code with openapi-generator-cli generate -i openapi.yaml -g c -o c

Steps to reproduce
  • Generate the code
  • Follow the build instructions
Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked openapi.yaml and reproduce generation using openapi-generator-cli generate -i openapi.yaml -g c -o c, then build the generated project with CMake and make. Inspect the generated banking_transaction_dto model and constructor around the missing transaction_type_enum; done means the generated C project compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.