Add json tags to query structs (otherwise swag does not get the correct names)

This commit is contained in:
Mike Schwörer 2022-11-30 16:46:14 +01:00
parent 7a11b2c76f
commit b6e8d037a0
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
5 changed files with 163 additions and 163 deletions

View File

@ -515,7 +515,7 @@ func (h APIHandler) ListChannels(g *gin.Context) ginresp.HTTPResponse {
UserID models.UserID `uri:"uid"` UserID models.UserID `uri:"uid"`
} }
type query struct { type query struct {
Selector *string `form:"selector"` Selector *string `json:"selector" form:"selector"`
} }
type response struct { type response struct {
Channels []models.ChannelJSON `json:"channels"` Channels []models.ChannelJSON `json:"channels"`
@ -720,10 +720,10 @@ func (h APIHandler) ListChannelMessages(g *gin.Context) ginresp.HTTPResponse {
ChannelID models.ChannelID `uri:"cid"` ChannelID models.ChannelID `uri:"cid"`
} }
type query struct { type query struct {
PageSize *int `form:"page_size"` PageSize *int `json:"page_size" form:"page_size"`
NextPageToken *string `form:"next_page_token"` NextPageToken *string `json:"next_page_token" form:"next_page_token"`
Filter *string `form:"filter"` Filter *string `json:"filter" form:"filter"`
Trimmed *bool `form:"trimmed"` Trimmed *bool `json:"trimmed" form:"trimmed"`
} }
type response struct { type response struct {
Messages []models.MessageJSON `json:"messages"` Messages []models.MessageJSON `json:"messages"`
@ -1015,7 +1015,7 @@ func (h APIHandler) CreateSubscription(g *gin.Context) ginresp.HTTPResponse {
Channel string `form:"channel_name" binding:"required"` Channel string `form:"channel_name" binding:"required"`
} }
type query struct { type query struct {
ChanSubscribeKey *string `form:"chan_subscribe_key"` ChanSubscribeKey *string `json:"chan_subscribe_key" form:"chan_subscribe_key"`
} }
var u uri var u uri
@ -1136,10 +1136,10 @@ func (h APIHandler) UpdateSubscription(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/messages [GET] // @Router /api/messages [GET]
func (h APIHandler) ListMessages(g *gin.Context) ginresp.HTTPResponse { func (h APIHandler) ListMessages(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
PageSize *int `form:"page_size"` PageSize *int `json:"page_size" form:"page_size"`
NextPageToken *string `form:"next_page_token"` NextPageToken *string `json:"next_page_token" form:"next_page_token"`
Filter *string `form:"filter"` Filter *string `json:"filter" form:"filter"`
Trimmed *bool `form:"trimmed"` //TODO more filter (sender-name, channel, timestamps, prio, ) Trimmed *bool `json:"trimmed" form:"trimmed"` //TODO more filter (sender-name, channel, timestamps, prio, )
} }
type response struct { type response struct {
Messages []models.MessageJSON `json:"messages"` Messages []models.MessageJSON `json:"messages"`

View File

@ -46,9 +46,9 @@ func NewCompatHandler(app *logic.Application) CompatHandler {
// @Router /api/register.php [get] // @Router /api/register.php [get]
func (h CompatHandler) Register(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Register(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
FCMToken *string `form:"fcm_token"` FCMToken *string `json:"fcm_token" form:"fcm_token"`
Pro *string `form:"pro"` Pro *string `json:"pro" form:"pro"`
ProToken *string `form:"pro_token"` ProToken *string `json:"pro_token" form:"pro_token"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -152,8 +152,8 @@ func (h CompatHandler) Register(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/info.php [get] // @Router /api/info.php [get]
func (h CompatHandler) Info(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Info(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id" json:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key" json:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -238,9 +238,9 @@ func (h CompatHandler) Info(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/ack.php [get] // @Router /api/ack.php [get]
func (h CompatHandler) Ack(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Ack(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
MessageID *int64 `form:"scn_msg_id"` MessageID *int64 `json:"scn_msg_id" form:"scn_msg_id"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -309,8 +309,8 @@ func (h CompatHandler) Ack(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/requery.php [get] // @Router /api/requery.php [get]
func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -378,9 +378,9 @@ func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/update.php [get] // @Router /api/update.php [get]
func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
FCMToken *string `form:"fcm_token"` FCMToken *string `json:"fcm_token" form:"fcm_token"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -491,9 +491,9 @@ func (h CompatHandler) Update(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/expand.php [get] // @Router /api/expand.php [get]
func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
MessageID *int64 `form:"scn_msg_id"` MessageID *int64 `json:"scn_msg_id" form:"scn_msg_id"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -580,10 +580,10 @@ func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse {
// @Router /api/upgrade.php [get] // @Router /api/upgrade.php [get]
func (h CompatHandler) Upgrade(g *gin.Context) ginresp.HTTPResponse { func (h CompatHandler) Upgrade(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *int64 `form:"user_id"` UserID *int64 `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
Pro *string `form:"pro"` Pro *string `json:"pro" form:"pro"`
ProToken *string `form:"pro_token"` ProToken *string `json:"pro_token" form:"pro_token"`
} }
type response struct { type response struct {
Success bool `json:"success"` Success bool `json:"success"`

View File

@ -50,13 +50,13 @@ func NewMessageHandler(app *logic.Application) MessageHandler {
// @Router /send.php [POST] // @Router /send.php [POST]
func (h MessageHandler) SendMessageCompat(g *gin.Context) ginresp.HTTPResponse { func (h MessageHandler) SendMessageCompat(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *models.UserID `form:"user_id"` UserID *models.UserID `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
Title *string `form:"title"` Title *string `json:"title" form:"title"`
Content *string `form:"content"` Content *string `json:"content" form:"content"`
Priority *int `form:"priority"` Priority *int `json:"priority" form:"priority"`
UserMessageID *string `form:"msg_id"` UserMessageID *string `json:"msg_id" form:"msg_id"`
SendTimestamp *float64 `form:"timestamp"` SendTimestamp *float64 `json:"timestamp" form:"timestamp"`
} }
type form struct { type form struct {
UserID *models.UserID `form:"user_id"` UserID *models.UserID `form:"user_id"`
@ -102,16 +102,16 @@ func (h MessageHandler) SendMessageCompat(g *gin.Context) ginresp.HTTPResponse {
// @Router /send [POST] // @Router /send [POST]
func (h MessageHandler) SendMessage(g *gin.Context) ginresp.HTTPResponse { func (h MessageHandler) SendMessage(g *gin.Context) ginresp.HTTPResponse {
type query struct { type query struct {
UserID *models.UserID `form:"user_id"` UserID *models.UserID `json:"user_id" form:"user_id"`
UserKey *string `form:"user_key"` UserKey *string `json:"user_key" form:"user_key"`
Channel *string `form:"channel"` Channel *string `json:"channel" form:"channel"`
ChanKey *string `form:"chan_key"` ChanKey *string `json:"chan_key" form:"chan_key"`
Title *string `form:"title"` Title *string `json:"title" form:"title"`
Content *string `form:"content"` Content *string `json:"content" form:"content"`
Priority *int `form:"priority"` Priority *int `json:"priority" form:"priority"`
UserMessageID *string `form:"msg_id"` UserMessageID *string `json:"msg_id" form:"msg_id"`
SendTimestamp *float64 `form:"timestamp"` SendTimestamp *float64 `json:"timestamp" form:"timestamp"`
SenderName *string `form:"sender_name"` SenderName *string `json:"sender_name" form:"sender_name"`
} }
type body struct { type body struct {
UserID *models.UserID `json:"user_id"` UserID *models.UserID `json:"user_id"`

View File

@ -19,7 +19,7 @@
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"name": "chanKey", "name": "chan_key",
"in": "query" "in": "query"
}, },
{ {
@ -32,19 +32,24 @@
"name": "content", "name": "content",
"in": "query" "in": "query"
}, },
{
"type": "string",
"name": "msg_id",
"in": "query"
},
{ {
"type": "integer", "type": "integer",
"name": "priority", "name": "priority",
"in": "query" "in": "query"
}, },
{ {
"type": "number", "type": "string",
"name": "sendTimestamp", "name": "sender_name",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "number",
"name": "senderName", "name": "timestamp",
"in": "query" "in": "query"
}, },
{ {
@ -54,17 +59,12 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "userID", "name": "user_id",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"name": "userKey", "name": "user_key",
"in": "query"
},
{
"type": "string",
"name": "userMessageID",
"in": "query" "in": "query"
}, },
{ {
@ -394,12 +394,12 @@
}, },
{ {
"type": "string", "type": "string",
"name": "nextPageToken", "name": "next_page_token",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "pageSize", "name": "page_size",
"in": "query" "in": "query"
}, },
{ {
@ -1334,12 +1334,12 @@
}, },
{ {
"type": "string", "type": "string",
"name": "nextPageToken", "name": "next_page_token",
"in": "query" "in": "query"
}, },
{ {
"type": "integer", "type": "integer",
"name": "pageSize", "name": "page_size",
"in": "query" "in": "query"
}, },
{ {
@ -1557,13 +1557,15 @@
} }
} }
} }
}, }
"delete": { },
"/api/users/{uid}/clients/{cid}": {
"get": {
"tags": [ "tags": [
"API-v2" "API-v2"
], ],
"summary": "Delete a client", "summary": "Get a single client",
"operationId": "api-clients-delete", "operationId": "api-clients-get",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
@ -1612,15 +1614,13 @@
} }
} }
} }
} },
}, "delete": {
"/api/users/{uid}/clients/{cid}": {
"get": {
"tags": [ "tags": [
"API-v2" "API-v2"
], ],
"summary": "Get a single clients", "summary": "Delete a client",
"operationId": "api-clients-get", "operationId": "api-clients-delete",
"parameters": [ "parameters": [
{ {
"type": "integer", "type": "integer",
@ -1736,7 +1736,7 @@
}, },
{ {
"type": "string", "type": "string",
"name": "chanSubscribeKey", "name": "chan_subscribe_key",
"in": "query" "in": "query"
}, },
{ {
@ -1959,7 +1959,7 @@
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"name": "chanKey", "name": "chan_key",
"in": "query" "in": "query"
}, },
{ {
@ -1972,19 +1972,24 @@
"name": "content", "name": "content",
"in": "query" "in": "query"
}, },
{
"type": "string",
"name": "msg_id",
"in": "query"
},
{ {
"type": "integer", "type": "integer",
"name": "priority", "name": "priority",
"in": "query" "in": "query"
}, },
{ {
"type": "number", "type": "string",
"name": "sendTimestamp", "name": "sender_name",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "number",
"name": "senderName", "name": "timestamp",
"in": "query" "in": "query"
}, },
{ {
@ -1994,17 +1999,12 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "userID", "name": "user_id",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"name": "userKey", "name": "user_key",
"in": "query"
},
{
"type": "string",
"name": "userMessageID",
"in": "query" "in": "query"
}, },
{ {
@ -2114,6 +2114,11 @@
"name": "content", "name": "content",
"in": "query" "in": "query"
}, },
{
"type": "string",
"name": "msg_id",
"in": "query"
},
{ {
"type": "integer", "type": "integer",
"name": "priority", "name": "priority",
@ -2121,7 +2126,7 @@
}, },
{ {
"type": "number", "type": "number",
"name": "sendTimestamp", "name": "timestamp",
"in": "query" "in": "query"
}, },
{ {
@ -2131,17 +2136,12 @@
}, },
{ {
"type": "integer", "type": "integer",
"name": "userID", "name": "user_id",
"in": "query" "in": "query"
}, },
{ {
"type": "string", "type": "string",
"name": "userKey", "name": "user_key",
"in": "query"
},
{
"type": "string",
"name": "userMessageID",
"in": "query" "in": "query"
}, },
{ {

View File

@ -491,7 +491,7 @@ paths:
Only UserID, UserKey and Title are required Only UserID, UserKey and Title are required
parameters: parameters:
- in: query - in: query
name: chanKey name: chan_key
type: string type: string
- in: query - in: query
name: channel name: channel
@ -499,26 +499,26 @@ paths:
- in: query - in: query
name: content name: content
type: string type: string
- in: query
name: msg_id
type: string
- in: query - in: query
name: priority name: priority
type: integer type: integer
- in: query - in: query
name: sendTimestamp name: sender_name
type: number
- in: query
name: senderName
type: string type: string
- in: query
name: timestamp
type: number
- in: query - in: query
name: title name: title
type: string type: string
- in: query - in: query
name: userID name: user_id
type: integer type: integer
- in: query - in: query
name: userKey name: user_key
type: string
- in: query
name: userMessageID
type: string type: string
- description: ' ' - description: ' '
in: body in: body
@ -742,10 +742,10 @@ paths:
name: filter name: filter
type: string type: string
- in: query - in: query
name: nextPageToken name: next_page_token
type: string type: string
- in: query - in: query
name: pageSize name: page_size
type: integer type: integer
- description: TODO more filter (sender-name, channel, timestamps, prio, ) - description: TODO more filter (sender-name, channel, timestamps, prio, )
in: query in: query
@ -1386,10 +1386,10 @@ paths:
name: filter name: filter
type: string type: string
- in: query - in: query
name: nextPageToken name: next_page_token
type: string type: string
- in: query - in: query
name: pageSize name: page_size
type: integer type: integer
- in: query - in: query
name: trimmed name: trimmed
@ -1467,43 +1467,6 @@ paths:
tags: tags:
- API-v2 - API-v2
/api/users/{uid}/clients: /api/users/{uid}/clients:
delete:
operationId: api-clients-delete
parameters:
- description: UserID
in: path
name: uid
required: true
type: integer
- description: ClientID
in: path
name: cid
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.ClientJSON'
"400":
description: Bad Request
schema:
$ref: '#/definitions/ginresp.apiError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/ginresp.apiError'
"404":
description: Not Found
schema:
$ref: '#/definitions/ginresp.apiError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/ginresp.apiError'
summary: Delete a client
tags:
- API-v2
get: get:
operationId: api-clients-list operationId: api-clients-list
parameters: parameters:
@ -1574,6 +1537,43 @@ paths:
tags: tags:
- API-v2 - API-v2
/api/users/{uid}/clients/{cid}: /api/users/{uid}/clients/{cid}:
delete:
operationId: api-clients-delete
parameters:
- description: UserID
in: path
name: uid
required: true
type: integer
- description: ClientID
in: path
name: cid
required: true
type: integer
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.ClientJSON'
"400":
description: Bad Request
schema:
$ref: '#/definitions/ginresp.apiError'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/ginresp.apiError'
"404":
description: Not Found
schema:
$ref: '#/definitions/ginresp.apiError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/ginresp.apiError'
summary: Delete a client
tags:
- API-v2
get: get:
operationId: api-clients-get operationId: api-clients-get
parameters: parameters:
@ -1608,7 +1608,7 @@ paths:
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: '#/definitions/ginresp.apiError' $ref: '#/definitions/ginresp.apiError'
summary: Get a single clients summary: Get a single client
tags: tags:
- API-v2 - API-v2
/api/users/{uid}/subscriptions: /api/users/{uid}/subscriptions:
@ -1653,7 +1653,7 @@ paths:
required: true required: true
type: integer type: integer
- in: query - in: query
name: chanSubscribeKey name: chan_subscribe_key
type: string type: string
- description: ' ' - description: ' '
in: body in: body
@ -1802,7 +1802,7 @@ paths:
Only UserID, UserKey and Title are required Only UserID, UserKey and Title are required
parameters: parameters:
- in: query - in: query
name: chanKey name: chan_key
type: string type: string
- in: query - in: query
name: channel name: channel
@ -1810,26 +1810,26 @@ paths:
- in: query - in: query
name: content name: content
type: string type: string
- in: query
name: msg_id
type: string
- in: query - in: query
name: priority name: priority
type: integer type: integer
- in: query - in: query
name: sendTimestamp name: sender_name
type: number
- in: query
name: senderName
type: string type: string
- in: query
name: timestamp
type: number
- in: query - in: query
name: title name: title
type: string type: string
- in: query - in: query
name: userID name: user_id
type: integer type: integer
- in: query - in: query
name: userKey name: user_key
type: string
- in: query
name: userMessageID
type: string type: string
- description: ' ' - description: ' '
in: body in: body
@ -1900,23 +1900,23 @@ paths:
- in: query - in: query
name: content name: content
type: string type: string
- in: query
name: msg_id
type: string
- in: query - in: query
name: priority name: priority
type: integer type: integer
- in: query - in: query
name: sendTimestamp name: timestamp
type: number type: number
- in: query - in: query
name: title name: title
type: string type: string
- in: query - in: query
name: userID name: user_id
type: integer type: integer
- in: query - in: query
name: userKey name: user_key
type: string
- in: query
name: userMessageID
type: string type: string
- in: formData - in: formData
name: content name: content