Struct vector_config_common::schema::SchemaGenerator
source · pub struct SchemaGenerator { /* private fields */ }
Expand description
Schema generator.
This is the main entrypoint for storing the defined schemas within a given root schema, and referencing existing schema definitions.
Implementations§
source§impl SchemaGenerator
impl SchemaGenerator
sourcepub fn new(settings: SchemaSettings) -> SchemaGenerator
pub fn new(settings: SchemaSettings) -> SchemaGenerator
Creates a new SchemaGenerator
using the given settings.
sourcepub fn settings(&self) -> &SchemaSettings
pub fn settings(&self) -> &SchemaSettings
Gets the SchemaSettings
being used by this SchemaGenerator
.
sourcepub fn definitions(&self) -> &Map<String, Schema>
pub fn definitions(&self) -> &Map<String, Schema>
Borrows the collection of all referenceable schemas that have been generated.
The keys of the returned Map
are the schema names, and the
values are the schemas themselves.
sourcepub fn definitions_mut(&mut self) -> &mut Map<String, Schema>
pub fn definitions_mut(&mut self) -> &mut Map<String, Schema>
Mutably borrows the collection of all referenceable schemas that have been generated.
The keys of the returned Map
are the schema names, and the
values are the schemas themselves.
sourcepub fn dereference<'a>(&'a self, schema: &Schema) -> Option<&'a Schema>
pub fn dereference<'a>(&'a self, schema: &Schema) -> Option<&'a Schema>
Attempts to find the schema that the given schema
is referencing.
If the given schema
has a $ref
property which refers to another schema in self
’s schema definitions, the referenced
schema will be returned. Otherwise, returns None
.
sourcepub fn into_root_schema(self, root_schema: SchemaObject) -> RootSchema
pub fn into_root_schema(self, root_schema: SchemaObject) -> RootSchema
Converts this generator into a root schema, using the given root_schema
as the top-level
definition.
This assumes the root schema was generated using this generator, such that any schema
definitions referenced by root_schema
refer to this generator.
All other relevant settings (i.e. meta-schema) are carried over.