Skip to content

Commit 18e4641

Browse files
Merge pull request #63 from OpenCHAMI/synackd/openapi-add-payload-data
docs: add missing payload data to POST/PUT openapi docs
2 parents 7515add + ae7bd90 commit 18e4641

File tree

5 files changed

+223
-12
lines changed

5 files changed

+223
-12
lines changed

cmd/cloud-init-server/group_handlers.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ func (h CiHandler) GetGroupHandler(w http.ResponseWriter, r *http.Request) {
127127
// @Description any existing content.
128128
// @Tags admin,groups
129129
// @Accept json
130-
// @Success 201 {object} nil
131-
// @Failure 422 {object} nil
132-
// @Failure 500 {object} nil
133-
// @Header 201 {string} Location "/groups/{name}"
134-
// @Param name path string true "Group name"
130+
// @Success 201 {object} nil
131+
// @Failure 422 {object} nil
132+
// @Failure 500 {object} nil
133+
// @Header 201 {string} Location "/groups/{name}"
134+
// @Param name path string true "Group name"
135+
// @Param group_data body cistore.GroupData true "Group data"
135136
// @Router /cloud-init/admin/groups/{name} [put]
136137
func (h CiHandler) UpdateGroupHandler(w http.ResponseWriter, r *http.Request) {
137138
var (

cmd/cloud-init-server/handlers.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ func DocsHandler(w http.ResponseWriter, r *http.Request) {
7171
// @Description Set default meta-data values for cluster.
7272
// @Tags admin,cluster-defaults
7373
// @Accept json
74-
// @Success 201 {object} nil
75-
// @Failure 400 {object} nil
76-
// @Failure 500 {object} nil
74+
// @Success 201 {object} nil
75+
// @Failure 400 {object} nil
76+
// @Failure 500 {object} nil
77+
// @Param data body cistore.ClusterDefaults true "Cluster defaults data"
7778
// @Router /cloud-init/admin/cluster-defaults [post]
7879
func SetClusterDataHandler(store cistore.Store) http.HandlerFunc {
7980
return func(w http.ResponseWriter, r *http.Request) {
@@ -141,10 +142,11 @@ func GetClusterDataHandler(store cistore.Store) http.HandlerFunc {
141142
// @Description Set meta-data for a specific node ID, overwriting relevant group meta-data.
142143
// @Tags admin,instance-data
143144
// @Accept json
144-
// @Success 201 {object} nil
145-
// @Failure 400 {object} nil
146-
// @Failure 500 {object} nil
147-
// @Param id path string true "Node ID"
145+
// @Success 201 {object} nil
146+
// @Failure 400 {object} nil
147+
// @Failure 500 {object} nil
148+
// @Param id path string true "Node ID"
149+
// @Param instance-info body cistore.OpenCHAMIInstanceInfo true "Instance info data"
148150
// @Router /cloud-init/admin/instance-info/{id} [put]
149151
func InstanceInfoHandler(sm smdclient.SMDClientInterface, store cistore.Store) http.HandlerFunc {
150152
return func(w http.ResponseWriter, r *http.Request) {

docs/docs.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ const docTemplate = `{
5252
"cluster-defaults"
5353
],
5454
"summary": "Set cluster defaults",
55+
"parameters": [
56+
{
57+
"description": "Cluster defaults data",
58+
"name": "data",
59+
"in": "body",
60+
"required": true,
61+
"schema": {
62+
"$ref": "#/definitions/cistore.ClusterDefaults"
63+
}
64+
}
65+
],
5566
"responses": {
5667
"201": {
5768
"description": "Created"
@@ -207,6 +218,15 @@ const docTemplate = `{
207218
"name": "name",
208219
"in": "path",
209220
"required": true
221+
},
222+
{
223+
"description": "Group data",
224+
"name": "group_data",
225+
"in": "body",
226+
"required": true,
227+
"schema": {
228+
"$ref": "#/definitions/cistore.GroupData"
229+
}
210230
}
211231
],
212232
"responses": {
@@ -368,6 +388,15 @@ const docTemplate = `{
368388
"name": "id",
369389
"in": "path",
370390
"required": true
391+
},
392+
{
393+
"description": "Instance info data",
394+
"name": "instance-info",
395+
"in": "body",
396+
"required": true,
397+
"schema": {
398+
"$ref": "#/definitions/cistore.OpenCHAMIInstanceInfo"
399+
}
371400
}
372401
],
373402
"responses": {
@@ -692,6 +721,54 @@ const docTemplate = `{
692721
}
693722
}
694723
},
724+
"cistore.OpenCHAMIInstanceInfo": {
725+
"type": "object",
726+
"properties": {
727+
"availability-zone": {
728+
"type": "string"
729+
},
730+
"cloud-init-base-url": {
731+
"type": "string"
732+
},
733+
"cloud-provider": {
734+
"type": "string"
735+
},
736+
"cluster-name": {
737+
"type": "string",
738+
"example": "demo"
739+
},
740+
"hostname": {
741+
"type": "string"
742+
},
743+
"id": {
744+
"type": "string",
745+
"example": "x3000c1b1n1"
746+
},
747+
"instance-id": {
748+
"type": "string"
749+
},
750+
"instance-type": {
751+
"type": "string"
752+
},
753+
"local-hostname": {
754+
"type": "string",
755+
"example": "compute-1"
756+
},
757+
"public-keys": {
758+
"type": "array",
759+
"items": {
760+
"type": "string"
761+
},
762+
"example": [
763+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMLtQNuzGcMDatF+YVMMkuxbX2c5v2OxWftBhEVfFb+U user1@demo-head",
764+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB4vVRvkzmGE5PyWX2fuzJEgEfET4PRLHXCnD1uFZ8ZL user2@demo-head"
765+
]
766+
},
767+
"region": {
768+
"type": "string"
769+
}
770+
}
771+
},
695772
"main.Group": {
696773
"type": "object",
697774
"additionalProperties": true

docs/swagger.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@
4444
"cluster-defaults"
4545
],
4646
"summary": "Set cluster defaults",
47+
"parameters": [
48+
{
49+
"description": "Cluster defaults data",
50+
"name": "data",
51+
"in": "body",
52+
"required": true,
53+
"schema": {
54+
"$ref": "#/definitions/cistore.ClusterDefaults"
55+
}
56+
}
57+
],
4758
"responses": {
4859
"201": {
4960
"description": "Created"
@@ -199,6 +210,15 @@
199210
"name": "name",
200211
"in": "path",
201212
"required": true
213+
},
214+
{
215+
"description": "Group data",
216+
"name": "group_data",
217+
"in": "body",
218+
"required": true,
219+
"schema": {
220+
"$ref": "#/definitions/cistore.GroupData"
221+
}
202222
}
203223
],
204224
"responses": {
@@ -360,6 +380,15 @@
360380
"name": "id",
361381
"in": "path",
362382
"required": true
383+
},
384+
{
385+
"description": "Instance info data",
386+
"name": "instance-info",
387+
"in": "body",
388+
"required": true,
389+
"schema": {
390+
"$ref": "#/definitions/cistore.OpenCHAMIInstanceInfo"
391+
}
363392
}
364393
],
365394
"responses": {
@@ -684,6 +713,54 @@
684713
}
685714
}
686715
},
716+
"cistore.OpenCHAMIInstanceInfo": {
717+
"type": "object",
718+
"properties": {
719+
"availability-zone": {
720+
"type": "string"
721+
},
722+
"cloud-init-base-url": {
723+
"type": "string"
724+
},
725+
"cloud-provider": {
726+
"type": "string"
727+
},
728+
"cluster-name": {
729+
"type": "string",
730+
"example": "demo"
731+
},
732+
"hostname": {
733+
"type": "string"
734+
},
735+
"id": {
736+
"type": "string",
737+
"example": "x3000c1b1n1"
738+
},
739+
"instance-id": {
740+
"type": "string"
741+
},
742+
"instance-type": {
743+
"type": "string"
744+
},
745+
"local-hostname": {
746+
"type": "string",
747+
"example": "compute-1"
748+
},
749+
"public-keys": {
750+
"type": "array",
751+
"items": {
752+
"type": "string"
753+
},
754+
"example": [
755+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMLtQNuzGcMDatF+YVMMkuxbX2c5v2OxWftBhEVfFb+U user1@demo-head",
756+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB4vVRvkzmGE5PyWX2fuzJEgEfET4PRLHXCnD1uFZ8ZL user2@demo-head"
757+
]
758+
},
759+
"region": {
760+
"type": "string"
761+
}
762+
}
763+
},
687764
"main.Group": {
688765
"type": "object",
689766
"additionalProperties": true

docs/swagger.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,41 @@ definitions:
6060
example: compute
6161
type: string
6262
type: object
63+
cistore.OpenCHAMIInstanceInfo:
64+
properties:
65+
availability-zone:
66+
type: string
67+
cloud-init-base-url:
68+
type: string
69+
cloud-provider:
70+
type: string
71+
cluster-name:
72+
example: demo
73+
type: string
74+
hostname:
75+
type: string
76+
id:
77+
example: x3000c1b1n1
78+
type: string
79+
instance-id:
80+
type: string
81+
instance-type:
82+
type: string
83+
local-hostname:
84+
example: compute-1
85+
type: string
86+
public-keys:
87+
example:
88+
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMLtQNuzGcMDatF+YVMMkuxbX2c5v2OxWftBhEVfFb+U
89+
user1@demo-head
90+
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB4vVRvkzmGE5PyWX2fuzJEgEfET4PRLHXCnD1uFZ8ZL
91+
user2@demo-head
92+
items:
93+
type: string
94+
type: array
95+
region:
96+
type: string
97+
type: object
6398
main.Group:
6499
additionalProperties: true
65100
type: object
@@ -213,6 +248,13 @@ paths:
213248
consumes:
214249
- application/json
215250
description: Set default meta-data values for cluster.
251+
parameters:
252+
- description: Cluster defaults data
253+
in: body
254+
name: data
255+
required: true
256+
schema:
257+
$ref: '#/definitions/cistore.ClusterDefaults'
216258
responses:
217259
"201":
218260
description: Created
@@ -341,6 +383,12 @@ paths:
341383
name: name
342384
required: true
343385
type: string
386+
- description: Group data
387+
in: body
388+
name: group_data
389+
required: true
390+
schema:
391+
$ref: '#/definitions/cistore.GroupData'
344392
responses:
345393
"201":
346394
description: Created
@@ -469,6 +517,12 @@ paths:
469517
name: id
470518
required: true
471519
type: string
520+
- description: Instance info data
521+
in: body
522+
name: instance-info
523+
required: true
524+
schema:
525+
$ref: '#/definitions/cistore.OpenCHAMIInstanceInfo'
472526
responses:
473527
"201":
474528
description: Created

0 commit comments

Comments
 (0)