Skip to content

Commit 03462da

Browse files
authored
Merge pull request swagger-api#1935 from HugoMario/master
swagger-api#1595 added test to verify issue
2 parents 33a8aba + 9fe0b58 commit 03462da

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import static org.testng.Assert.fail;
55
import static org.testng.Assert.assertEquals;
66

7+
import com.fasterxml.jackson.annotation.JsonCreator;
8+
import com.fasterxml.jackson.annotation.JsonIgnore;
79
import com.fasterxml.jackson.annotation.JsonProperty;
810
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
911
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -107,6 +109,14 @@ public void testIntArray() throws Exception {
107109
assertEquals(prop.getType(), "array");
108110
}
109111

112+
@Test
113+
public void testComplex() throws Exception {
114+
final Model model = context.resolve(ComplexBean.class);
115+
assertNotNull(model);
116+
final Map<String, Property> props = model.getProperties();
117+
assertEquals(props.size(), 6);
118+
}
119+
110120
/*
111121
/**********************************************************
112122
/* Test methods
@@ -170,4 +180,48 @@ static class StringDateMapBean {
170180
static class IntArrayBean {
171181
public int[] b;
172182
}
183+
184+
185+
static class ComplexBean {
186+
public String j;
187+
@JsonIgnore
188+
public SimpleBean simpleBean;
189+
190+
@JsonCreator
191+
public ComplexBean(@JsonProperty("b") int b,
192+
@JsonProperty("c") long c, @JsonProperty("d") float d, @JsonProperty("e") double e,
193+
@JsonProperty("j") String j) {
194+
simpleBean = new SimpleBean();
195+
simpleBean.b = b;
196+
simpleBean.c = c;
197+
simpleBean.d = d;
198+
simpleBean.e = e;
199+
this.j = j;
200+
}
201+
202+
public SimpleBean getSimpleBean() {
203+
return simpleBean;
204+
}
205+
206+
public String getA() {
207+
return simpleBean.getA();
208+
}
209+
public int getB() {
210+
return simpleBean.b;
211+
}
212+
public long getC() {
213+
return simpleBean.c;
214+
}
215+
public float getD() {
216+
return simpleBean.d;
217+
}
218+
public double getE() {
219+
return simpleBean.e;
220+
}
221+
public String getJ() {
222+
return j;
223+
}
224+
}
225+
226+
173227
}

0 commit comments

Comments
 (0)