Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;

Expand All @@ -34,6 +36,7 @@

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down Expand Up @@ -691,11 +694,18 @@ protected boolean ignore(final Annotated member, final XmlAccessorType xmlAccess
if (propertiesToIgnore.contains(propName)) {
return true;
}
if (member.hasAnnotation(JsonIgnore.class)) {
return true;
}
if (xmlAccessorTypeAnnotation == null) {
return false;
}
if (xmlAccessorTypeAnnotation.value().equals(XmlAccessType.NONE)) {
if (!member.hasAnnotation(XmlElement.class) && !member.hasAnnotation(XmlAttribute.class)) {
if (!member.hasAnnotation(XmlElement.class) &&
!member.hasAnnotation(XmlAttribute.class) &&
!member.hasAnnotation(XmlElementRef.class) &&
!member.hasAnnotation(XmlElementRefs.class) &&
!member.hasAnnotation(JsonProperty.class)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.jackson;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.converter.ModelConverter;
Expand All @@ -14,6 +15,8 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import static org.testng.Assert.assertEquals;
Expand Down Expand Up @@ -83,6 +86,12 @@ public void testReadingXmlAccessorTypeNone() throws Exception {
assertNull(impl.getProperties().get("b"));

assertNotNull(impl.getProperties().get("c"));

assertNotNull(impl.getProperties().get("d"));

assertNotNull(impl.getProperties().get("e"));

assertNotNull(impl.getProperties().get("f"));
}

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

@XmlAttribute
public String c;

@XmlElementRef
public XmlDecoratedBean d;

@XmlElementRefs(value = {@XmlElementRef})
public List<XmlDecoratedBean> e;

@JsonProperty
public int f;
}

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

Property propertyB = impl.getProperties().get("b");
final Property propertyB = impl.getProperties().get("b");
assertNotNull(propertyB);

final Property propertyC = impl.getProperties().get("c");
assertNull(propertyC);

}

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

public String b;

@JsonIgnore
public String c;
}

}