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 @@ -404,8 +404,8 @@ public void setAllowEmptyValue(Boolean allowEmptyValue) {

@JsonProperty("x-example")
public Object getExample() {
if (example == null) {
return null;
if (example == null || example.isEmpty()) {
return example;
}
try {
if (BaseIntegerProperty.TYPE.equals(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.models.properties.BaseIntegerProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DecimalProperty;
import io.swagger.models.properties.LongProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.StringProperty;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -335,6 +336,26 @@ public void testGetExampleWithDecimalProperty() {
"The example value must not change when when set an array property");
}

@Test
public void testGetExampleWithEmptyString() {
// given
instance.setProperty(new LongProperty());
example = null;

// when
instance.setExample(example);

// then
assertEquals(instance.getExample(), null, "The example must be null if the value is null");

// given
instance.setProperty(new LongProperty());
example = "";

// then
assertEquals(instance.getExample(), null, "The example must be empty string if the value is an empty string");
}

@Test
public void testGetExampleWithBooleanProperty() {
// given
Expand Down