opg
opg copied to clipboard
Add proc-macro for paths
Instead of describing the paths in the describe_api macro, I would like to have some proc-macro.
Instead of this:
describe_api! {
// ...
paths: {
("some" / "path" / { param: String }): {
GET: {
description: "Get smth",
200: Smth,
500: ApiError
},
POST: {
description: "Do smth",
200: None,
500: ApiError
},
}
}
}
describe api like this:
#[opg::path(
path = "some/path/{param}",
method = "GET",
description = "Get smth",
on_200 = "Smth",
on_500 = "ApiError",
)]
async fn get_smth() -> Result<Smth, ApiError> {...}
#[opg::path(
path = "some/path/{param}",
method = "POST",
description = "Get smth",
on_200 = "None",
on_500 = "ApiError",
)]
async fn do_smth() -> Result<(), ApiError> {...}
// ...
describe_api! {
// ...
paths: {
get_smth,
do_smth,
}
}