java.lang.Object
dev.metaschema.schemagen.AbstractSchemaGenerator<com.fasterxml.jackson.core.JsonGenerator,dev.metaschema.schemagen.json.impl.JsonDatatypeManager,dev.metaschema.schemagen.json.impl.JsonGenerationState>
dev.metaschema.schemagen.json.JsonSchemaGenerator
- All Implemented Interfaces:
ISchemaGenerator
public class JsonSchemaGenerator
extends AbstractSchemaGenerator<com.fasterxml.jackson.core.JsonGenerator,dev.metaschema.schemagen.json.impl.JsonDatatypeManager,dev.metaschema.schemagen.json.impl.JsonGenerationState>
Generates JSON Schema documents from Metaschema modules.
This generator produces JSON Schema draft-07 compatible schemas that can be used to validate JSON and YAML content conforming to the Metaschema model.
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.metaschema.schemagen.ISchemaGenerator
ISchemaGenerator.SchemaFormat -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new JSON schema generator using a default JSON factory.JsonSchemaGenerator(com.fasterxml.jackson.core.JsonFactory jsonFactory) Constructs a new JSON schema generator using the specified JSON factory. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgenerateSchema(dev.metaschema.schemagen.json.impl.JsonGenerationState state) Called to generate the actual schema content.com.fasterxml.jackson.core.JsonFactoryRetrieves the JSON factory used by this generator.protected dev.metaschema.schemagen.json.impl.JsonGenerationStatenewGenerationState(IModule module, com.fasterxml.jackson.core.JsonGenerator schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration) Create a new schema generation state object.protected com.fasterxml.jackson.core.JsonGeneratorCreate a new writer to use to write the schema.Methods inherited from class dev.metaschema.schemagen.AbstractSchemaGenerator
analyzeDefinitions, generateFromModule
-
Constructor Details
-
JsonSchemaGenerator
public JsonSchemaGenerator()Constructs a new JSON schema generator using a default JSON factory. -
JsonSchemaGenerator
public JsonSchemaGenerator(@NonNull com.fasterxml.jackson.core.JsonFactory jsonFactory) Constructs a new JSON schema generator using the specified JSON factory.- Parameters:
jsonFactory- the Jackson JSON factory to use for creating JSON generators
-
-
Method Details
-
getJsonFactory
@NonNull public com.fasterxml.jackson.core.JsonFactory getJsonFactory()Retrieves the JSON factory used by this generator.- Returns:
- the JSON factory instance
-
newWriter
Description copied from class:AbstractSchemaGeneratorCreate a new writer to use to write the schema.The caller owns the returned writer and is responsible for closing it.
- Specified by:
newWriterin classAbstractSchemaGenerator<com.fasterxml.jackson.core.JsonGenerator,dev.metaschema.schemagen.json.impl.JsonDatatypeManager, dev.metaschema.schemagen.json.impl.JsonGenerationState> - Parameters:
out- theWriterto write the schema content to- Returns:
- the schema writer
-
newGenerationState
protected dev.metaschema.schemagen.json.impl.JsonGenerationState newGenerationState(IModule module, com.fasterxml.jackson.core.JsonGenerator schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration) Description copied from class:AbstractSchemaGeneratorCreate a new schema generation state object.- Specified by:
newGenerationStatein classAbstractSchemaGenerator<com.fasterxml.jackson.core.JsonGenerator,dev.metaschema.schemagen.json.impl.JsonDatatypeManager, dev.metaschema.schemagen.json.impl.JsonGenerationState> - Parameters:
module- the Metaschema module to generate the schema forschemaWriter- the writer to use to write the schemaconfiguration- the generation configuration- Returns:
- the schema generation state used for context and writing
-
generateSchema
protected void generateSchema(dev.metaschema.schemagen.json.impl.JsonGenerationState state) Description copied from class:AbstractSchemaGeneratorCalled to generate the actual schema content.- Specified by:
generateSchemain classAbstractSchemaGenerator<com.fasterxml.jackson.core.JsonGenerator,dev.metaschema.schemagen.json.impl.JsonDatatypeManager, dev.metaschema.schemagen.json.impl.JsonGenerationState> - Parameters:
state- the generation state object
-