OpenAPITools / OpenAPITools/openapi-generator

[REQ] Add a way to Update model names based on the Type ( response | request )

Open
#21,695 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.

I had a lot of problems when trying to update the model names based on requests or responses.
The main goal was : If request add Request to the name
if Response add Response to the Name

One big issue i ran into was when i was overriding the preprocessOpenAPI function and going through the paths to update the refs and then getting a mapping of names and then passing through the schemas to update the names, the modelJson and JsonSchema properties would not get updated (i think it has to do with the 3.1 OpenAPI creating empty schemas and filling them using the modelKeys Supplier that you can't override) and so i would need to redo the work in the processAllModels function

Describe the solution you'd like

One solution I already applied was going through the OpenAPI and updating refs recursively. in preprocessOpenAPI
And then go over the CodegenModels and do it again in processAllModels

Describe alternatives you've considered

A better alternative pointed out to me by William Cheng was to do that in the Normalizer (I m not sure if it would work though due to the same Normalize3.1 spec rule) but i am looking into (it would also involve overriding all normalizeX functions in the Normalizer

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 by tracing the preprocessOpenAPI and processAllModels entry points, then compare them with the Normalizer and its normalizeX functions, especially around modelKeys, modelJson, and JsonSchema. Done should mean request and response schemas receive distinct names while references and generated model metadata remain consistent for OpenAPI 3.1.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, 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.