Added OpenAPI examples

This commit is contained in:
2026-04-26 09:30:05 +02:00
parent c31b062a6b
commit 31425db152
2 changed files with 178 additions and 0 deletions

View File

@@ -5,6 +5,35 @@ from typing import Any
from pydantic import BaseModel, Field
REPOSITORY_EXAMPLE = {
"id": 1,
"name": "MailRouter",
"url": "https://github.com/example/mail-router.git",
"description": "Routes incoming customer email.",
"branch": "main",
"status": "indexed",
}
ANALYSIS_RUN_EXAMPLE = {
"id": 1,
"repository_id": 1,
"snapshot_id": 1,
"status": "completed",
"started_at": "2026-04-26T09:00:00Z",
"completed_at": "2026-04-26T09:00:03Z",
"error_message": None,
"scanner_version": "deterministic-v1",
}
SOURCE_REFERENCE_EXAMPLE = {
"fact_id": 12,
"path": "src/routes/classify_email.py",
"kind": "api_route",
"name": "POST /api/classify-email",
"line": 42,
}
class RepositoryCreate(BaseModel):
url: str
name: str | None = None
@@ -292,6 +321,12 @@ class RepositoryResponse(BaseModel):
branch: str
status: str
model_config = {
"json_schema_extra": {
"examples": [REPOSITORY_EXAMPLE],
}
}
class RepositorySnapshotResponse(BaseModel):
id: int
@@ -410,6 +445,66 @@ class CandidateGraphResponse(BaseModel):
analysis_run: AnalysisRunResponse
abilities: list[CandidateAbilityResponse]
model_config = {
"json_schema_extra": {
"examples": [
{
"repository": {
**REPOSITORY_EXAMPLE,
"status": "reviewing",
},
"analysis_run": ANALYSIS_RUN_EXAMPLE,
"abilities": [
{
"id": 1,
"name": "Business Email Routing",
"description": "Route inbound messages to the right team.",
"confidence": 0.82,
"confidence_label": "high",
"status": "pending",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
"capabilities": [
{
"id": 1,
"name": "Classify Incoming Email",
"description": "Classify messages by intent.",
"inputs": ["subject", "body"],
"outputs": ["intent", "confidence"],
"confidence": 0.78,
"confidence_label": "medium",
"status": "pending",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
"features": [
{
"id": 1,
"name": "POST /api/classify-email",
"type": "REST endpoint",
"location": "src/routes/classify_email.py",
"confidence": 0.84,
"confidence_label": "high",
"status": "pending",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
}
],
"evidence": [
{
"id": 1,
"type": "unit_test",
"reference": "tests/test_email_classification.py",
"strength": "strong",
"status": "pending",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
}
],
}
],
}
],
}
]
}
}
class EvidenceResponse(BaseModel):
id: int
@@ -454,6 +549,56 @@ class RepositoryAbilityMapResponse(BaseModel):
repository: RepositoryResponse
abilities: list[AbilityResponse]
model_config = {
"json_schema_extra": {
"examples": [
{
"repository": REPOSITORY_EXAMPLE,
"abilities": [
{
"id": 1,
"name": "Business Email Routing",
"description": "Route inbound messages to the right team.",
"confidence": 0.92,
"confidence_label": "high",
"capabilities": [
{
"id": 1,
"name": "Classify Incoming Email",
"description": "Classify messages by intent.",
"inputs": ["subject", "body"],
"outputs": ["intent", "confidence"],
"confidence": 0.88,
"confidence_label": "high",
"features": [
{
"id": 1,
"name": "POST /api/classify-email",
"type": "REST endpoint",
"location": "src/routes/classify_email.py",
"confidence": 0.84,
"confidence_label": "high",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
}
],
"evidence": [
{
"id": 1,
"type": "unit_test",
"reference": "tests/test_email_classification.py",
"strength": "strong",
"source_refs": [SOURCE_REFERENCE_EXAMPLE],
}
],
}
],
}
],
}
]
}
}
class IdResponse(BaseModel):
id: int
@@ -475,6 +620,29 @@ class SearchResultResponse(BaseModel):
evidence_level: str | None = None
source_reference: str | None = None
model_config = {
"json_schema_extra": {
"examples": [
{
"repository_id": 1,
"repository_name": "MailRouter",
"match_type": "capability",
"match_name": "Classify Incoming Email",
"confidence": 0.88,
"confidence_label": "high",
"match_description": "Classify messages by intent.",
"matched_field": "capability.description",
"ability_id": 1,
"ability_name": "Business Email Routing",
"capability_id": 1,
"capability_name": "Classify Incoming Email",
"evidence_level": None,
"source_reference": None,
}
]
}
}
class AbilitySummaryResponse(BaseModel):
id: int