API documentation: update OpenAPI spec with new endpoints for packet statistics, noise floor history, CAD calibration, and room messaging; improve response schemas and descriptions

This commit is contained in:
Lloyd
2025-12-18 12:06:21 +00:00
parent 289922e91b
commit f068ca5db2
2 changed files with 305 additions and 170 deletions
+174 -6
View File
@@ -2499,11 +2499,164 @@ class APIEndpoints:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pyMC Repeater API Documentation</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css">
<title>pyMC Repeater API</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css">
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/favicon-32x32.png" sizes="32x32" />
<style>
body { margin: 0; padding: 0; }
.topbar { display: none !important; }
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}
.topbar {
background-color: #1b1b1b !important;
border-bottom: 2px solid #3b4151;
}
.topbar .download-url-wrapper { display: none; }
.swagger-ui .topbar .topbar-wrapper {
padding: 16px 20px;
}
.swagger-ui .topbar .topbar-wrapper::before {
content: "pyMC Repeater API Documentation";
font-size: 1.5em;
font-weight: 600;
color: #fff;
}
.swagger-ui .info {
margin: 30px 0;
}
.swagger-ui .info .title {
font-size: 2.5rem;
font-weight: 700;
color: #3b4151;
}
.swagger-ui .scheme-container {
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.swagger-ui .opblock {
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.08);
margin-bottom: 16px;
border: 1px solid #e8e8e8;
}
.swagger-ui .opblock.opblock-get {
border-left: 4px solid #61affe;
}
.swagger-ui .opblock.opblock-post {
border-left: 4px solid #49cc90;
}
.swagger-ui .opblock.opblock-delete {
border-left: 4px solid #f93e3e;
}
.swagger-ui .opblock.opblock-put {
border-left: 4px solid #fca130;
}
.swagger-ui .opblock-summary {
padding: 12px 20px;
}
.swagger-ui .opblock-summary-method {
font-weight: 700;
border-radius: 4px;
text-transform: uppercase;
font-size: 12px;
padding: 6px 12px;
}
.swagger-ui .btn.execute {
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
border: none;
color: white;
font-weight: 600;
padding: 10px 24px;
border-radius: 6px;
transition: all 0.2s;
}
.swagger-ui .btn.execute:hover {
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
transform: translateY(-1px);
}
.swagger-ui .response-col_status {
font-weight: 600;
font-size: 14px;
}
.swagger-ui .model-box {
background: #f7f8fa;
border-radius: 8px;
padding: 16px;
}
.swagger-ui .response-col_description__inner p {
margin: 0;
padding: 8px 0;
}
.swagger-ui .filter-container {
padding: 16px 20px;
border-bottom: 1px solid #e8e8e8;
}
.swagger-ui .filter .operation-filter-input {
border: 2px solid #e8e8e8;
border-radius: 6px;
padding: 10px 16px;
font-size: 14px;
width: 100%;
max-width: 400px;
}
.swagger-ui .filter .operation-filter-input:focus {
border-color: #667eea;
outline: none;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.swagger-ui .opblock-tag {
font-size: 1.3rem;
font-weight: 700;
color: #3b4151;
padding: 16px 20px;
border-bottom: 2px solid #e8e8e8;
margin-bottom: 16px;
}
.swagger-ui .renderedMarkdown p {
line-height: 1.6;
}
/* Dark mode support */
@media (prefers-color-scheme: dark) {
.swagger-ui .opblock {
background: #2d2d2d;
border-color: #3b3b3b;
}
.swagger-ui .opblock-tag {
color: #e8e8e8;
border-bottom-color: #3b3b3b;
}
.swagger-ui .info .title {
color: #e8e8e8;
}
}
</style>
</head>
<body>
@@ -2512,7 +2665,7 @@ class APIEndpoints:
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function() {
SwaggerUIBundle({
const ui = SwaggerUIBundle({
url: '/api/openapi',
dom_id: '#swagger-ui',
deepLinking: true,
@@ -2527,9 +2680,24 @@ class APIEndpoints:
tryItOutEnabled: true,
filter: true,
displayRequestDuration: true,
displayOperationId: false,
persistAuthorization: true,
validatorUrl: null
validatorUrl: null,
syntaxHighlight: {
activate: true,
theme: "monokai"
},
defaultModelsExpandDepth: 1,
defaultModelExpandDepth: 2,
docExpansion: "list",
showExtensions: true,
showCommonExtensions: true,
tagsSorter: "alpha",
operationsSorter: "alpha"
});
// Add API info to title
window.ui = ui;
};
</script>
</body>
+131 -164
View File
@@ -119,6 +119,27 @@ paths:
mode: monitor
responses:
'200':
description: Mode changed
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
examples:
success:
value:
success: true
data: "Mode set to forward"
'400':
description: Invalid mode
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/packet_stats:
get:
tags: [Packets]
summary: Get packet statistics
description: Returns packet counts, types, and routing statistics
parameters:
- name: hours
@@ -154,9 +175,7 @@ paths:
by_type:
type: object
by_route:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
type: object
/set_duty_cycle:
post:
@@ -185,25 +204,39 @@ paths:
responses:
'200':
description: Duty cycle setting updated
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
/packet_stats:
/packet_history:
get:
tags: [Packets]
summary: Get packet statistics
summary: Get packet history
description: Retrieve recent packet history
parameters:
- name: hours
- name: limit
in: query
schema:
type: integer
default: 24
description: Time range in hours
default: 100
minimum: 1
maximum: 1000
description: Maximum number of packets to return
responses:
'200':
description: Packet statistics
description: Packet history
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: array
items:
type: object
/packet_by_hash:
get:
@@ -326,6 +359,8 @@ paths:
type: string
data:
type: array
items:
type: number
/metrics_graph_data:
get:
@@ -397,17 +432,42 @@ paths:
type: string
data:
type: array
items:
type: number
/noise_floor_history:
get:
tags: [Noise Floor]
summary: Get noise floor history
description: Retrieve historical noise floor measurements
parameters:
- name: hours
in: query
schema:
type: integer
default: 24
minimum: 1
maximum: 168
description: Time range in hours
responses:
'200':
description: Noise floor history
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: array
items:
type: object
/cad_calibration_start:
post:
tags: [CAD Calibration]
summary: Start CAD calibration
description: Begin Channel Activity Detection calibration process
requestBody:
required: true
@@ -446,6 +506,23 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
/cad_calibration_stop:
post:
tags: [CAD Calibration]
summary: Stop CAD calibration
responses:
'200':
description: Calibration stopped
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
/create_identity:
post:
tags: [Identities]
summary: Create new identity
description: Create a new repeater or room server identity
requestBody:
required: true
@@ -545,16 +622,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'200':
description: Calibration started
/cad_calibration_stop:
post:
tags: [CAD Calibration]
summary: Stop CAD calibration
responses:
'200':
description: Calibration stopped
/identities:
get:
@@ -575,7 +642,14 @@ paths:
properties:
identities:
type: array
|
items:
$ref: '#/components/schemas/Identity'
/room_messages:
get:
tags: [Room Server]
summary: Get room messages
description: |
Retrieve messages from a room with pagination.
**Max Messages Per Room**: 32 (hard limit)
@@ -676,6 +750,28 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/room_post_message:
post:
tags: [Room Server]
summary: Post message to room
description: |
Add a new message to a room server. Message will be distributed to all synced clients.
**Special author values:**
- `"server"` or `"system"` - System message, goes to ALL clients (API only)
- Any hex string - Normal message, NOT sent to that client
**Security:**
- Radio messages cannot use server key (blocked)
- API messages can use server key (for announcements)
**Rate Limits:**
- 10 messages/minute per author_pubkey
- 160 bytes max message length
- Global 1.1s gap between transmissions
requestBody:
required: true
content:
application/json:
schema:
@@ -799,129 +895,6 @@ paths:
value:
success: false
error: "message is required"
description: ACL statistics
/room_messages:
get:
tags: [Room Server]
summary: Get room messages
description: Retrieve messages from a room with pagination
parameters:
- name: room_name
in: query
schema:
type: string
example: General
- name: room_hash
in: query
schema:
type: string
example: "0x42"
- name: limit
in: query
schema:
type: integer
default: 50
- name: offset
in: query
schema:
type: integer
default: 0
- name: since_timestamp
in: query
schema:
type: number
format: float
responses:
'200':
description: Messages retrieved
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: object
properties:
room_name:
type: string
room_hash:
type: string
messages:
type: array
items:
$ref: '#/components/schemas/RoomMessage'
count:
type: integer
total:
type: integer
limit:
type: integer
offset:
type: integer
/room_post_message:
post:
tags: [Room Server]
summary: Post message to room
description: |
Add a new message to a room server. Message will be distributed to all synced clients.
**Special author values:**
- `"server"` or `"system"` - System message, goes to ALL clients
- Any hex string - Normal message, NOT sent to that client
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [message, author_pubkey]
properties:
room_name:
type: string
example: General
room_hash:
type: string
example: "0x42"
message:
type: string
maxLength: 160
example: "Hello from API"
author_pubkey:
type: string
example: "abc123def456..."
description: "Hex string or 'server' for system messages"
txt_type:
type: integer
default: 0
responses:
'200':
description: Message posted
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: object
properties:
message_id:
type: integer
room_name:
type: string
room_hash:
type: string
queued_for_distribution:
type: boolean
is_server_message:
type: boolean
author_filter_note:
type: string
/room_stats:
get:
@@ -1101,14 +1074,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
type: string
- name: room_hash
in: query
schema:
type: string
responses:
'200':
description: Client list
/room_message:
delete:
@@ -1149,6 +1114,18 @@ paths:
responses:
'200':
description: Messages cleared
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: object
properties:
deleted_count:
type: integer
components:
schemas:
@@ -1157,8 +1134,10 @@ components:
properties:
success:
type: boolean
example: true
data:
type: object
description: Response data (varies by endpoint)
ErrorResponse:
type: object
@@ -1168,19 +1147,7 @@ components:
example: false
error:
type: string
Identity:
type: object
properties:
name:
type: string
type:
type: string
enum: [repeater, room_server]
hash:
type: string
public_key:
type: string
description: Error message
RoomMessage:
type: object