Schemars

Generate JSON Schema documents directly from Rust types

Library
Cargo
v1.2.2
1,415 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
63 /100 Good
Development Activity 32
Maintenance 52
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 82
Code Quality 85
Innovation 75
Learning Curve 80

Schemars derives JSON Schema documents from Rust structs and enums with a single #[derive(JsonSchema)] macro, reusing the same field attributes (rename, skip, default) that serde already understands so your schema and your serialization stay in sync automatically. It ships JsonSchema implementations for most of the standard library plus popular crates (chrono, uuid, bytes, indexmap, rust_decimal) behind feature flags.

Because the generated schema is built from actual Rust type definitions rather than hand-written separately, Schemars is commonly used to produce OpenAPI-compatible schemas, validate config files, or describe tool/function-call interfaces for LLM integrations without maintaining a second schema definition by hand.

What You Get

  • A #[derive(JsonSchema)] macro plus schema_for!/schema_for_value! macros for one-line schema generation
  • Automatic reuse of serde attributes (rename, skip_serializing_if, default) so schema and serialization never drift
  • Built-in JsonSchema implementations for most std types and, via feature flags, chrono, uuid, bytes, indexmap, rust_decimal, and more
  • A Generator/SchemaSettings API for customizing schema draft version, $ref strategy, and inline-vs-referenced definitions
  • no_std-compatible core so it can run in embedded or constrained environments

Common Use Cases

  • Generating OpenAPI-compatible request/response schemas for a Rust web API (Axum, Actix, Rocket) alongside existing serde models
  • Producing JSON Schema tool/function definitions for LLM function-calling from native Rust structs
  • Validating configuration files against a schema derived straight from the config struct definition
  • Publishing a public JSON Schema for a data format defined by a Rust type, without maintaining it by hand

Under The Hood

Architecture: schemars/src/lib.rs defines the JsonSchema trait and re-exports the derive macro from the sibling schemars_derive proc-macro crate; generate.rs and schema.rs implement the actual schema-building logic and settings (draft version, $ref inlining), while json_schema_impls/ provides JsonSchema implementations for every supported type, gated behind per-crate feature flags (chrono04, uuid1, indexmap2, etc.) so consumers only compile in what they use.

Tech Stack: Pure Rust, no_std-compatible core (categories = ["encoding", "no-std"] in Cargo.toml) built on serde/serde_json plus small utility crates (dyn-clone, ref-cast); optional integrations use versioned feature-flag naming (e.g. chrono04, bigdecimal04) to support multiple major versions of dependent crates simultaneously.

Code Quality: The schemars crate ships 61+ integration/unit test files covering type-by-type schema output (including snapshot-style expected-JSON comparisons and an update-tests.sh regeneration script), reflecting the project’s need for byte-stable schema output across releases; clippy.toml enforces lint discipline project-wide.

API Design: The primary entry point is a single derive macro plus one macro call (schema_for!(MyType)), so most users never touch the Generator/SchemaSettings customization API at all — advanced schema-shape control (draft version, $ref policy) is opt-in rather than required, keeping the common case a two-line change to an existing serde-derived struct.

Used by 11 apps in this directory

Dart
74%
AGPL 3.0

AppFlowy

AI Assistants · Collaboration · Productivity

76,967

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
67
Dependency
Built with
Dart 74%
Rust 24%
Updated 1 weeks ago
Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust 86%
Updated 1 weeks ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
Rust
80%
MIT

fabro

Developer Tools · Devops

1,658

Define AI agent workflows as code graphs, route tasks across any LLM, and intervene only where it matters.

View details
82
Repo Health
83
Technical
67
Dependency
Built with
Rust 80%
TypeScript 15%
Updated 5 days ago
Rust
94%
Apache 2.0

herdr

AI Agents · Developer Tools

41,057

A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.

View details
84
Repo Health
84
Technical
72
Dependency
Built with
Rust 94%
Updated 5 days ago
Rust
73%
Other

iii

Developer Tools · Devops

18,814

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 73%
TypeScript 16%
Updated 5 days ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 5 days ago
Rust
71%
Apache 2.0

mesh-llm

AI Agents · AI Development

3,463

Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.

View details
84
Repo Health
91
Technical
69
Dependency
Built with
Rust 71%
TypeScript 13%
Python 10%
Updated 4 days ago
TypeScript
64%
AGPL 3.0

Silex

Design Tools · No Code Platforms

2,986

Free, open-source visual website builder that exports clean HTML/CSS — no lock-in, no subscription, host anywhere

View details
89
Repo Health
68
Technical
67
Dependency
Built with
TypeScript 64%
Rust 15%
JavaScript 11%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers