Files
octoturge 51dba8e896 Fix broken v2 bambulab schema refs, wire up v2 dispatchers, fix PrintJobStatus JSON mismatch
- v2/common/device/device.schema.json: stray backtick in bed $ref broke resolution
- v2/report/print/print.schema.json: ams $ref pointed at wrong path (missing ams/ subdir)
- v2/common/device/plate.schema.json: $id was copy-pasted from bed.schema.json
- Add v2/request.schema.json and v2/report.schema.json dispatchers - v2's leaf
  schemas were unreachable without them, same oneOf convention as v1
- Rewrite schemas/bambulab/README.md layout section, which still described
  v1's pre-rename paths and claimed v2 was removed
- PrintJob.status serialized as a raw i32 in Rust (prost stores proto3 enums
  as i32) while ts-types' TypeBox schema validates full enum name strings -
  add serde with= on the field so Rust JSON matches TS and protobuf's own
  canonical JSON enum mapping, plus a regression test
2026-08-31 13:50:51 +00:00

39 lines
1.4 KiB
Rust

use std::path::PathBuf;
fn main() {
let proto_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../proto")
.canonicalize()
.expect("proto root must exist");
let proto_files = [
proto_root.join("continuum/v1/material.proto"),
proto_root.join("continuum/v1/print_params.proto"),
proto_root.join("continuum/v1/template.proto"),
proto_root.join("continuum/v1/print_job.proto"),
];
for file in &proto_files {
println!("cargo:rerun-if-changed={}", file.display());
}
let mut config = prost_build::Config::new();
config.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]");
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");
// prost stores proto3 enums as plain `i32` fields (not the generated
// enum type), so the blanket type_attribute above never actually runs
// for `status` - it'd serialize as a bare number, disagreeing with
// TypeBox's full-name string literals in ts-types. Route the field
// through PrintJobStatus's own as_str_name()/from_str_name() instead,
// matching protobuf's own canonical JSON enum representation.
config.field_attribute(
".continuum.v1.PrintJob.status",
"#[serde(with = \"crate::print_job_status_serde\")]",
);
config
.compile_protos(&proto_files, &[proto_root])
.expect("failed to compile continuum .proto sources");
}