feat(api): the OpenAPI description covers the code graph and chat routes (#1006)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m43s
CI / Check (pull_request) Successful in 20m20s

The 12 code graph, chat and help chat paths are described from their
handlers: the graph, its nodes, summary, communities, a finding's impact,
symbol search, file content and rebuild (tag "Code graph"), the code chat
and its embeddings (tag "Chat"), and the documentation chat (tag "Help").
The search, file and help chat inputs are schemas; the code chat body
stays an object, as it is a core type. undescribed_routes.txt drops to
59 paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-11-16 17:46:16 +01:00
1 parent bde53a96dd
commit 75ff5d4d43
5 files changed
+168 -69

No files matched your search

+34 -3
View File
@@ -18,7 +18,18 @@ use super::ApiResponse;
type AgentExt = Extension<Arc<ComplianceAgent>>;
/// POST /api/v1/chat/:repo_id — Send a chat message with RAG context
/// Ask about a target's code, answered from its code graph.
#[utoipa::path(
post,
path = "/api/v1/chat/{repo_id}",
tag = "Chat",
params(("repo_id" = String, Path, description = "The target's id")),
request_body(content = Object, description = "`message`, and the earlier `history` as `role` and `content`"),
responses(
(status = 200, description = "The answer with its sources"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn chat(
Extension(agent): AgentExt,
@@ -133,7 +144,17 @@ pub async fn chat(
}))
}
/// POST /api/v1/chat/:repo_id/build-embeddings — Trigger embedding build
/// Build the embeddings the chat answers from, in the background.
#[utoipa::path(
post,
path = "/api/v1/chat/{repo_id}/build-embeddings",
tag = "Chat",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The build was started"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn build_embeddings(
Extension(agent): AgentExt,
@@ -244,7 +265,17 @@ pub async fn build_embeddings(
))
}
/// GET /api/v1/chat/:repo_id/status — Get latest embedding build status
/// The status of a target's latest embedding build.
#[utoipa::path(
get,
path = "/api/v1/chat/{repo_id}/status",
tag = "Chat",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The build, or null"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn embedding_status(
Extension(agent): AgentExt,
+103 -11
View File
@@ -42,14 +42,18 @@ pub struct GraphData {
pub total_nodes: u64,
}
#[derive(Deserialize)]
/// A symbol search.
#[derive(Deserialize, utoipa::IntoParams)]
#[into_params(parameter_in = Query)]
pub struct SearchParams {
/// The search text.
pub q: String,
/// Clamped to `1..=MAX_PAGE_SIZE` while deserializing, like every list.
#[serde(
default = "default_search_limit",
deserialize_with = "super::dto::de_limit"
)]
#[param(minimum = 1, maximum = 200)]
pub limit: i64,
}
@@ -57,7 +61,19 @@ fn default_search_limit() -> i64 {
50
}
/// GET /api/v1/graph/:repo_id — Full graph data
/// A target's code graph: its latest build, nodes and edges.
///
/// Truncated past a size a browser can lay out, and says so.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The graph"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn get_graph(
Extension(agent): AgentExt,
@@ -150,7 +166,17 @@ pub async fn get_graph(
}))
}
/// GET /api/v1/graph/:repo_id/nodes — List nodes (paginated)
/// A target's code graph nodes, a page at a time.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/nodes",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id"), PaginationParams),
responses(
(status = 200, description = "A page of nodes"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn get_nodes(
Extension(agent): AgentExt,
@@ -222,8 +248,19 @@ impl GraphSummary {
}
}
/// GET /api/v1/graph/:repo_id/summary — The latest build's counts, without
/// loading any node: `data` is `null` when there is none to show.
/// The counts of a target's latest graph build, without loading any node.
///
/// `data` is `null` when there is none to show.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/summary",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The counts, or null"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn get_summary(
Extension(agent): AgentExt,
@@ -244,7 +281,17 @@ pub async fn get_summary(
}))
}
/// GET /api/v1/graph/:repo_id/communities — List detected communities
/// The communities detected in a target's code graph.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/communities",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The communities"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn get_communities(
Extension(agent): AgentExt,
@@ -312,7 +359,17 @@ pub struct CommunityInfo {
pub members: Vec<String>,
}
/// GET /api/v1/graph/:repo_id/impact/:finding_id — Impact analysis
/// What a finding reaches in a target's code graph.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/impact/{finding_id}",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id"), ("finding_id" = String, Path, description = "The finding's id")),
responses(
(status = 200, description = "The impact analysis, or null"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id, finding_id = %finding_id))]
pub async fn get_impact(
Extension(agent): AgentExt,
@@ -336,7 +393,17 @@ pub async fn get_impact(
}))
}
/// GET /api/v1/graph/:repo_id/search — BM25 symbol search
/// Search a target's code graph for symbols (BM25).
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/search",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id"), SearchParams),
responses(
(status = 200, description = "The matching nodes"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id, query = %params.q))]
pub async fn search_symbols(
Extension(agent): AgentExt,
@@ -370,7 +437,19 @@ pub async fn search_symbols(
}))
}
/// GET /api/v1/graph/:repo_id/file-content — Read source file from cloned repo
/// A source file of a target's checkout.
#[utoipa::path(
get,
path = "/api/v1/graph/{repo_id}/file-content",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id"), FileContentParams),
responses(
(status = 200, description = "The file"),
(status = 403, description = "The path leaves the checkout"),
(status = 404, description = "No such target, checkout or file"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn get_file_content(
Extension(agent): AgentExt,
@@ -431,8 +510,11 @@ pub async fn get_file_content(
}))
}
#[derive(Deserialize)]
/// The file of [`get_file_content`].
#[derive(Deserialize, utoipa::IntoParams)]
#[into_params(parameter_in = Query)]
pub struct FileContentParams {
/// The file's path in the checkout.
pub path: String,
}
@@ -443,7 +525,17 @@ pub struct FileContent {
pub language: String,
}
/// POST /api/v1/graph/:repo_id/build — Trigger graph rebuild
/// Rebuild a target's code graph in the background.
#[utoipa::path(
post,
path = "/api/v1/graph/{repo_id}/build",
tag = "Code graph",
params(("repo_id" = String, Path, description = "The target's id")),
responses(
(status = 200, description = "The build was started"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all, fields(repo_id = %repo_id))]
pub async fn trigger_build(
Extension(agent): AgentExt,
+19 -4
View File
@@ -11,15 +11,21 @@ use super::dto::{AgentExt, ApiResponse};
// ── DTOs ─────────────────────────────────────────────────────────────────────
#[derive(Debug, Deserialize)]
/// An earlier turn of a help chat.
#[derive(Debug, Deserialize, utoipa::ToSchema)]
pub struct HelpChatMessage {
/// `user` or `assistant`.
pub role: String,
/// What was said.
pub content: String,
}
#[derive(Debug, Deserialize)]
/// The body of [`help_chat`].
#[derive(Debug, Deserialize, utoipa::ToSchema)]
pub struct HelpChatRequest {
/// The question.
pub message: String,
/// The earlier turns, oldest first.
#[serde(default)]
pub history: Vec<HelpChatMessage>,
}
@@ -170,8 +176,17 @@ fn doc_context() -> &'static str {
// ── Handler ──────────────────────────────────────────────────────────────────
/// POST /api/v1/help/chat — Answer questions about the compliance-scanner
/// using the project documentation as grounding context.
/// Ask about Prüfwerk, answered from its published documentation.
#[utoipa::path(
post,
path = "/api/v1/help/chat",
tag = "Help",
request_body = HelpChatRequest,
responses(
(status = 200, description = "The answer"),
(status = 401, description = "No valid bearer token"),
)
)]
#[tracing::instrument(skip_all)]
pub async fn help_chat(
Extension(agent): AgentExt,
+12 -39
View File
@@ -234,35 +234,14 @@ fn described_routes() -> OpenApiRouter {
delete(handlers::mcp_tokens::revoke_mcp_token),
)
// Graph API endpoints
.route("/api/v1/graph/{repo_id}", get(handlers::graph::get_graph))
.route(
"/api/v1/graph/{repo_id}/nodes",
get(handlers::graph::get_nodes),
)
.route(
"/api/v1/graph/{repo_id}/summary",
get(handlers::graph::get_summary),
)
.route(
"/api/v1/graph/{repo_id}/communities",
get(handlers::graph::get_communities),
)
.route(
"/api/v1/graph/{repo_id}/impact/{finding_id}",
get(handlers::graph::get_impact),
)
.route(
"/api/v1/graph/{repo_id}/search",
get(handlers::graph::search_symbols),
)
.route(
"/api/v1/graph/{repo_id}/file-content",
get(handlers::graph::get_file_content),
)
.route(
"/api/v1/graph/{repo_id}/build",
post(handlers::graph::trigger_build),
)
.routes(routes!(handlers::graph::get_graph))
.routes(routes!(handlers::graph::get_nodes))
.routes(routes!(handlers::graph::get_summary))
.routes(routes!(handlers::graph::get_communities))
.routes(routes!(handlers::graph::get_impact))
.routes(routes!(handlers::graph::search_symbols))
.routes(routes!(handlers::graph::get_file_content))
.routes(routes!(handlers::graph::trigger_build))
// DAST API endpoints
.routes(routes!(
handlers::dast::list_targets,
@@ -273,17 +252,11 @@ fn described_routes() -> OpenApiRouter {
.routes(routes!(handlers::dast::list_findings))
.routes(routes!(handlers::dast::get_finding))
// Chat / RAG API endpoints
.route("/api/v1/chat/{repo_id}", post(handlers::chat::chat))
.route(
"/api/v1/chat/{repo_id}/build-embeddings",
post(handlers::chat::build_embeddings),
)
.route(
"/api/v1/chat/{repo_id}/status",
get(handlers::chat::embedding_status),
)
.routes(routes!(handlers::chat::chat))
.routes(routes!(handlers::chat::build_embeddings))
.routes(routes!(handlers::chat::embedding_status))
// Help chat (documentation-grounded Q&A)
.route("/api/v1/help/chat", post(handlers::help_chat::help_chat))
.routes(routes!(handlers::help_chat::help_chat))
// CVE notification endpoints
.route(
"/api/v1/notifications",
@@ -44,18 +44,6 @@
/api/v1/mcp-servers/{id}/token
/api/v1/mcp-tokens
/api/v1/mcp-tokens/{id}
/api/v1/graph/{repo_id}
/api/v1/graph/{repo_id}/nodes
/api/v1/graph/{repo_id}/summary
/api/v1/graph/{repo_id}/communities
/api/v1/graph/{repo_id}/impact/{finding_id}
/api/v1/graph/{repo_id}/search
/api/v1/graph/{repo_id}/file-content
/api/v1/graph/{repo_id}/build
/api/v1/chat/{repo_id}
/api/v1/chat/{repo_id}/build-embeddings
/api/v1/chat/{repo_id}/status
/api/v1/help/chat
/api/v1/notifications
/api/v1/notifications/count
/api/v1/notifications/read-all