replace_subschema

Function replace_subschema 

Source
pub fn replace_subschema<T: JsonSchema>(
    generator: &mut SchemaGenerator,
    schema: impl Fn() -> Schema,
) -> Schema
Expand description

Replaces the JSON schema definition for some type if it is in use (in the definitions list), and returns a reference to it.

This asserts that JsonSchema::schema_name() + “2” does not exist because this indicates that there are multiple types that use this name, and unfortunately schemars APIs do not support resolving this ambiguity - see https://github.com/GREsau/schemars/issues/449

This takes a closure for schema because some settings types are not available on the remote server, and so will crash when attempting to access e.g. GlobalThemeRegistry.