@@ -1613,7 +1613,16 @@ private static ServiceModel ParseModel(AutoRestCompositeType autoRestCompositeTy
16131613 if ( settings . ShouldGenerateXmlSerialization )
16141614 {
16151615 modelImports . Add ( "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement" ) ;
1616- modelImports . Add ( "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty" ) ;
1616+
1617+ if ( compositeTypeProperties . Any ( p => p . XmlIsAttribute ) )
1618+ {
1619+ modelImports . Add ( "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty" ) ;
1620+ }
1621+
1622+ if ( compositeTypeProperties . Any ( p => ! p . XmlIsAttribute ) )
1623+ {
1624+ modelImports . Add ( "com.fasterxml.jackson.annotation.JsonProperty" ) ;
1625+ }
16171626
16181627 if ( compositeTypeProperties . Any ( p => p . ModelType is AutoRestSequenceType ) )
16191628 {
@@ -2453,12 +2462,10 @@ public static JavaFile GetModelJavaFile(ServiceModel model, JavaSettings setting
24532462 {
24542463 classBlock . Annotation ( "HeaderCollection(\" " + property . HeaderCollectionPrefix + "\" )" ) ;
24552464 }
2456- else if ( settings . ShouldGenerateXmlSerialization )
2465+ else if ( settings . ShouldGenerateXmlSerialization && property . IsXmlAttribute )
24572466 {
24582467 string localName = settings . ShouldGenerateXmlSerialization ? property . XmlName : property . SerializedName ;
2459- classBlock . Annotation ( property . IsXmlAttribute
2460- ? $ "JacksonXmlProperty(localName = \" { localName } \" , isAttribute = true)"
2461- : $ "JacksonXmlProperty(localName = \" { localName } \" )") ;
2468+ classBlock . Annotation ( $ "JacksonXmlProperty(localName = \" { localName } \" , isAttribute = true)") ;
24622469 }
24632470 else if ( ! string . IsNullOrEmpty ( property . AnnotationArguments ) )
24642471 {
@@ -2739,7 +2746,7 @@ public static JavaFile GetEnumJavaFile(EnumType serviceEnum, JavaSettings settin
27392746
27402747 enumBlock . JavadocComment ( $ "The actual serialized value for a { serviceEnum . Name } instance.") ;
27412748 enumBlock . PrivateFinalMemberVariable ( "String" , "value" ) ;
2742-
2749+
27432750 enumBlock . PrivateConstructor ( $ "{ serviceEnum . Name } (String value)", ( constructor ) =>
27442751 {
27452752 constructor . Line ( "this.value = value;" ) ;
@@ -2764,7 +2771,7 @@ public static JavaFile GetEnumJavaFile(EnumType serviceEnum, JavaSettings settin
27642771 } ) ;
27652772 function . Return ( "null" ) ;
27662773 } ) ;
2767-
2774+
27682775 enumBlock . Annotation ( "JsonValue" ,
27692776 "Override" ) ;
27702777 enumBlock . PublicMethod ( "String toString()" , ( function ) =>
0 commit comments