Skip to content

Commit 9ae1480

Browse files
authored
fix: use schemas for health (#774)
1 parent e79d41b commit 9ae1480

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

healthx/doc.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ package healthx
66

77
import "strings"
88

9+
// The health status of the service.
10+
//
911
// swagger:model healthStatus
1012
type swaggerHealthStatus struct {
1113
// Status always contains "ok".
1214
Status string `json:"status"`
1315
}
1416

17+
// The not ready status of the service.
18+
//
1519
// swagger:model healthNotReadyStatus
1620
type swaggerNotReadyStatus struct {
1721
// Errors contains a list of errors that caused the not ready status.
@@ -26,7 +30,9 @@ func (s swaggerNotReadyStatus) Error() string {
2630
return strings.Join(errs, "; ")
2731
}
2832

29-
// swagger:model version
33+
// The service's version.
34+
//
35+
// swagger:model serviceVersion
3036
type swaggerVersion struct {
3137
// Version is the service's version.
3238
Version string `json:"version"`

healthx/openapi/patch.yaml

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717
content:
1818
application/json:
1919
schema:
20-
required:
21-
- status
22-
type: object
23-
properties:
24-
status:
25-
description: Always "ok".
26-
type: string
20+
"$ref": "#/components/schemas/healthStatus"
2721
description: '{{.ProjectHumanName}} is ready to accept connections.'
2822
default:
2923
content:
@@ -52,27 +46,13 @@
5246
content:
5347
application/json:
5448
schema:
55-
required:
56-
- status
57-
type: object
58-
properties:
59-
status:
60-
description: Always "ok".
61-
type: string
49+
"$ref": "#/components/schemas/healthStatus"
6250
description: '{{.ProjectHumanName}} is ready to accept requests.'
6351
'503':
6452
content:
6553
application/json:
6654
schema:
67-
required:
68-
- errors
69-
properties:
70-
errors:
71-
additionalProperties:
72-
type: string
73-
description: Errors contains a list of errors that caused the not ready status.
74-
type: object
75-
type: object
55+
"$ref": "#/components/schemas/healthNotReadyStatus"
7656
description: Ory Kratos is not yet ready to accept requests.
7757
default:
7858
content:
@@ -100,13 +80,7 @@
10080
content:
10181
application/json:
10282
schema:
103-
type: object
104-
required:
105-
- version
106-
properties:
107-
version:
108-
description: The version of {{.ProjectHumanName}}.
109-
type: string
83+
"$ref": "#/components/schemas/serviceVersion"
11084
description: Returns the {{.ProjectHumanName}} version.
11185
summary: Return Running Software Version.
11286
tags: {{ .HealthPathTags | toJson }}

0 commit comments

Comments
 (0)