hyperlane-plugin-openapi 23.3.1

An OpenAPI 3.1.0 specification builder and zero-allocation interactive API docs plugin for the Hyperlane framework serving ETag-cached /openapi.json (with 304 support) and a self-contained zero-CDN /docs explorer.
Documentation
use super::*;

#[test]
fn test_openapi_spec_serialization_etag_and_docs_wire() {
    let spec: OpenApiSpec = OpenApiSpec::new("Orders API", "2.1.0")
        .with_description("High-throughput order processing service")
        .with_server("https://api.example.com")
        .with_operation(
            "/orders/{id}",
            "GET",
            OpenApiOperation::new("Fetch order by ID")
                .with_tag("orders")
                .with_parameter("id", "path", true)
                .with_response(200, "Order found")
                .with_response(404, "Order not found"),
        );
    let plugin: OpenApiPlugin = OpenApiPlugin::new(OpenApiConfig::from_spec(spec));
    assert!(plugin.get_spec_etag().starts_with('"'));
    let spec_wire: String = String::from_utf8(plugin.get_spec_wire().to_vec()).unwrap();
    assert!(spec_wire.starts_with("HTTP/1.1 200 OK"));
    assert!(spec_wire.contains("\"openapi\":\"3.1.0\""));
    assert!(spec_wire.contains("Orders API"));
    assert!(spec_wire.contains("/orders/{id}"));
    let docs_wire: String = String::from_utf8(plugin.get_docs_wire().to_vec()).unwrap();
    assert!(docs_wire.starts_with("HTTP/1.1 200 OK"));
    assert!(docs_wire.contains("text/html"));
    assert!(docs_wire.contains("/openapi.json"));
}