Skip to content

Commit fa11924

Browse files
committed
Add a (failing) unit test for #4
1 parent 45debbd commit fa11924

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/main/java/com/fasterxml/jackson/module/jsonSchema/factories/ObjectVisitor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,4 @@ protected JsonSerializer<Object> getSer(BeanProperty prop)
116116
}
117117
return ser;
118118
}
119-
120119
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.fasterxml.jackson.module.jsonSchema.failing;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
5+
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;
6+
import com.fasterxml.jackson.module.jsonSchema.SchemaTestBase;
7+
8+
public class TestCyclic extends SchemaTestBase
9+
{
10+
// [Issue#4]
11+
public class Loop {
12+
public String name;
13+
public Loop next;
14+
}
15+
16+
private final ObjectMapper MAPPER = objectMapper();
17+
18+
// [Issue#4]
19+
public void testSimpleCyclic() throws Exception
20+
{
21+
JsonSchemaGenerator generator = new JsonSchemaGenerator(MAPPER);
22+
JsonSchema schema = generator.generateSchema(Loop.class);
23+
24+
String json = MAPPER.writeValueAsString(schema).replace('"', '\'');
25+
String EXP = "{'type':'object','properties':{"
26+
+"'name':{'type':'string'}},'next':{'type':'object'}}}";
27+
// System.err.println("JSON: "+json);
28+
assertEquals(EXP, json);
29+
}
30+
}

src/test/java/com/fasterxml/jackson/module/jsonSchema/failing/TestUnwrapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static class Name {
2727
/**********************************************************
2828
*/
2929

30-
private final ObjectMapper MAPPER = new ObjectMapper();
30+
private final ObjectMapper MAPPER = objectMapper();
3131

3232
public void testUnwrapping() throws Exception
3333
{

0 commit comments

Comments
 (0)