Package org.apache.juneau.jsonschema
Class JsonSchemaGenerator
java.lang.Object
org.apache.juneau.Context
org.apache.juneau.BeanContextable
org.apache.juneau.BeanTraverseContext
org.apache.juneau.jsonschema.JsonSchemaGenerator
- All Implemented Interfaces:
JsonSchemaMetaProvider
Generates JSON-schema metadata about POJOs.
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Set<TypeCategory>protected final Set<TypeCategory>protected final booleanprotected final booleanprotected final Class<? extends BeanDefMapper>static final JsonSchemaGeneratorDefault serializer, all default settings.protected final JsonParserprotected final JsonSerializerprotected final booleanFields inherited from class org.apache.juneau.BeanContextable
beanContextFields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static JsonSchemaGenerator.Buildercreate()Creates a new builder for this object.Create a session builder based on the properties defined on this context.protected final Set<TypeCategory>Add descriptions to types.protected final Set<TypeCategory>Add examples.protected final BeanDefMapperBean schema definition mapper.Ignore types from schema definitions.Returns the language-specific metadata on the specified bean property.getJsonSchemaClassMeta(ClassMeta<?> cm) Returns the language-specific metadata on the specified class.Returns a session to use for this context.protected final booleanAllow nested descriptions.protected final booleanAllow nested examples.booleanisIgnoredType(ClassMeta<?> cm) Returnstrue if the specified type is ignored.protected final booleanUse bean definitions.Returns the properties on this bean as a map for debugging.Methods inherited from class org.apache.juneau.BeanTraverseContext
getDetectRecursions, getIgnoreRecursions, getInitialDepth, getMaxDepth, isDetectRecursions, isIgnoreRecursionsMethods inherited from class org.apache.juneau.BeanContextable
getBeanContextMethods inherited from class org.apache.juneau.Context
createBuilder, getAnnotationProvider, init, isDebug, toString
-
Field Details
-
DEFAULT
Default serializer, all default settings. -
allowNestedDescriptions
-
allowNestedExamples
-
useBeanDefs
-
beanDefMapper
-
jsonParser
-
jsonSerializer
-
addDescriptionsTo
-
addExamplesTo
-
ignoreTypes
-
-
Constructor Details
-
JsonSchemaGenerator
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
copy
Description copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
- Specified by:
copyin classBeanTraverseContext- Returns:
- A new Builder object.
-
createSession
Description copied from class:ContextCreate a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use
Context.getSession()directly.- Overrides:
createSessionin classContext- Returns:
- A new session builder.
-
getIgnoreTypes
Ignore types from schema definitions.- Returns:
- Custom schema information for particular class types.
Nevernull .
List is unmodifiable. - See Also:
-
getJsonSchemaBeanPropertyMeta
Description copied from interface:JsonSchemaMetaProviderReturns the language-specific metadata on the specified bean property.- Specified by:
getJsonSchemaBeanPropertyMetain interfaceJsonSchemaMetaProvider- Parameters:
bpm- The bean property to return the metadata on.- Returns:
- The metadata.
-
getJsonSchemaClassMeta
Description copied from interface:JsonSchemaMetaProviderReturns the language-specific metadata on the specified class.- Specified by:
getJsonSchemaClassMetain interfaceJsonSchemaMetaProvider- Parameters:
cm- The class to return the metadata on.- Returns:
- The metadata.
-
getSession
Description copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSessionin classContext- Returns:
- A new session object.
-
isIgnoredType
Returnstrue if the specified type is ignored.The type is ignored if it's specified in the
JsonSchemaGenerator.Builder.ignoreTypes(String...)setting.
Ignored types returnnull on the call toJsonSchemaGeneratorSession.getSchema(ClassMeta).- Parameters:
cm- The type to check.- Returns:
true if the specified type is ignored.
-
getAddDescriptionsTo
Add descriptions to types.- Returns:
- Set of categories of types that descriptions should be automatically added to generated schemas.
- See Also:
-
getAddExamplesTo
Add examples.- Returns:
- Set of categories of types that examples should be automatically added to generated schemas.
- See Also:
-
getBeanDefMapper
Bean schema definition mapper.- Returns:
- Interface to use for converting Bean classes to definition IDs and URIs.
- See Also:
-
isAllowNestedDescriptions
Allow nested descriptions.- Returns:
true if nested descriptions are allowed in schema definitions.- See Also:
-
isAllowNestedExamples
Allow nested examples.- Returns:
true if nested examples are allowed in schema definitions.- See Also:
-
isUseBeanDefs
Use bean definitions.- Returns:
true if schemas on beans will be serialized with'$ref' tags.- See Also:
-
properties
Description copied from class:ContextReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classBeanTraverseContext- Returns:
- The properties on this bean as a map for debugging.
-