OpenAPITools / OpenAPITools/openapi-generator

Override default special chars replacement

Open
#14,706 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

I'm using openapi generator to generate a Rust library from Scaleway Cloud provider OpenAPI spec (https://github.com/Qovery/scaleway-api-rs). When I generate the API, the naming does not respect the spec because of replaced chars.

Example, the spec starts with:

...
components:
  schemas:
    google.protobuf.UInt32Value:
      type: integer
      nullable: true
    scaleway.k8s.v1.CNI:
      type: string
      enum:
      - unknown_cni
      - cilium
      - calico
      - weave
      - flannel
      - kilo
      default: unknown_cni
    scaleway.k8s.v1.Cluster:
...

Here scaleway.k8s.v1.CNI, when generated becomes:

pub use self::scaleway_period_k8s_period_v1_period_cni::ScalewayPeriodK8sPeriodV1PeriodCni;

As you can see Period and _period_ are replacing the dots everywhere https://docs.rs/scaleway_api_rs/latest/scaleway_api_rs/models/index.html

Describe the solution you'd like

It would be great to have a way to override default special chars override
https://github.com/OpenAPITools/openapi-generator/blob/68b944e6e62fa69669e97a8c2041a7eb7ed3314a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L1820
to avoid this behavior.

I may have missed something, and there is something simple to achieve this, so feel free to tell me.

What do you think?

Thanks

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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java at the referenced special-character replacement logic. Trace how generator options reach this code and how the Rust generator applies the replacement to schema names. Done means users can override the replacement behavior and the Scaleway-style names are generated without the unwanted Period substitutions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, rust
Domain
tooling
Issue type
Feature
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.