sdk: readable clients (no Empty wrapper, no unused error module), documented examples with tests

This commit is contained in:
2026-10-23 01:05:19 +01:00
parent edc2d1a63b
commit 0516158883
15 changed files with 426 additions and 81 deletions
+13 -7
View File
@@ -68,25 +68,31 @@ pub fn method<P: Params, R: SchemaType>(doc: &mut Value, name: &str, docs: &str)
"schema": field,
})
}).collect();
doc["x-sdk-input"]
.as_object_mut()
.unwrap()
.extend(definitions);
if !params.is_empty() {
doc["x-sdk-input"]
.as_object_mut()
.unwrap()
.extend(definitions);
}
let mut output = generator(true);
let result_schema = serde_json::to_value(output.subschema_for::<R>()).unwrap();
doc["x-sdk-output"]
.as_object_mut()
.unwrap()
.extend(output.take_definitions(true));
doc["methods"].as_array_mut().unwrap().push(json!({
let has_params = !params.is_empty();
let mut method = json!({
"name":name,
"summary":docs.split("\n\n").next().unwrap_or_default(),
"description":docs,
"paramStructure":"by-name",
"params":params,
"result":{"name":"result","schema":result_schema},
"x-sausage-params":params_ref,
}));
});
if has_params {
method["x-sausage-params"] = params_ref;
}
doc["methods"].as_array_mut().unwrap().push(method);
}
/// Resolve shared schema names after all methods contribute their contracts.