Documented import/export format defaults are required on the wire: OBJ/PLY/STL/glTF options lack #[serde(default)]
Context: API Makeathon participant. Found while reviewing the format option types.
The OBJ, PLY, STL, and glTF format-option structs document defaults (for example OBJ documents default coordinate system and millimeters) and have #[builder(default)] plus impl Default, but they do not carry #[serde(default)]. Builder defaults and impl Default do not affect serde deserialization or the schemars required list, so those "defaulted" fields are actually required on the wire.
Evidence
modeling-cmds/src/format/obj.rs: the docs at line 26 describe default coordinates and millimeters, but the options at line 12 have only builder defaults and no serde default. The same pattern is present for PLY and STL (import and export) and glTF export. By contrast STEP is correct: modeling-cmds/src/format/step.rs:14 uses #[serde(default)]. The generated schema requires OBJ's supposedly-defaulted fields in modeling-cmds/openapi/api.json.
Why it is wrong
A JSON client that sends the documented minimal request, e.g. {"type":"obj"}, gets a missing-field deserialization error instead of the documented defaults. Generated clients also force callers to populate every field the docs describe as optional.
Concrete failure
{"type":"obj"} and {"type":"gltf"} fail to deserialize into InputFormat3d / OutputFormat3d, while the equivalent minimal STEP variant succeeds. A user who reads the docs and sends only the format type gets a hard error.
Verify
Deserialize {"type":"obj"} and {"type":"gltf"} into InputFormat3d / OutputFormat3d: both fail. The minimal STEP variant succeeds.
Suggested fix
Add #[serde(default)] to the OBJ, PLY, STL, and glTF option structs (and their fields) so deserialization and the generated schema match the documented and builder defaults, as STEP already does.
Environment
Reviewed against the current main of KittyCAD/modeling-api.
Documented import/export format defaults are required on the wire: OBJ/PLY/STL/glTF options lack
#[serde(default)]Context: API Makeathon participant. Found while reviewing the format option types.
The OBJ, PLY, STL, and glTF format-option structs document defaults (for example OBJ documents default coordinate system and millimeters) and have
#[builder(default)]plusimpl Default, but they do not carry#[serde(default)]. Builder defaults andimpl Defaultdo not affect serde deserialization or the schemarsrequiredlist, so those "defaulted" fields are actually required on the wire.Evidence
modeling-cmds/src/format/obj.rs: the docs at line 26 describe default coordinates and millimeters, but the options at line 12 have only builder defaults and no serde default. The same pattern is present for PLY and STL (import and export) and glTF export. By contrast STEP is correct:modeling-cmds/src/format/step.rs:14uses#[serde(default)]. The generated schema requires OBJ's supposedly-defaulted fields inmodeling-cmds/openapi/api.json.Why it is wrong
A JSON client that sends the documented minimal request, e.g.
{"type":"obj"}, gets a missing-field deserialization error instead of the documented defaults. Generated clients also force callers to populate every field the docs describe as optional.Concrete failure
{"type":"obj"}and{"type":"gltf"}fail to deserialize intoInputFormat3d/OutputFormat3d, while the equivalent minimal STEP variant succeeds. A user who reads the docs and sends only the format type gets a hard error.Verify
Deserialize
{"type":"obj"}and{"type":"gltf"}intoInputFormat3d/OutputFormat3d: both fail. The minimal STEP variant succeeds.Suggested fix
Add
#[serde(default)]to the OBJ, PLY, STL, and glTF option structs (and their fields) so deserialization and the generated schema match the documented and builder defaults, as STEP already does.Environment
Reviewed against the current
mainof KittyCAD/modeling-api.