Skip to main content

json_schema_rs/
schema.rs

1use serde::Deserialize;
2use std::collections::BTreeMap;
3
4/// Root or nested JSON Schema object.
5///
6/// Only the schema fields used by the generator are modeled.
7/// Extra keys in the JSON are ignored via serde's default behavior.
8/// Uses `BTreeMap` for deterministic property ordering (alphabetical by key).
9#[derive(Debug, Deserialize)]
10pub struct JsonSchema {
11    #[serde(default)]
12    pub title: Option<String>,
13
14    #[serde(default)]
15    pub r#type: Option<String>,
16
17    #[serde(default)]
18    pub properties: Option<BTreeMap<String, Box<JsonSchema>>>,
19
20    #[serde(default)]
21    pub required: Option<Vec<String>>,
22
23    #[serde(default)]
24    pub r#enum: Option<Vec<serde_json::Value>>,
25}