mirror of
https://github.com/openai/codex.git
synced 2026-11-13 22:47:20 +00:00
Sort JSON schema object keys for consistent Cargo and Bazel output (#43325)
## Why JSON schema exports should be identical across Cargo and Bazel builds. ## What changed Recursively sort object keys before writing app-server protocol JSON schemas, while preserving array order. GitOrigin-RevId: 740c846062f7bae18790e9cf4f30734289ae3056
This commit is contained in:
1 parent
02d4529f55
commit
112be0bd74
1 file changed
+5
-3
@@ -25,7 +25,6 @@ use anyhow::Result;
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use codex_history::RolloutLine;
|
use codex_history::RolloutLine;
|
||||||
use schemars::schema_for;
|
use schemars::schema_for;
|
||||||
use serde::Serialize;
|
|
||||||
use serde_json::Map;
|
use serde_json::Map;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
@@ -1571,8 +1570,11 @@ where
|
|||||||
write_json_schema_with_return::<T>(out_dir, name)
|
write_json_schema_with_return::<T>(out_dir, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_pretty_json(path: PathBuf, value: &impl Serialize) -> Result<()> {
|
fn write_pretty_json(path: PathBuf, value: &Value) -> Result<()> {
|
||||||
let json = serde_json::to_vec_pretty(value)
|
let mut value = value.clone();
|
||||||
|
// Keep Cargo and Bazel output identical without changing meaningful array order.
|
||||||
|
value.sort_all_objects();
|
||||||
|
let json = serde_json::to_vec_pretty(&value)
|
||||||
.with_context(|| format!("Failed to serialize JSON schema to {}", path.display()))?;
|
.with_context(|| format!("Failed to serialize JSON schema to {}", path.display()))?;
|
||||||
fs::write(&path, json).with_context(|| format!("Failed to write {}", path.display()))?;
|
fs::write(&path, json).with_context(|| format!("Failed to write {}", path.display()))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in new issue
Block a user