openapi-lambda 0.1.3

Opinionated, strongly-typed code generation for AWS Lambda from OpenAPI definitions
Documentation
1
2
3
4
5
6
7
8
9
10
11
use serde::Serialize;

pub fn to_json<T>(value: &T) -> Result<String, serde_path_to_error::Error<serde_json::Error>>
where
  T: Serialize,
{
  let mut json_bytes = Vec::new();
  let mut serializer = serde_json::Serializer::new(&mut json_bytes);
  serde_path_to_error::serialize(value, &mut serializer)?;
  Ok(String::from_utf8(json_bytes).expect("JSON must be UTF-8"))
}