Skip to content

Commit d0ce56e

Browse files
authored
Merge pull request #2920 from IdentityAutomation/issue-2907-1.5
fix for issue #2907 - 1.5.x version
2 parents b8086d5 + f24c50a commit d0ce56e

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

modules/swagger-core/src/main/java/io/swagger/jackson/ModelResolver.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import javax.xml.bind.annotation.XmlAccessorType;
2525
import javax.xml.bind.annotation.XmlAttribute;
2626
import javax.xml.bind.annotation.XmlElement;
27+
import javax.xml.bind.annotation.XmlElementRef;
28+
import javax.xml.bind.annotation.XmlElementRefs;
2729
import javax.xml.bind.annotation.XmlRootElement;
2830
import javax.xml.bind.annotation.XmlSchema;
2931

@@ -34,6 +36,7 @@
3436

3537
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
3638
import com.fasterxml.jackson.annotation.JsonIdentityReference;
39+
import com.fasterxml.jackson.annotation.JsonIgnore;
3740
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3841
import com.fasterxml.jackson.annotation.JsonProperty;
3942
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@@ -691,11 +694,18 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess
691694
if (propertiesToIgnore.contains(propName)) {
692695
return true;
693696
}
697+
if (member.hasAnnotation(JsonIgnore.class)) {
698+
return true;
699+
}
694700
if (xmlAccessorTypeAnnotation == null) {
695701
return false;
696702
}
697703
if (xmlAccessorTypeAnnotation.value().equals(XmlAccessType.NONE)) {
698-
if (!member.hasAnnotation(XmlElement.class) && !member.hasAnnotation(XmlAttribute.class)) {
704+
if (!member.hasAnnotation(XmlElement.class) &&
705+
!member.hasAnnotation(XmlAttribute.class) &&
706+
!member.hasAnnotation(XmlElementRef.class) &&
707+
!member.hasAnnotation(XmlElementRefs.class) &&
708+
!member.hasAnnotation(JsonProperty.class)) {
699709
return true;
700710
}
701711
}

modules/swagger-core/src/test/java/io/swagger/jackson/XMLInfoTest.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.swagger.jackson;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnore;
34
import com.fasterxml.jackson.annotation.JsonProperty;
45
import io.swagger.annotations.ApiModel;
56
import io.swagger.converter.ModelConverter;
@@ -14,6 +15,8 @@
1415
import javax.xml.bind.annotation.XmlAccessorType;
1516
import javax.xml.bind.annotation.XmlAttribute;
1617
import javax.xml.bind.annotation.XmlElement;
18+
import javax.xml.bind.annotation.XmlElementRef;
19+
import javax.xml.bind.annotation.XmlElementRefs;
1720
import javax.xml.bind.annotation.XmlElementWrapper;
1821
import javax.xml.bind.annotation.XmlRootElement;
1922
import static org.testng.Assert.assertEquals;
@@ -83,6 +86,12 @@ public void testReadingXmlAccessorTypeNone() throws Exception {
8386
assertNull(impl.getProperties().get("b"));
8487

8588
assertNotNull(impl.getProperties().get("c"));
89+
90+
assertNotNull(impl.getProperties().get("d"));
91+
92+
assertNotNull(impl.getProperties().get("e"));
93+
94+
assertNotNull(impl.getProperties().get("f"));
8695
}
8796

8897
@XmlRootElement(name = "xmlDecoratedBean")
@@ -97,6 +106,15 @@ static class XmlDecoratedBeanXmlAccessorNone {
97106

98107
@XmlAttribute
99108
public String c;
109+
110+
@XmlElementRef
111+
public XmlDecoratedBean d;
112+
113+
@XmlElementRefs(value = {@XmlElementRef})
114+
public List<XmlDecoratedBean> e;
115+
116+
@JsonProperty
117+
public int f;
100118
}
101119

102120
@Test
@@ -114,8 +132,12 @@ public void testReadingXmlAccessorTypePublic() throws Exception {
114132
final Property propertyA = impl.getProperties().get("a");
115133
assertNotNull(propertyA);
116134

117-
Property propertyB = impl.getProperties().get("b");
135+
final Property propertyB = impl.getProperties().get("b");
118136
assertNotNull(propertyB);
137+
138+
final Property propertyC = impl.getProperties().get("c");
139+
assertNull(propertyC);
140+
119141
}
120142

121143
@XmlRootElement(name = "xmlDecoratedBean")
@@ -126,6 +148,9 @@ static class XmlDecoratedBeanXmlAccessorPublic {
126148
public int a;
127149

128150
public String b;
151+
152+
@JsonIgnore
153+
public String c;
129154
}
130155

131156
}

0 commit comments

Comments
 (0)