Skip to content

Configuration

Each generator function takes a config struct that controls its output paths and behavior. All config types are plain Rust structs with public fields — no builder pattern, no defaults you need to worry about.

Used by parse_schema().

FieldTypeDescription
schema_dirPathBufPath to the directory containing your schema .rs files. Typically "src/schema".
SchemaConfig {
schema_dir: "src/schema".into(),
}

All .rs files in this directory are scanned for structs with #[derive(OntologyEntity)]. Subdirectories are not traversed.


Used by gen_seaorm().

FieldTypeDescription
entity_outputPathBufOutput directory for generated SeaORM entity modules. Each entity gets its own file, plus a mod.rs.
conversion_outputPathBufOutput directory for generated from_model() / to_active_model() conversion code.
skip_conversionsVec<String>Entity names to skip when generating conversions. Use this if you write custom conversion logic for specific entities.
SeaOrmConfig {
entity_output: "src/persistence/db/entities/generated".into(),
conversion_output: "src/persistence/db/conversions/generated".into(),
skip_conversions: vec![],
}

Used by gen_markdown_io().

FieldTypeDescription
output_dirPathBufOutput directory for generated parser, writer, and filesystem operation modules.
MarkdownIoConfig {
output_dir: "src/persistence/markdown".into(),
}

Used by gen_dtos().

FieldTypeDescription
output_dirPathBufOutput directory for generated CreateEntityInput and UpdateEntityInput structs.
DtoConfig {
output_dir: "src/schema/dto".into(),
}

Generated DTOs include Deserialize, JsonSchema, and specta::Type derives for use across transport layers.


Used by gen_store().

FieldTypeDescription
output_dirPathBufOutput directory for generated CRUD method modules. Each entity gets its own file.
hooks_dirOption<PathBuf>Directory for scaffolded hook files. When Some, hook files are created once per entity and never overwritten. When None, hook scaffolding is skipped entirely.
schema_module_pathStringRust import path for the schema module in generated code. Use ontogen::DEFAULT_SCHEMA_MODULE_PATH ("crate::schema") for the canonical default.
StoreConfig {
output_dir: "src/store/generated".into(),
hooks_dir: Some("src/store/hooks".into()),
schema_module_path: ontogen::DEFAULT_SCHEMA_MODULE_PATH.into(),
}

When hooks_dir is None, the generated CRUD code still compiles — but it expects your consuming crate to provide hook modules at the expected import paths. This is useful when you want full control over hook file organization.


Used by gen_api().

FieldTypeDescription
output_dirPathBufOutput directory for generated CRUD API modules.
excludeVec<String>Entity names to skip. These entities won’t get generated API modules.
scan_dirsVec<PathBuf>Directories to scan for hand-written API modules. Scanned functions are merged with generated CRUD into a unified ApiOutput. When empty, only generated modules are included.
state_typeStringThe AppState type name. Used when scanning hand-written modules to identify functions that take the global state.
store_typeOption<String>The Store type name. Functions whose first parameter matches this are treated as entity-scoped (they operate on a specific store instance rather than the global state).
schema_module_pathStringRust import path for the schema module in generated code. Use ontogen::DEFAULT_SCHEMA_MODULE_PATH ("crate::schema") for the canonical default.
ApiConfig {
output_dir: "src/api/v1/generated".into(),
exclude: vec![],
scan_dirs: vec!["src/api/v1".into()],
state_type: "AppState".to_string(),
store_type: Some("Store".to_string()),
schema_module_path: ontogen::DEFAULT_SCHEMA_MODULE_PATH.into(),
}

When scan_dirs is non-empty, gen_api parses every .rs file in those directories (excluding generated/ subdirectories) with syn. It extracts:

  • Function name and doc comment
  • Parameter names and types
  • Return type
  • The first parameter type to determine if it’s AppState-scoped or Store-scoped

Scanned functions are classified by their name pattern and parameter shape into OpKind values (List, GetById, Create, Update, Delete, CustomGet, CustomPost, EventStream). This classification drives HTTP verb and route selection in the server transport generators.


Used by gen_servers().

This is the largest config type because it controls multiple transport generators simultaneously.

FieldTypeDescription
api_dirPathBufDirectory to scan for API source files when not using ApiOutput.
state_typeStringThe AppState type name for route handlers (e.g., "AppState").
service_import_pathStringImport path for service modules from the consuming crate (e.g., "crate::api::v1").
types_import_pathStringImport path for schema types (e.g., "crate::schema").
state_importStringImport path for the state type (e.g., "crate::AppState").
namingNamingConfigNaming overrides for pluralization, singularization, and labels.
generatorsVec<ServerGeneratorConfig>Which server generators to run and their output paths.
client_generatorsVec<ClientGenerator>Which client generators to run (TypeScript transports, admin registry).
rustfmt_editionStringRust edition for formatting generated Rust code (e.g., "2021", "2024").
sse_route_overridesHashMap<String, String>Map from event function name to custom SSE route path.
ts_skip_commandsVec<String>IPC command names to skip in TypeScript client generation.
route_prefixOption<RoutePrefix>Optional route prefix for project-scoped routes.
store_typeOption<String>Store type for entity-scoped functions.
store_importOption<String>Import path for the Store type.
paginationOption<PaginationConfig>Pagination support for list operations.
schema_entitiesVec<EntityDef>Parsed schema entities used by the admin-registry client generator to emit per-field UI metadata. Pass schema.entities.clone() from the SchemaOutput returned by parse_schema. Without it, admin-registry.ts ships with empty fields: [] per entity. The Pipeline builder fills this in automatically. Server transports (Axum, Tauri IPC, MCP) and the transport TypeScript clients do not consume it — only the admin-registry generator does.

Controls how entity names are transformed for URLs, labels, and module names. Lives at ontogen::servers::NamingConfig.

FieldTypeDescription
plural_overridesHashMap<String, String>Module name to plural form (e.g., "evidence" to "evidence").
singular_overridesHashMap<String, String>Module name to singular form.
label_overridesHashMap<String, String>Module name to human label (e.g., "work_session" to "Work Session").
plural_label_overridesHashMap<String, String>Module name to human plural label.

Uses cruet for Rails-style inflection by default. Override maps take precedence.

pub enum ServerGenerator {
HttpAxum { output: PathBuf },
TauriIpc { output: PathBuf },
Mcp { output: PathBuf },
}
VariantOutputDescription
HttpAxumRust fileAxum route handlers with entity_routes() router constructor.
TauriIpcRust file#[tauri::command] handlers with State extraction and specta annotations.
McpRust fileMCP tool definitions with JSON Schema parameters.
pub enum ClientGenerator {
HttpTauriIpcSplit { output: PathBuf, bindings_path: PathBuf },
HttpTs { output: PathBuf, bindings_path: PathBuf },
AdminRegistry { output: PathBuf },
}
VariantOutputDescription
HttpTauriIpcSplitTypeScript fileUnified client that uses HTTP in browsers and Tauri IPC in desktop apps.
HttpTsTypeScript fileHTTP-only TypeScript client.
AdminRegistryTypeScript fileEntity metadata for admin UI components.

Optional prefix for project-scoped routes (e.g., /api/projects/:project_id/nodes).

FieldTypeDescription
segmentsStringPath segments to insert (e.g., "projects/:project_id").
state_accessorStringState method for validation (e.g., "store_for" produces state.store_for(&project_id)?).
paramsVec<PrefixParam>Parameters extracted from segments.
FieldTypeDescription
nameStringParameter name (e.g., "project_id").
rust_typeStringRust type (e.g., "uuid::Uuid").
ts_typeStringTypeScript type (e.g., "string").
FieldTypeDescription
default_limitu32Default page size when limit is not specified in the request.
max_limitu32Maximum allowed page size. Requests above this are clamped.

Used by install_admin_layer().

FieldTypeDescription
nuxt_configPathBufPath to the Nuxt app’s nuxt.config.ts.
layer_pathStringRelative path from the nuxt config to the admin layer package.
AdminLayerConfig {
nuxt_config: "../src-nuxt/nuxt.config.ts".into(),
layer_path: "../crates/ontogen/packages/nuxt_admin_layer".to_string(),
}