apcore-toolkit
Rust toolkit for building APCore framework integrations. Scan web framework endpoints (Axum, Actix, Rocket, etc.), extract JSON Schemas, infer behavioral annotations, and output APCore-compatible module definitions — as YAML binding files, direct registry entries, or HTTP proxy modules.
If you're building an APCore adapter for a Rust web framework, this crate provides all the shared infrastructure so you only need to write the framework-specific scanning logic.
Installation
[]
= { = "https://github.com/aipartnerup/apcore-toolkit-rust" }
# Optional: HTTP proxy writer
= { = "https://github.com/aipartnerup/apcore-toolkit-rust", = ["http-proxy"] }
Core Modules
| Module | Description |
|---|---|
ScannedModule |
Canonical struct representing a scanned endpoint |
Scanner |
Async trait for framework scanners, generic over App type (e.g., Scanner<axum::Router>) |
filter_modules |
Regex-based include/exclude filtering for scanned modules |
deduplicate_ids |
Resolves duplicate module IDs by appending _2, _3, etc. |
infer_annotations_from_method |
Maps HTTP methods to behavioral ModuleAnnotations |
YAMLWriter |
Generates .binding.yaml files for apcore::BindingLoader |
RegistryWriter |
Registers modules directly into an apcore::Registry with pluggable HandlerFactory |
HTTPProxyRegistryWriter |
Registers HTTP proxy modules that forward requests to a running API (feature: http-proxy) |
Enhancer |
Pluggable trait for metadata enhancement |
AIEnhancer |
SLM-based metadata enhancement for scanned modules |
WriteResult |
Structured result type for all writer operations |
WriteError |
Typed error (via thiserror) for I/O failures during write |
Verifier |
Pluggable trait for validating written artifacts |
VerifyResult |
Result type for verification operations |
YAMLVerifier |
Verifies YAML files parse correctly with required fields |
RegistryVerifier |
Verifies modules are registered and retrievable |
MagicBytesVerifier |
Verifies file headers match expected magic bytes |
JSONVerifier |
Verifies JSON files parse correctly |
to_markdown |
Converts JSON objects to Markdown with depth control and table heuristics |
enrich_schema_descriptions |
Merges descriptions into JSON Schema properties |
get_writer |
Factory function mapping format strings to OutputFormat variants |
Usage
Scanning and Writing
use async_trait;
use ;
use json;
;
async
Framework-Specific Scanner (Axum Example)
use ;
use async_trait;
;
Direct Registry Registration
use Registry;
use RegistryWriter;
let mut registry = new;
let writer = new;
writer.write;
Registry with Custom Handler Factory
use Arc;
use ;
let factory: HandlerFactory = new;
let writer = with_handler_factory;
writer.write;
Output Format Factory
use ;
let format = get_writer; // Some(OutputFormat::Yaml)
let format = get_writer; // Some(OutputFormat::Registry)
let format = get_writer; // Some(OutputFormat::HttpProxy)
OpenAPI Schema Extraction
use ;
let input_schema = extract_input_schema;
let output_schema = extract_output_schema;
Schema Enrichment
use HashMap;
use enrich_schema_descriptions;
let mut descs = new;
descs.insert;
let enriched = enrich_schema_descriptions;
Markdown Formatting
use ;
use json;
let data = json!;
let opts = MarkdownOptions ;
let md = to_markdown.unwrap;
Requirements
- Rust edition 2021
- apcore >= 0.13.0
- See
Cargo.tomlfor full dependency list
Features
| Feature | Description |
|---|---|
http-proxy |
Enables HTTPProxyRegistryWriter (adds reqwest dependency) |
Documentation
Full documentation is available at https://github.com/aipartnerup/apcore-toolkit.
License
Apache-2.0