Skip to content

Commit

Permalink
Merge 0e3c691 into 2747c02
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe444 committed Aug 5, 2019
2 parents 2747c02 + 0e3c691 commit e3f3089
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator;
import com.fasterxml.jackson.module.jsonSchema.customProperties.ValidationSchemaFactoryWrapper;
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import com.fasterxml.jackson.module.jsonSchema.factories.VisitorContext;
import com.google.common.collect.Lists;
Expand All @@ -30,7 +31,7 @@ public VauntSerializer() {
mapper.registerModule(new GuavaModule());
mapper.registerModule(new JavaTimeModule());

wrapper = new SchemaFactoryWrapper();
wrapper = new ValidationSchemaFactoryWrapper();
generator = new JsonSchemaGenerator(mapper, wrapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import groovy.json.JsonSlurper
import spock.lang.Specification
import spock.lang.Subject

import javax.validation.constraints.Size
import java.time.ZonedDateTime

class VauntSerializerSpec extends Specification {
Expand Down Expand Up @@ -64,7 +65,7 @@ class VauntSerializerSpec extends Specification {
def schema() {
def schema = new ObjectSchema()
schema.setId(Message.getSimpleName())
schema.putOptionalProperty("string", new StringSchema())
schema.putOptionalProperty("string", stringPart())
schema.putOptionalProperty("zonedDateTime", new NumberSchema())
schema.putOptionalProperty("mapped", mappedPart())
schema.putOptionalProperty("listed", listedPart())
Expand All @@ -73,6 +74,13 @@ class VauntSerializerSpec extends Specification {
return schema
}
def stringPart() {
def schema = new StringSchema()
schema.setMinLength(1)
schema.setMaxLength(3)
return schema
}
def subinnerPart() {
def schema = new ObjectSchema()
schema.setId(InnerMessage.class.getSimpleName())
Expand Down Expand Up @@ -156,7 +164,9 @@ class VauntSerializerSpec extends Specification {
"id":"Message",
"properties":{
"string":{
"type":"string"
"type":"string",
"maxLength":3,
"minLength":1
},
"zonedDateTime":{
"type":"number"
Expand Down Expand Up @@ -278,6 +288,7 @@ class VauntSerializerSpec extends Specification {
}
class Message {
@Size(min = 1, max = 3)
String string
ZonedDateTime zonedDateTime
Multimap<String, Contract> mapped
Expand Down

0 comments on commit e3f3089

Please sign in to comment.