fixes swagger documentation

* create groups endpoint was missing some information
This commit is contained in:
Bernhard B
2021-03-20 20:01:08 +01:00
parent b9ff3062bd
commit d9cbc9d985
4 changed files with 77 additions and 15 deletions

View File

@@ -40,6 +40,11 @@ type GroupEntry struct {
InviteLink string `json:"invite_link"` InviteLink string `json:"invite_link"`
} }
type CreateGroupRequest struct {
Name string `json:"name"`
Members []string `json:"members"`
}
type LoggingConfiguration struct { type LoggingConfiguration struct {
Level string `json:"Level"` Level string `json:"Level"`
} }
@@ -100,7 +105,7 @@ type About struct {
BuildNr int `json:"build"` BuildNr int `json:"build"`
} }
type CreateGroup struct { type CreateGroupResponse struct {
Id string `json:"id"` Id string `json:"id"`
} }
@@ -632,19 +637,15 @@ func (a *Api) Receive(c *gin.Context) {
// @Description Create a new Signal Group with the specified members. // @Description Create a new Signal Group with the specified members.
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 201 {object} CreateGroup // @Success 201 {object} CreateGroupResponse
// @Failure 400 {object} Error // @Failure 400 {object} Error
// @Param data body CreateGroupRequest true "Input Data"
// @Param number path string true "Registered Phone Number" // @Param number path string true "Registered Phone Number"
// @Router /v1/groups/{number} [post] // @Router /v1/groups/{number} [post]
func (a *Api) CreateGroup(c *gin.Context) { func (a *Api) CreateGroup(c *gin.Context) {
number := c.Param("number") number := c.Param("number")
type Request struct { var req CreateGroupRequest
Name string `json:"name"`
Members []string `json:"members"`
}
var req Request
err := c.BindJSON(&req) err := c.BindJSON(&req)
if err != nil { if err != nil {
c.JSON(400, gin.H{"error": "Couldn't process request - invalid request"}) c.JSON(400, gin.H{"error": "Couldn't process request - invalid request"})
@@ -666,7 +667,7 @@ func (a *Api) CreateGroup(c *gin.Context) {
} }
internalGroupId := getStringInBetween(out, `"`, `"`) internalGroupId := getStringInBetween(out, `"`, `"`)
c.JSON(201, CreateGroup{Id: convertInternalGroupIdToGroupId(internalGroupId)}) c.JSON(201, CreateGroupResponse{Id: convertInternalGroupIdToGroupId(internalGroupId)})
} }
// @Summary List all Signal Groups. // @Summary List all Signal Groups.

View File

@@ -262,6 +262,15 @@ var doc = `{
], ],
"summary": "Create a new Signal Group.", "summary": "Create a new Signal Group.",
"parameters": [ "parameters": [
{
"description": "Input Data",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api.CreateGroupRequest"
}
},
{ {
"type": "string", "type": "string",
"description": "Registered Phone Number", "description": "Registered Phone Number",
@@ -274,7 +283,7 @@ var doc = `{
"201": { "201": {
"description": "Created", "description": "Created",
"schema": { "schema": {
"$ref": "#/definitions/api.CreateGroup" "$ref": "#/definitions/api.CreateGroupResponse"
} }
}, },
"400": { "400": {
@@ -932,7 +941,21 @@ var doc = `{
} }
} }
}, },
"api.CreateGroup": { "api.CreateGroupRequest": {
"type": "object",
"properties": {
"members": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
}
}
},
"api.CreateGroupResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {

View File

@@ -247,6 +247,15 @@
], ],
"summary": "Create a new Signal Group.", "summary": "Create a new Signal Group.",
"parameters": [ "parameters": [
{
"description": "Input Data",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api.CreateGroupRequest"
}
},
{ {
"type": "string", "type": "string",
"description": "Registered Phone Number", "description": "Registered Phone Number",
@@ -259,7 +268,7 @@
"201": { "201": {
"description": "Created", "description": "Created",
"schema": { "schema": {
"$ref": "#/definitions/api.CreateGroup" "$ref": "#/definitions/api.CreateGroupResponse"
} }
}, },
"400": { "400": {
@@ -917,7 +926,21 @@
} }
} }
}, },
"api.CreateGroup": { "api.CreateGroupRequest": {
"type": "object",
"properties": {
"members": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
}
}
},
"api.CreateGroupResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": { "id": {

View File

@@ -15,7 +15,16 @@ definitions:
$ref: '#/definitions/api.LoggingConfiguration' $ref: '#/definitions/api.LoggingConfiguration'
type: object type: object
type: object type: object
api.CreateGroup: api.CreateGroupRequest:
properties:
members:
items:
type: string
type: array
name:
type: string
type: object
api.CreateGroupResponse:
properties: properties:
id: id:
type: string type: string
@@ -283,6 +292,12 @@ paths:
- application/json - application/json
description: Create a new Signal Group with the specified members. description: Create a new Signal Group with the specified members.
parameters: parameters:
- description: Input Data
in: body
name: data
required: true
schema:
$ref: '#/definitions/api.CreateGroupRequest'
- description: Registered Phone Number - description: Registered Phone Number
in: path in: path
name: number name: number
@@ -294,7 +309,7 @@ paths:
"201": "201":
description: Created description: Created
schema: schema:
$ref: '#/definitions/api.CreateGroup' $ref: '#/definitions/api.CreateGroupResponse'
"400": "400":
description: Bad Request description: Bad Request
schema: schema: