All updates
Rust API Client
DocSpring now has an official Rust API client, the docspring crate on crates.io. It covers all of API v2 with an async method for each operation, and checks each request against the API's schemas before sending it, so a request the API would reject fails with a list of what's wrong.
[dependencies]
docspring = "4"
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
- Typed requests and responses. Each operation takes its parameters from a builder, and its models are Rust structs and enums. An enum value added to the API after your release comes back as
Unknownwith the value, so a new submission state doesn't break your code. - Errors you can act on. An error response comes back as the operation's error type for its status, with the response's headers, such as a 429's
Retry-After. - Webhooks.
docspring::verify_webhook_signaturechecks a webhook request's signature. - Mocks for your tests. The
mockallfeature addsMockApi, a mock of the client.
The template editor's Code button writes Rust structs for a template's data too, which serde turns into the data you send.
See Install an API Client and Generate Model Code.