public interface MongoJsonSchema
builder(), for
example:
MongoJsonSchema schema = MongoJsonSchema.builder().required("firstname", "lastname")
.properties(string("firstname").possibleValues("luke", "han"),
object("address").properties(string("postCode").minLength(4).maxLength(5))
).build();
resulting in the following schema:
{
"type": "object",
"required": [ "firstname", "lastname" ],
"properties": {
"firstname": {
"type": "string", "enum": [ "luke", "han" ],
},
"address": {
"type": "object",
"properties": {
"postCode": { "type": "string", "minLength": 4, "maxLength": 5 }
}
}
}
}
UntypedJsonSchemaObject,
TypedJsonSchemaObject| Modifier and Type | Interface and Description |
|---|---|
static class |
MongoJsonSchema.MongoJsonSchemaBuilder
MongoJsonSchema.MongoJsonSchemaBuilder provides a fluent API for defining a MongoJsonSchema. |
| Modifier and Type | Method and Description |
|---|---|
static MongoJsonSchema.MongoJsonSchemaBuilder |
builder()
Obtain a new
MongoJsonSchema.MongoJsonSchemaBuilder to fluently define the schema. |
static MongoJsonSchema |
of(org.bson.Document document)
Create a new
MongoJsonSchema for a given root Document containing the schema definition. |
static MongoJsonSchema |
of(JsonSchemaObject root)
Create a new
MongoJsonSchema for a given root object. |
org.bson.Document |
toDocument()
Create the
Document containing the specified $jsonSchema. |
org.bson.Document toDocument()
Document containing the specified $jsonSchema. Document through a
JsonSchemaMapper to apply field name customization.static MongoJsonSchema of(JsonSchemaObject root)
MongoJsonSchema for a given root object.root - must not be null.static MongoJsonSchema of(org.bson.Document document)
MongoJsonSchema for a given root Document containing the schema definition.document - must not be null.static MongoJsonSchema.MongoJsonSchemaBuilder builder()
MongoJsonSchema.MongoJsonSchemaBuilder to fluently define the schema.MongoJsonSchema.MongoJsonSchemaBuilder.Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.