OpenAPITools / OpenAPITools/openapi-generator

[REQ] Support for arbitrary model property naming

Open
#21,290 0 comments 0 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.

OpenAPI Generator does not currently support arbitrary strings for generated model property names in TypeScript, the OpenAPI specification does not have that limitation.

For example: This is limiting in my use case when working with APIs or specifications that require property names to remain in the kebab-case format.

When using the typescript codegen and setting modelPropertyNaming to original, the property names are incorrectly converted from kebab-case to snake_case.

The following would be valid in TypeScript:

type Example = { 'kebab-case': string };

and so would this (albeit somewhat unorthodox):

type Example = { '|bars|*stars*': string };

Describe the solution you'd like

Add support for arbitrary string property naming in the generated code, particularly for TypeScript, changing how name sanitizing currently works.

Describe alternatives you've considered

  • In my case: Manually mapping the snake_case to kebab-case during runtime.
  • Post-processing scripts to revert naming changes are possible but add additional development overhead.

Additional Context

It seems that DefaultCodegen sanitizes some specific chars. My understanding of the codebase is limited but perhaps that logic should be language specific as some languages support these arbitrary property names.

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 at DefaultCodegen's name-sanitizing logic and the TypeScript codegen path, focusing on behavior when modelPropertyNaming is set to original. Compare the generated output with the kebab-case and arbitrary-string examples in the issue. Done means valid TypeScript preserves supported arbitrary property names without breaking naming behavior for other generators.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.