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
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
use continuum_types::{PrintJob, PrintJobStatus};
|
||||
|
||||
fn sample(status: PrintJobStatus) -> PrintJob {
|
||||
PrintJob {
|
||||
id: "job-1".into(),
|
||||
farm_id: "farm-1".into(),
|
||||
printer_id: "printer-1".into(),
|
||||
template_id: "template-1".into(),
|
||||
status: status as i32,
|
||||
progress_percent: 50.0,
|
||||
started_at_unix: 0,
|
||||
completed_at_unix: 0,
|
||||
gcode_file_key: "key".into(),
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test: PrintJob.status must serialize as the full proto enum
|
||||
// name (matching ts-types' TypeBox schema), not the raw i32 prost stores
|
||||
// it as internally.
|
||||
#[test]
|
||||
fn status_serializes_as_full_proto_enum_name() {
|
||||
let json = serde_json::to_value(sample(PrintJobStatus::Printing)).unwrap();
|
||||
assert_eq!(json["status"], "PRINT_JOB_STATUS_PRINTING");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn status_round_trips_through_json() {
|
||||
let original = sample(PrintJobStatus::Completed);
|
||||
let json = serde_json::to_string(&original).unwrap();
|
||||
let restored: PrintJob = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(restored.status, PrintJobStatus::Completed as i32);
|
||||
}
|
||||
Reference in New Issue
Block a user