Skip to content

Commit 3973d9f

Browse files
author
cguillemot
committed
fix 1847-XmlAttribute are not parsed when XmlAccessType.NONE
1 parent fcc8556 commit 3973d9f

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import javax.validation.constraints.Size;
5555
import javax.xml.bind.annotation.XmlAccessType;
5656
import javax.xml.bind.annotation.XmlAccessorType;
57+
import javax.xml.bind.annotation.XmlAttribute;
5758
import javax.xml.bind.annotation.XmlElement;
5859
import javax.xml.bind.annotation.XmlRootElement;
5960
import javax.xml.bind.annotation.XmlSchema;
@@ -617,7 +618,7 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess
617618
return false;
618619
}
619620
if (xmlAccessorTypeAnnotation.value().equals(XmlAccessType.NONE)) {
620-
if (!member.hasAnnotation(XmlElement.class)) {
621+
if (!member.hasAnnotation(XmlElement.class) && !member.hasAnnotation(XmlAttribute.class)) {
621622
return true;
622623
}
623624
}

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.List;
1313
import javax.xml.bind.annotation.XmlAccessType;
1414
import javax.xml.bind.annotation.XmlAccessorType;
15+
import javax.xml.bind.annotation.XmlAttribute;
1516
import javax.xml.bind.annotation.XmlElement;
1617
import javax.xml.bind.annotation.XmlElementWrapper;
1718
import javax.xml.bind.annotation.XmlRootElement;
@@ -77,10 +78,25 @@ public void testReadingXmlAccessorTypeNone() throws Exception {
7778
assertNotNull(xml);
7879
assertEquals(xml.getName(), "xmlDecoratedBean");
7980

80-
final Property property = impl.getProperties().get("a");
81-
assertNotNull(property);
81+
assertNotNull(impl.getProperties().get("a"));
8282

8383
assertNull(impl.getProperties().get("b"));
84+
85+
assertNotNull(impl.getProperties().get("c"));
86+
}
87+
88+
@XmlRootElement(name = "xmlDecoratedBean")
89+
@XmlAccessorType(XmlAccessType.NONE)
90+
@ApiModel
91+
static class XmlDecoratedBeanXmlAccessorNone {
92+
93+
@XmlElement
94+
public int a;
95+
96+
public String b;
97+
98+
@XmlAttribute
99+
public String c;
84100
}
85101

86102
@Test
@@ -102,17 +118,6 @@ public void testReadingXmlAccessorTypePublic() throws Exception {
102118
assertNotNull(propertyB);
103119
}
104120

105-
@XmlRootElement(name = "xmlDecoratedBean")
106-
@XmlAccessorType(XmlAccessType.NONE)
107-
@ApiModel
108-
static class XmlDecoratedBeanXmlAccessorNone {
109-
110-
@XmlElement
111-
public int a;
112-
113-
public String b;
114-
}
115-
116121
@XmlRootElement(name = "xmlDecoratedBean")
117122
@ApiModel
118123
static class XmlDecoratedBeanXmlAccessorPublic {

0 commit comments

Comments
 (0)