-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
jackson/src/test/java/eu/mihosoft/vmf/jackson/test/type_formats01/FormatModelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package eu.mihosoft.vmf.jackson.test.type_formats01; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import eu.mihosoft.vmf.jackson.VMFJacksonModule; | ||
import eu.mihosoft.vmf.jackson.VMFJsonSchemaGenerator; | ||
import eu.mihosoft.vmf.jackson.test.simple.Address; | ||
import eu.mihosoft.vmf.jackson.test.simple.Employee; | ||
import eu.mihosoft.vmf.jackson.test.simple.MyModel; | ||
import eu.mihosoft.vmf.jackson.test.simple.Person; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class FormatModelTest { | ||
@org.junit.jupiter.api.Test | ||
void testModel() { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
mapper.registerModule(VMFJacksonModule.newInstance(VMFJacksonModule.RUNTIME_TYPE.EXPERIMENTAL) | ||
.withTypeAlias("pet", Pet.class.getName()) | ||
); | ||
|
||
var writer = mapper.writerWithDefaultPrettyPrinter(); | ||
|
||
// generate schema | ||
VMFJsonSchemaGenerator schemaGenerator = | ||
VMFJsonSchemaGenerator.newInstance(VMFJacksonModule.RUNTIME_TYPE.EXPERIMENTAL) | ||
.withTypeAlias("pet", Pet.class.getName()); | ||
|
||
var schema = schemaGenerator.generateSchemaAsString(FormatModel01.class); | ||
|
||
System.out.println(schema); | ||
|
||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
jackson/src/test/java/eu/mihosoft/vmf/jackson/test/type_formats01/PetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package eu.mihosoft.vmf.jackson.test.type_formats01; | ||
|
||
public enum PetType { | ||
DOG, CAT, BIRD, FISH, UNKNOWN | ||
} |
32 changes: 32 additions & 0 deletions
32
jackson/src/test/vmf/eu/mihosoft/vmf/jackson/test/type_formats01/vmfmodel/FormatModel01.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package eu.mihosoft.vmf.jackson.test.type_formats01.vmfmodel; | ||
|
||
import eu.mihosoft.vmf.core.*; | ||
|
||
@ExternalType(pkgName = "eu.mihosoft.vmf.jackson.test.type_formats01") | ||
interface PetType { | ||
} | ||
|
||
interface FormatModel01 { | ||
@Contains(opposite = "model") | ||
@Annotation(key = "vmf:jackson:schema:format", value = "table") | ||
@Annotation(key = "vmf:jackson:schema:uniqueItems", value = "true") | ||
Pet[] getPets(); | ||
} | ||
|
||
interface Pet { | ||
@DefaultValue("eu.mihosoft.vmf.jackson.test.type_formats01.PetType.UNKNOWN") | ||
PetType getType(); | ||
String getName(); | ||
int getAge(); | ||
@Container(opposite = "pets") | ||
FormatModel01 getModel(); | ||
|
||
@Annotation(key = "vmf:jackson:schema:format", value = "color") | ||
@DefaultValue("\"#ffa500\"") | ||
String getColor(); | ||
|
||
@Annotation(key = "vmf:jackson:schema:inject", value = "\"title\": \"My Title\"") | ||
String getOtherProperty(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters