forked from themanojdesai/python-a2a
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
106 lines (93 loc) · 2.92 KB
/
Copy path__init__.py
File metadata and controls
106 lines (93 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""
Documentation utilities for A2A Protocol.
"""
# Simple stub for now - we'll implement full docs later
def generate_a2a_docs(agent_card, output_dir=None):
"""
Generate OpenAPI documentation for A2A API
Args:
agent_card: The agent card to document
output_dir: Optional directory to save documentation
Returns:
API specification object
"""
# Simple implementation that just returns the agent card info
spec = {
"openapi": "3.0.3",
"info": {
"title": f"{agent_card.name} API",
"version": agent_card.version,
"description": agent_card.description
},
"paths": {
"/agent.json": {
"get": {
"summary": "Get agent card",
"responses": {
"200": {
"description": "Agent card"
}
}
}
},
"/tasks/send": {
"post": {
"summary": "Send a task",
"responses": {
"200": {
"description": "Task result"
}
}
}
}
}
}
return spec
def generate_html_docs(spec):
"""
Generate HTML documentation from API specification
Args:
spec: API specification
Returns:
HTML documentation string
"""
# Simple implementation that returns basic HTML
import json
html = f"""<!DOCTYPE html>
<html>
<head>
<title>A2A API Documentation</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {{ font-family: sans-serif; margin: 0; padding: 20px; }}
h1 {{ color: #333; }}
.endpoint {{ margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 4px; }}
.method {{ display: inline-block; padding: 4px 8px; border-radius: 4px; color: white; }}
.get {{ background-color: #61affe; }}
.post {{ background-color: #49cc90; }}
</style>
</head>
<body>
<h1>{spec['info']['title']}</h1>
<p>{spec['info']['description']}</p>
<h2>Version: {spec['info']['version']}</h2>
<h2>Endpoints</h2>
<div class="endpoints">
"""
# Add endpoints
for path, methods in spec['paths'].items():
for method, details in methods.items():
html += f"""
<div class="endpoint">
<span class="method {method}">{method.upper()}</span>
<span class="path">{path}</span>
<p>{details.get('summary', '')}</p>
</div>
"""
html += """
</div>
</body>
</html>
"""
return html