|
3 | 3 | //! Generates TypeScript type definitions from Rust op definitions |
4 | 4 | //! and JSON Schema for configuration. |
5 | 5 |
|
6 | | -use std::collections::HashMap; |
| 6 | +use std::collections::{BTreeMap, HashMap}; |
7 | 7 | use std::fs; |
8 | 8 | use std::path::Path; |
9 | 9 |
|
@@ -1532,7 +1532,7 @@ fn apply_rename_style(name: &str, style: &str) -> String { |
1532 | 1532 | /// Convert Rust type to JSON Schema type |
1533 | 1533 | fn rust_type_to_json_schema( |
1534 | 1534 | rust_type: &str, |
1535 | | - definitions: &HashMap<String, serde_json::Value>, |
| 1535 | + definitions: &BTreeMap<String, serde_json::Value>, |
1536 | 1536 | ) -> serde_json::Value { |
1537 | 1537 | let rust_type = rust_type.trim(); |
1538 | 1538 |
|
@@ -1618,7 +1618,7 @@ fn rust_type_to_json_schema( |
1618 | 1618 |
|
1619 | 1619 | /// Generate full JSON Schema from extracted structs |
1620 | 1620 | fn generate_json_schema(structs: &[ConfigStructInfo]) -> serde_json::Value { |
1621 | | - let mut definitions: HashMap<String, serde_json::Value> = HashMap::new(); |
| 1621 | + let mut definitions: BTreeMap<String, serde_json::Value> = BTreeMap::new(); |
1622 | 1622 |
|
1623 | 1623 | // First pass: collect all definition names |
1624 | 1624 | let def_names: std::collections::HashSet<String> = |
@@ -1648,12 +1648,12 @@ fn generate_struct_schema( |
1648 | 1648 | struct_info: &ConfigStructInfo, |
1649 | 1649 | def_names: &std::collections::HashSet<String>, |
1650 | 1650 | ) -> serde_json::Value { |
1651 | | - let definitions: HashMap<String, serde_json::Value> = def_names |
| 1651 | + let definitions: BTreeMap<String, serde_json::Value> = def_names |
1652 | 1652 | .iter() |
1653 | 1653 | .map(|name| (name.clone(), serde_json::json!({}))) |
1654 | 1654 | .collect(); |
1655 | 1655 |
|
1656 | | - let mut properties: HashMap<String, serde_json::Value> = HashMap::new(); |
| 1656 | + let mut properties: BTreeMap<String, serde_json::Value> = BTreeMap::new(); |
1657 | 1657 | let mut required: Vec<String> = Vec::new(); |
1658 | 1658 |
|
1659 | 1659 | for field in &struct_info.fields { |
@@ -1687,6 +1687,7 @@ fn generate_struct_schema( |
1687 | 1687 | }); |
1688 | 1688 |
|
1689 | 1689 | if !required.is_empty() { |
| 1690 | + required.sort(); |
1690 | 1691 | schema["required"] = serde_json::json!(required); |
1691 | 1692 | } |
1692 | 1693 |
|
|
0 commit comments