OpenAPITools / OpenAPITools/openapi-generator
[BUG] Different Prefixes for Models and Operations Should Be Allowed
Nobody has claimed this yet.
- 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)?
- 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 executing openapi-codegenerator with the command line option: --model-name-prefix=, this should only change the prefix of the models. Currently it changes both the model prefix and the operation prefix. This behavior prevents the use of external models if they are generated using openapi-codegenerator. I am currently generating all my models in a separate API spec and putting them into a library. I am then trying to generate a server using a different API spec that references my models API spec. I need to be able to change the models prefix to be different from my server prefix.
openapi-generator version
openapi-generator-cli-4.1.1
cpp-qt5-qhttpengine-server/cpp-qt5-client
OpenAPI declaration file content or url
Command line used for generation
java -Dapis -DsupportingFiles -DdebugModels -DdebugOperations -jar ${OPENAPI_JAR}/openapi-codegen.jar generate --enable-post-process-file --input-spec $1 --generator-name cpp-qt5-qhttpengine-server --template-dir /space/data/Repositories/MustacheFiles/ForQHTTPEngine --output $2 --model-name-prefix=MniPars
NOTE: By using DdebugModels and DdebugOperations and I can see that both the 'prefix' and 'modelNamePrefix' are both set by the model-name-prefix command line argument.
Steps to reproduce
SnapShot of the output for the above command:

Related issues/PRs
Suggest a fix
Users should have the capability to change both prefixes differently. This will allow the use of external models. By using the -DdebugModels and -DdebugOperations, the two tags used to apply the prefix are: 'prefix' and 'modelNamePrefix'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the command-line handling of --model-name-prefix and the debugModels/debugOperations output for the cpp-qt5-qhttpengine-server generator. Compare why the prefix and modelNamePrefix values are both set, then check how external models are referenced. Done means model and operation prefixes can be configured independently without breaking generated external-model references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java, 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