From 58f9fbbb643a8b88324d25f08ea257ceabfb7acd Mon Sep 17 00:00:00 2001 From: Markus Alexander Kuppe Date: Wed, 3 Jul 2024 14:52:34 -0700 Subject: [PATCH] https://spec.openapis.org/oas/latest.html suggests that "operationId" (or "operationref") is mandatory. Signed-off-by: Markus Alexander Kuppe --- src/endpoints/endpoint_registry.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/endpoints/endpoint_registry.cpp b/src/endpoints/endpoint_registry.cpp index 32f0da7e776d..b75a71200f8c 100644 --- a/src/endpoints/endpoint_registry.cpp +++ b/src/endpoints/endpoint_registry.cpp @@ -34,6 +34,12 @@ namespace ccf::endpoints ds::openapi::path(document, endpoint->full_uri_path), http_verb.value()); + // Add what appears a *mandatory* operationId, which is expected to be a unique string. + std::string p = std::regex_replace(endpoint->full_uri_path, std::regex("[/_]"), ""); + std::string s = llhttp_method_name(http_verb.value()); + ccf::nonstd::to_lower(s); + path_op["operationId"] = fmt::format("{}_{}", p, s); + // Path Operation must contain at least one response - if none has been // defined, assume this can return 200 if (ds::openapi::responses(path_op).empty())