fix(api): update health endpoint to return detailed health info

- Changed the response type of the health endpoint to use a new HealthMap type for better clarity.
- Updated the health information retrieval method to GetHealthInfoWithoutDetail for improved accuracy in the response.
- Adjusted Swagger documentation to reflect the new response structure.
This commit is contained in:
yusing
2026-02-13 21:44:22 +08:00
parent 7fc6c4ace1
commit 1a33c0079d
4 changed files with 74 additions and 63 deletions

View File

@@ -855,7 +855,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/github_com_yusing_goutils_events.Event"
"$ref": "#/definitions/Event"
}
}
},
@@ -1210,10 +1210,7 @@
"200": {
"description": "Health info by route name",
"schema": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/HealthStatusString"
}
"$ref": "#/definitions/HealthMap"
}
},
"403": {
@@ -3827,6 +3824,42 @@
"x-nullable": false,
"x-omitempty": false
},
"Event": {
"type": "object",
"properties": {
"action": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"category": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"data": {
"x-nullable": false,
"x-omitempty": false
},
"level": {
"$ref": "#/definitions/events.Level",
"x-nullable": false,
"x-omitempty": false
},
"timestamp": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"uuid": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
}
},
"x-nullable": false,
"x-omitempty": false
},
"FileType": {
"type": "string",
"enum": [
@@ -3996,7 +4029,6 @@
"type": "object",
"properties": {
"latency": {
"description": "latency in microseconds",
"type": "number",
"x-nullable": false,
"x-omitempty": false
@@ -4015,7 +4047,6 @@
"x-omitempty": false
},
"uptime": {
"description": "uptime in milliseconds",
"type": "number",
"x-nullable": false,
"x-omitempty": false
@@ -4088,6 +4119,14 @@
"x-nullable": false,
"x-omitempty": false
},
"HealthMap": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/HealthInfoWithoutDetail"
},
"x-nullable": false,
"x-omitempty": false
},
"HealthStatusString": {
"type": "string",
"enum": [
@@ -6718,37 +6757,6 @@
"x-nullable": false,
"x-omitempty": false
},
"github_com_yusing_goutils_events.Event": {
"type": "object",
"properties": {
"action": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"category": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
},
"data": {
"x-nullable": false,
"x-omitempty": false
},
"level": {
"$ref": "#/definitions/events.Level",
"x-nullable": false,
"x-omitempty": false
},
"timestamp": {
"type": "string",
"x-nullable": false,
"x-omitempty": false
}
},
"x-nullable": false,
"x-omitempty": false
},
"icons.Source": {
"type": "string",
"enum": [

View File

@@ -295,6 +295,20 @@ definitions:
message:
type: string
type: object
Event:
properties:
action:
type: string
category:
type: string
data: {}
level:
$ref: '#/definitions/events.Level'
timestamp:
type: string
uuid:
type: string
type: object
FileType:
enum:
- config
@@ -375,7 +389,6 @@ definitions:
HealthInfoWithoutDetail:
properties:
latency:
description: latency in microseconds
type: number
status:
enum:
@@ -387,7 +400,6 @@ definitions:
- unknown
type: string
uptime:
description: uptime in milliseconds
type: number
type: object
HealthJSON:
@@ -419,6 +431,10 @@ definitions:
url:
type: string
type: object
HealthMap:
additionalProperties:
$ref: '#/definitions/HealthInfoWithoutDetail'
type: object
HealthStatusString:
enum:
- unknown
@@ -1755,18 +1771,6 @@ definitions:
- LevelInfo
- LevelWarn
- LevelError
github_com_yusing_goutils_events.Event:
properties:
action:
type: string
category:
type: string
data: {}
level:
$ref: '#/definitions/events.Level'
timestamp:
type: string
type: object
icons.Source:
enum:
- https://
@@ -1828,12 +1832,12 @@ definitions:
type: string
kernel_version:
type: string
load_avg_15m:
type: string
load_avg_1m:
type: string
load_avg_5m:
type: string
load_avg_15m:
type: string
mem_pct:
type: string
mem_total:
@@ -2484,7 +2488,7 @@ paths:
description: OK
schema:
items:
$ref: '#/definitions/github_com_yusing_goutils_events.Event'
$ref: '#/definitions/Event'
type: array
"403":
description: 'Forbidden: unauthorized'
@@ -2721,9 +2725,7 @@ paths:
"200":
description: Health info by route name
schema:
additionalProperties:
$ref: '#/definitions/HealthStatusString'
type: object
$ref: '#/definitions/HealthMap'
"403":
description: Forbidden
schema: