Class ChenileJsonSchemaGenerator
java.lang.Object
org.chenile.core.schema.ChenileJsonSchemaGenerator
Generates the JSON Schema (Draft 2020-12, the dialect of OpenAPI 3.1) of a Java type. It is the one schema
generator for Chenile's published contracts, so MCP tools, OpenAPI and the service registry describe a type the
same way.
The schema follows Jackson's view of the type (property names, @JsonProperty(required = true)) and
carries no $schema keyword, because it is usually embedded in a larger document. Referenced types are
placed under $defs, keyed by their simple class names.
For documents with shared schemas (OpenAPI, the service registry), generateReference(Type, ObjectNode) and
withComponents(ObjectNode, ObjectNode) move definitions into a components map and point references at
#/components/schemas/, so every contract names and shares types the same way.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodeThe JSON Schema of a type, which may be generic (for exampleList<Order>).tools.jackson.databind.node.ObjectNodegenerateReference(Type type, tools.jackson.databind.node.ObjectNode components) The schema of a type for a document with shared components.private voidrewriteChildReferences(tools.jackson.databind.JsonNode node) private tools.jackson.databind.node.ObjectNoderewriteReferences(tools.jackson.databind.node.ObjectNode node) tools.jackson.databind.node.ObjectNodewithComponents(tools.jackson.databind.node.ObjectNode schema, tools.jackson.databind.node.ObjectNode components) Moves a schema's$defsinto components and points its references (and theirs) at#/components/schemas/.
-
Field Details
-
COMPONENTS_REF
Where shared schemas live in an OpenAPI-style document.- See Also:
-
DEFS_REF
- See Also:
-
generator
private final com.github.victools.jsonschema.generator.SchemaGenerator generator
-
-
Constructor Details
-
ChenileJsonSchemaGenerator
public ChenileJsonSchemaGenerator()
-
-
Method Details
-
generate
The JSON Schema of a type, which may be generic (for exampleList<Order>). -
generateReference
public tools.jackson.databind.node.ObjectNode generateReference(Type type, tools.jackson.databind.node.ObjectNode components) The schema of a type for a document with shared components. Referenced types go into components; a named object type goes there too, under its simple class name, and a$refto it is returned. Other types (scalars, collections, generics) are returned inline.- Parameters:
components- the document's components (name to schema); added to
-
withComponents
public tools.jackson.databind.node.ObjectNode withComponents(tools.jackson.databind.node.ObjectNode schema, tools.jackson.databind.node.ObjectNode components) Moves a schema's$defsinto components and points its references (and theirs) at#/components/schemas/. Changes and returns the given schema. -
rewriteReferences
private tools.jackson.databind.node.ObjectNode rewriteReferences(tools.jackson.databind.node.ObjectNode node) -
rewriteChildReferences
private void rewriteChildReferences(tools.jackson.databind.JsonNode node)
-
CHENILE