Files
codex/codex-rs/app-server-protocol/src/protocol/serde_helpers.rs
T
Michael Bolin acd540f158 Precompute app-server protocol exports (#36212)
## Why

Normal app-server protocol builds do not need the `ts-rs` and `schemars`
implementations used to generate schema exports.

## What changed

- Embed compressed stable and experimental TypeScript and JSON schema exports,
  and serve the existing export APIs from those artifacts.
- Use no-op schema derives in non-test builds while keeping the real generators
  available for fixture regeneration and tests.
- Move schema fixture regeneration behind a Python helper and update
  `just write-app-server-schema --experimental` to refresh the experimental
  embedded exports.

## Testing

- Verify embedded exports match freshly generated stable and experimental
  schemas.
- Verify export options and on-disk output remain compatible.

GitOrigin-RevId: e8536338b457e6eec34bdf29ec0684144bd13734
2026-07-30 19:47:30 +00:00

41 lines
1019 B
Rust

use std::path::PathBuf;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;
#[cfg(test)]
pub(crate) fn nullable_string_schema(
generator: &mut schemars::r#gen::SchemaGenerator,
) -> schemars::schema::Schema {
generator.subschema_for::<Option<String>>()
}
pub fn deserialize_empty_path_as_none<'de, D>(deserializer: D) -> Result<Option<PathBuf>, D::Error>
where
D: Deserializer<'de>,
{
let path = Option::<PathBuf>::deserialize(deserializer)?;
Ok(path.filter(|path| !path.as_os_str().is_empty()))
}
pub fn deserialize_double_option<'de, T, D>(deserializer: D) -> Result<Option<Option<T>>, D::Error>
where
T: Deserialize<'de>,
D: Deserializer<'de>,
{
serde_with::rust::double_option::deserialize(deserializer)
}
pub fn serialize_double_option<T, S>(
value: &Option<Option<T>>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
T: Serialize,
S: Serializer,
{
serde_with::rust::double_option::serialize(value, serializer)
}