Skip to content

Commit 45000b5

Browse files
authored
Merge pull request #2409 from clovis-guillemot/bugfix/1847-xmlattribute-not-parsed
fix 1847-XmlAttribute are not parsed when XmlAccessType.NONE
2 parents e16bff5 + a71aefa commit 45000b5

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
@@ -22,6 +22,7 @@
2222
import javax.validation.constraints.Size;
2323
import javax.xml.bind.annotation.XmlAccessType;
2424
import javax.xml.bind.annotation.XmlAccessorType;
25+
import javax.xml.bind.annotation.XmlAttribute;
2526
import javax.xml.bind.annotation.XmlElement;
2627
import javax.xml.bind.annotation.XmlRootElement;
2728
import javax.xml.bind.annotation.XmlSchema;
@@ -627,7 +628,7 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess
627628
return false;
628629
}
629630
if (xmlAccessorTypeAnnotation.value().equals(XmlAccessType.NONE)) {
630-
if (!member.hasAnnotation(XmlElement.class)) {
631+
if (!member.hasAnnotation(XmlElement.class) && !member.hasAnnotation(XmlAttribute.class)) {
631632
return true;
632633
}
633634
}

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)