use alux_http::HttpProgramExt;
use alux_http_conformance::{LABELS, Shop, ShopApiExt, WideApiExt};
use alux_http_openapi::OpenApiHandlerImpl;
#[test]
fn documents_the_shared_surface() {
let api = OpenApiHandlerImpl::<Shop>::new();
let route = api.compile_http(api.shop_api::<Shop>());
assert_eq!(route.labels(), LABELS);
let document = api.document("shop", "1.0", &route);
assert_eq!(document["paths"]["/item/{id}"]["get"]["operationId"], "shop_item");
assert_eq!(
document["paths"]["/items"]["post"]["responses"]["201"]["description"],
"Records one reading and returns it."
);
assert_eq!(document["paths"]["/items"]["delete"]["responses"]["204"]["description"], "Forgets every reading.");
}
#[test]
fn compiles_the_widest_endpoint_the_specification_states() {
let api = OpenApiHandlerImpl::<Shop>::new();
assert_eq!(api.compile_http(api.wide_api::<Shop>()).labels(), ["POST /wide"]);
}