sdk: readable clients (no Empty wrapper, no unused error module), documented examples with tests
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
//! Check the shared generator against a real example's discovered document.
|
||||
|
||||
/// String enums retain the conversion support that their parsers need.
|
||||
#[test]
|
||||
fn enum_client_keeps_used_error_support() {
|
||||
let doc = serde_json::json!({
|
||||
"components":{"schemas":{"Mode":{"type":"string","enum":["fast","slow"]}}},
|
||||
"methods":[{"name":"mode","params":[],"result":{"schema":{"$ref":"#/components/schemas/Mode"}}}]
|
||||
});
|
||||
let code = sausage_interface::client_rs("settings", &doc).unwrap();
|
||||
assert!(code.contains("pub mod error"));
|
||||
assert!(code.contains("error::ConversionError"));
|
||||
assert!(!code.contains("ModeParams"));
|
||||
syn::parse_file(&code).unwrap();
|
||||
}
|
||||
#[test]
|
||||
fn notes_client_preserves_names_and_docs() {
|
||||
let document =
|
||||
@@ -7,6 +21,8 @@ fn notes_client_preserves_names_and_docs() {
|
||||
assert!(code.contains("pub struct AddParams"));
|
||||
assert!(code.contains("pub struct Added"));
|
||||
assert!(!code.contains("AddedResult"));
|
||||
assert!(!code.contains("pub struct Empty"));
|
||||
assert!(!code.contains("pub mod error"));
|
||||
assert!(code.contains("The complete note text"));
|
||||
assert!(code.contains("pub fn add(params: AddParams)"));
|
||||
syn::parse_file(&code).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user