-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Wrong generation of @JacksonXmlElementWrapper annotation #10333
Conversation
@@ -33,7 +33,8 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela | |||
{{#isContainer}} | |||
{{#isXmlWrapped}} | |||
// items.xmlName={{items.xmlName}} | |||
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}") | |||
@JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JacksonXmlElementWrapper
should use the swaggerArrayProperty.xml.name
as its local name instead of swaggerArrayProperty.items.xml.name
In order to customize the name for the wrapped xml element, JacksonXmlProperty
annotation also must be included.
hey @sanjeevgiri let me know when this is ready and i'll help you with merge |
Hi @HugoMario what are the steps needed to get this merged? Its a pretty minor template change and I have been able to see expected results for me. I have not been able to get feedback from the author of this issue so far though. I guess I can wait for her feedback? |
@gracekarina @mobreza |
hey @sanjeevgiri , sorry for delay, would you please update a sample to see how these change affect output code? you could update samples running |
Hi Hugo, thanks and sorry for late response myself. I will try to get to this by end of this week or hopefully early next week. I will get in touch once I get a chance to look back into this :). |
…ces with java model generation with xml
@@ -52,7 +52,8 @@ | |||
|
|||
@JsonProperty("photoUrls") | |||
// items.xmlName= | |||
@JacksonXmlElementWrapper(useWrapping = true, localName = "photoUrls") | |||
@JacksonXmlElementWrapper(useWrapping = true, localName = "photoUrl") | |||
@JacksonXmlProperty(localName = "photoUrls") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
<photoUrls>
<photoUrl>
...
</photoUrl>
<photoUrl>
...
</photoUrl>
<photoUrls>
@HugoMario |
please build |
I ran Did you want me to run something more specific. Sorry if I missed something that is routine. I am a first time contributer to this specific project. Let me know if I missed something and I will include those steps too. I ran |
@sanjeevgiri , oh sorry for confuse. "please build" it's a comment tthat i made to trigger CI tools. it seems there is an issue with appveyor. Need to fix that in order to merge your request |
Is there something I need to fix the tests? |
no really your PR looks good to me, this is a configuration issue. one of the CI tool is not being triggered, i already request for help about this. let's hope for tomorrow this is solved and your PR merged. |
Thanks a lot Hugo. I appreciate your time and help regarding this PR. |
@sanjeevgiri do you think the pr is on branch 3.0.0 too ? Master is only for 2 ? I use 3.0.22-SNAPSHOT swagger codegen and dont see improvement ... |
@volvicoasis This fix was for 2.0 specific. I was using swagger 2.0. I believe I had briefly looked at 3.0 branch and noticed that the templates were being imported from elsewhere. |
@sanjeevgiri do you know an easy way to solve the xml wrapped = false in 3.0 ? |
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
. NOTE: Are these still applicable. I did not see any file name java-petstore.sh.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.Description of the PR
Language: Java
Base version: 2.4.15-SNAPSHOT
Problem summary:
The generated code uses incorrect values for @JacksonXmlElementWrapper and skips inclusion of @JacksonElement for collection/array type properties.
Fixes #9845