Interface MongoJsonSchemaCreator
public interface MongoJsonSchemaCreator
MongoJsonSchemaCreator
extracts the MongoJsonSchema
for a given Class
by applying the
following mapping rules.
Required Properties
- Properties of primitive type
- All properties annotated with
Transient
Object
->type : 'object'
Arrays
->type : 'array'
Collection
->type : 'array'
Map
->type : 'object'
Enum
->type : 'string', enum : [the enum values]
- Simple Types ->
type : 'the corresponding bson type'
- Domain Types ->
type : 'object', properties : {the types properties}
_id
properties using types that can be converted into
ObjectId
like String
will be mapped to type : 'object'
unless there is more
specific information available via the MongoId
annotation.
Encrypted
properties will contain encrypt information.- Since:
- 2.2
- Author:
- Christoph Strobl
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
The context in which a specificMongoJsonSchemaCreator.JsonSchemaPropertyContext.getProperty()
is encountered during schema creation.static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic MongoJsonSchemaCreator
create()
Creates a newMongoJsonSchemaCreator
that does not consider potential extensions - suitable for testing.static MongoJsonSchemaCreator
create
(MappingContext mappingContext) Creates a newMongoJsonSchemaCreator
that is aware of type mappings and potentialextensions
.static MongoJsonSchemaCreator
create
(MongoConverter mongoConverter) Creates a newMongoJsonSchemaCreator
that is aware of conversions applied by the givenMongoConverter
.createSchemaFor
(Class<?> type) Create theMongoJsonSchema
for the giventype
.A filterPredicate
that matchesencrypted properties
and those having nested ones.Filter matchingproperties
.default MongoJsonSchema
mergedSchemaFor
(Class<?>... types) Create a mergedMongoJsonSchema
out of the individual schemas of the given types by merging their properties into one largeschema
.Entry point to specify additional behavior for a given path.
-
Method Details
-
createSchemaFor
Create theMongoJsonSchema
for the giventype
.- Parameters:
type
- must not be null.- Returns:
- never null.
-
mergedSchemaFor
Create a mergedMongoJsonSchema
out of the individual schemas of the given types by merging their properties into one largeschema
.- Parameters:
types
- must not be null nor contain null.- Returns:
- new instance of
MongoJsonSchema
. - Since:
- 3.4
-
filter
Filter matchingproperties
.- Parameters:
filter
- thePredicate
to evaluate for inclusion. Must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator
. - Since:
- 3.3
-
property
Entry point to specify additional behavior for a given path.- Parameters:
path
- the path using dot '.' notation.- Returns:
- new instance of
MongoJsonSchemaCreator.PropertySpecifier
. - Since:
- 3.4
-
encryptedOnly
A filterPredicate
that matchesencrypted properties
and those having nested ones.- Returns:
- new instance of
Predicate
. - Since:
- 3.3
-
create
Creates a newMongoJsonSchemaCreator
that is aware of conversions applied by the givenMongoConverter
.- Parameters:
mongoConverter
- must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator
.
-
create
Creates a newMongoJsonSchemaCreator
that is aware of type mappings and potentialextensions
.- Parameters:
mappingContext
- must not be null.- Returns:
- new instance of
MongoJsonSchemaCreator
. - Since:
- 3.3
-
create
Creates a newMongoJsonSchemaCreator
that does not consider potential extensions - suitable for testing. We recommend to usecreate(MappingContext)
.- Returns:
- new instance of
MongoJsonSchemaCreator
. - Since:
- 3.3
-