Skip to content

[BUG] [C-libcurl] The name of field in a struct cannot get escaped when it is the keywords of C such "enum, continue, etc" or includes "-" #4700

@ityuhui

Description

@ityuhui

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

When using C-libcurl generator to generate kubernetes API, some field names are keywords of C programming language, e.g.

object_ *default;
list_t *enum;

And some field names include "-", e.g.

int x-kubernetes-int-or-string;

The source code fails to compile due to these field names.

openapi-generator version

master

OpenAPI declaration file content or url

https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

Command line used for generation

mvn clean package
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json -g c -o ../c_k8s_api_client

Steps to reproduce
  1. generate the c api client by the above command
  2. check the file "c_k8s_api_client/model/v1_json_schema_props.h"
Related issues/PRs

#3970

Suggest a fix

does openapi-generator provide a method to escape the name of field in a struct ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions