-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] [JavaJaxRS] Combining modelNameSuffix
and import-mappings
#11478
Comments
* remove import mapping logic in model generation, better handle of file, list * add new files for file, list * fix some tests * update tests, doc * skip file as reserved word in feign client * add new files * remove file from reserved word list in spring generator
I'm also getting this issue and I'm using this workaround to fix it. I'm setting a languageSpecificPrimitive, these should really be ignored by the modelNameSuffix as I'm already declaring what I want it to be called, if I want the Suffix on it I could just mention it there. |
Behaviour changed again when switching from 6.0.0 to 6.0.1. To achieve the wanted result, the config now has to look like this: {
"typeMappings": {
"ExampleId": "com.example.model.id.ExampleId"
},
"schemaMappings": {
"ExampleId": "needed to trigger typeMappings"
}
} |
this seems to be exactly what I reported in the PR after my tests: #12600 (comment) @wing328 I guess there really is an issue |
I'll try to take another look this weekend if someone can provide a minimal/full spec and the settings (e.g. --import-mappings) to reproduce the issue. |
This issue seems to have been fixed by introducing the new |
@mickroll will you create a new issue for this: #11478 (comment) ? |
No i did not. Feel free to do so, please. |
Bug Report Checklist
Description
We use
<modelNameSuffix>TO</modelNameSuffix>
to distinct all our generated models from our internal models and prevent name collissions. In our Spec, we define our Ids as follows (in an extra fileid.json
):The spec then references these id types:
To prevent OpenAPI-Generator from generating
ExampleId
-classes, we define a mapping configuration via<configurationFile>configuration.json</configurationFile>
:The referenced class
ExampleId
already exists of course.All of this worked in
5.3.1
an lead to sources like this:With
5.4.0
this is generated:Note: a
ExampleIdTO
is not generated! (we don't want it to, just a note)I tracked the changed behaviour to 33bce99#r65722393 but as the PR says, this change is intended. Was it really, given the example above? Or was using
modelNamePrefix
/modelNameSuffix
out of scope for that PR?Workaround
If i change our
configuration.json
to the following, valid sources are generated:But this seems very redundant and partly wrong to me. If i leave out any of the three definitions, it stops working:
typeMappings.ExampleIdTO
:ExampleWrapperTO
usesExampleIdTO
instead ofExampleId
importMappings.ExampleId
:ExampleWrapperTO
usesUUID
instead ofExampleId
importMappings.ExampleIdTO
:ExampleWrapperTO
importscom.example.api.generated.model.ExampleIdTO
(which doesn't exist), but notcom.example.model.id.ExampleId
, but usesprivate @Valid ExampleId id
, which cannot be foundopenapi-generator version
5.4.0 (worked in 5.3.1)
OpenAPI declaration file content or url
see above
Generation Details
openapi-generator-maven-plugin:5.4.0
with config:
Steps to reproduce
Related issues/PRs
#11217
Suggest a fix
Revert #11217 or some of its contents?
The text was updated successfully, but these errors were encountered: