static_string

Macro static_string 

Source
macro_rules! static_string {
    ($vis:vis $name:ident, $str:expr) => { ... };
}
Expand description

Construct an OpenApi type that always evaluates to a static string that is set at compile time.

ยงExample
use poem_ext::static_string;
use poem_openapi::{types::ToJSON, Object};

static_string!(NotFoundError, "not found");

#[derive(Debug, Object)]
struct NotFoundDetails {
    error: NotFoundError,
    foobar: i32,
}

let response = NotFoundDetails {
    error: Default::default(),
    foobar: 42,
};
assert_eq!(
    response.to_json_string(),
    r#"{"error":"not found","foobar":42}"#
);