Macro typify_macro::import_types
source · import_types!() { /* proc-macro */ }Expand description
Import types from a schema file. This may be invoked with simply a pathname
for a JSON Schema file (relative to $CARGO_MANIFEST_DIR), or it may be
invoked with a structured form:
use typify_macro::import_types;
use serde::{Deserialize,Serialize};
import_types!(
schema = "../example.json",
derives = [schemars::JsonSchema],
);-
schema: string literal; the JSON schema file -
derives: optional array of derive macro paths; the derive macros to be applied to all generated types -
struct_builder: optional boolean; (if true) generates a::builder()method for each generated struct that can be used to specify each property and construct the struct -
patch: optional map from type to an object with the optional membersrenameandderives. This may be used to renamed generated types or to apply additional (non-default) derive macros to them. -
replace: optional map from definition name to a replacement type. This may be used to skip generation of the named type and use a existing Rust type. -
convert: optional map from a JSON schema type defined in$defsto a replacement type. This may be used to skip generation of the schema and use an existing Rust type.