jsonschema_schema/extensions/tombi.rs
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4/// [Tombi] JSON Schema extensions (`x-tombi-*`).
5///
6/// Tombi is a TOML language server and formatter. Unlike
7/// [`TaploSchemaExt`](super::TaploSchemaExt) (a single nested object
8/// under `x-taplo`), Tombi extensions are separate top-level keys on the
9/// schema object. This struct is
10/// [`#[serde(flatten)]`](https://serde.rs/attr-flatten.html)-ed into
11/// [`Schema`](crate::Schema).
12///
13/// # Keys
14///
15/// | JSON key | Rust field | Purpose |
16/// |---|---|---|
17/// | `x-tombi-toml-version` | [`toml_version`](Self::toml_version) | Required TOML spec version |
18/// | `x-tombi-table-keys-order` | [`table_keys_order`](Self::table_keys_order) | Preferred key ordering |
19/// | `x-tombi-additional-key-label` | [`additional_key_label`](Self::additional_key_label) | Label for `additionalProperties` keys |
20/// | `x-tombi-array-values-order` | [`array_values_order`](Self::array_values_order) | Preferred array element ordering |
21///
22/// [Tombi]: https://github.com/tombi-toml/tombi
23#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
24pub struct TombiSchemaExt {
25 /// TOML specification version required by this schema (e.g. `"1.0.0"`).
26 #[serde(
27 rename = "x-tombi-toml-version",
28 skip_serializing_if = "Option::is_none"
29 )]
30 pub toml_version: Option<String>,
31
32 /// Preferred ordering of table keys for formatting.
33 ///
34 /// The value is tool-defined and typically an array of key names or an
35 /// ordering strategy object.
36 #[serde(
37 rename = "x-tombi-table-keys-order",
38 skip_serializing_if = "Option::is_none"
39 )]
40 pub table_keys_order: Option<Value>,
41
42 /// Display label for keys matched by `additionalProperties`.
43 #[serde(
44 rename = "x-tombi-additional-key-label",
45 skip_serializing_if = "Option::is_none"
46 )]
47 pub additional_key_label: Option<String>,
48
49 /// Preferred ordering of array element values for formatting.
50 ///
51 /// The value is tool-defined and typically an array of values or an
52 /// ordering strategy object.
53 #[serde(
54 rename = "x-tombi-array-values-order",
55 skip_serializing_if = "Option::is_none"
56 )]
57 pub array_values_order: Option<Value>,
58}