1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// crustrace::omni expands fn signatures
//! # avrotize
//!
//! Convert [JSON Schema](https://json-schema.org/) documents into
//! [Apache Avro](https://avro.apache.org/) schemas.
//!
//! ## Features
//!
//! - Supports `$defs` / `definitions` resolution
//! - Handles composition keywords (`allOf`, `anyOf`, `oneOf`)
//! - Maps primitive JSON Schema types to Avro equivalents
//! - Generates records, enums, arrays, maps, and unions
//! - Resolves and sorts type dependencies
//! - CLI tool `jsonschema2avro` for batch conversion
//!
//! ## Example (Programmatic Usage)
//!
//! ```no_run
//! use serde_json::json;
//! use avrotize::converter::jsons_to_avro;
//!
//! let schema = json!({
//! "$schema": "https://json-schema.org/draft/2020-12/schema",
//! "title": "Example",
//! "type": "object",
//! "properties": {
//! "name": { "type": "string" },
//! "age": { "type": "integer" }
//! },
//! "required": ["name"]
//! });
//!
//! let avro = jsons_to_avro(
//! &schema,
//! "example_ns", // namespace
//! "example_ns.utility", // utility namespace
//! "example.json", // base URI
//! false // don't split top-level
//! );
//!
//! println!("{}", serde_json::to_string_pretty(&avro).unwrap());
//! ```
//!
//! ## Example (CLI)
//!
//! ```bash
//! jsonschema2avro schema.json out.avsc
//! ```
//!
//! Or to split top-level records into separate `.avsc` files:
//!
//! ```bash
//! jsonschema2avro schema.json out_dir --split-top-level-records
//! ```
//!
//! ## Crate Layout
//!
//! - [`avro`] — Core Avro type definitions (`AvroType`, `AvroField`)
//! - [`common`] — Helpers for names, hashing, traversal, etc.
//! - [`converter`] — JSON Schema → Avro conversion logic
//! - [`dependency_resolver`] — Handles dependency ordering and inlining
//!
//! The CLI binary is enabled with the `cli` feature.