Add missing bad request / not found definitions

This commit is contained in:
Jannis Mattheis 2018-11-24 10:52:43 +01:00
parent dfb71dabbc
commit 9e7859c36c
6 changed files with 290 additions and 0 deletions

View File

@ -54,6 +54,10 @@ type ApplicationAPI struct {
// description: Ok
// schema:
// $ref: "#/definitions/Application"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -129,6 +133,10 @@ func (a *ApplicationAPI) GetApplications(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -137,6 +145,10 @@ func (a *ApplicationAPI) GetApplications(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *ApplicationAPI) DeleteApplication(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if app := a.DB.GetApplicationByID(id); app != nil && app.UserID == auth.GetUserID(ctx) {
@ -191,6 +203,10 @@ func (a *ApplicationAPI) DeleteApplication(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if app := a.DB.GetApplicationByID(id); app != nil && app.UserID == auth.GetUserID(ctx) {
@ -238,6 +254,10 @@ func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
// description: Ok
// schema:
// $ref: "#/definitions/Application"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -246,6 +266,14 @@ func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
// 500:
// description: Server Error
// schema:
// $ref: "#/definitions/Error"
func (a *ApplicationAPI) UploadApplicationImage(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if app := a.DB.GetApplicationByID(id); app != nil && app.UserID == auth.GetUserID(ctx) {

View File

@ -48,6 +48,10 @@ type ClientAPI struct {
// description: Ok
// schema:
// $ref: "#/definitions/Client"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -120,6 +124,10 @@ func (a *ClientAPI) GetClients(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -128,6 +136,10 @@ func (a *ClientAPI) GetClients(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *ClientAPI) DeleteClient(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if client := a.DB.GetClientByID(id); client != nil && client.UserID == auth.GetUserID(ctx) {

View File

@ -76,6 +76,10 @@ type pagingParams struct {
// description: Ok
// schema:
// $ref: "#/definitions/PagedMessages"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -157,6 +161,10 @@ func withPaging(ctx *gin.Context, f func(pagingParams *pagingParams)) {
// description: Ok
// schema:
// $ref: "#/definitions/PagedMessages"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -165,6 +173,10 @@ func withPaging(ctx *gin.Context, f func(pagingParams *pagingParams)) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
withPaging(ctx, func(params *pagingParams) {
@ -226,6 +238,10 @@ func (a *MessageAPI) DeleteMessages(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -234,6 +250,10 @@ func (a *MessageAPI) DeleteMessages(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if application := a.DB.GetApplicationByID(id); application != nil && application.UserID == auth.GetUserID(ctx) {
@ -264,6 +284,10 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -272,6 +296,10 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *MessageAPI) DeleteMessage(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if msg := a.DB.GetMessageByID(id); msg != nil && a.DB.GetApplicationByID(msg.ApplicationID).UserID == auth.GetUserID(ctx) {
@ -304,10 +332,18 @@ func (a *MessageAPI) DeleteMessage(ctx *gin.Context) {
// description: Ok
// schema:
// $ref: "#/definitions/Message"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
// $ref: "#/definitions/Error"
// 403:
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
func (a *MessageAPI) CreateMessage(ctx *gin.Context) {
message := model.Message{}
if err := ctx.Bind(&message); err == nil {

View File

@ -133,6 +133,10 @@ func (a *API) register(client *client) {
// description: Ok
// schema:
// $ref: "#/definitions/Message"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -141,6 +145,10 @@ func (a *API) register(client *client) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 500:
// description: Server Error
// schema:
// $ref: "#/definitions/Error"
func (a *API) Handle(ctx *gin.Context) {
conn, err := upgrader.Upgrade(ctx.Writer, ctx.Request, nil)
if err != nil {

View File

@ -116,6 +116,10 @@ func (a *UserAPI) GetCurrentUser(ctx *gin.Context) {
// description: Ok
// schema:
// $ref: "#/definitions/User"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -160,6 +164,10 @@ func (a *UserAPI) CreateUser(ctx *gin.Context) {
// description: Ok
// schema:
// $ref: "#/definitions/User"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -168,6 +176,10 @@ func (a *UserAPI) CreateUser(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *UserAPI) GetUserByID(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if user := a.DB.GetUserByID(uint(id)); user != nil {
@ -198,6 +210,10 @@ func (a *UserAPI) GetUserByID(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -206,6 +222,10 @@ func (a *UserAPI) GetUserByID(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *UserAPI) DeleteUserByID(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
if user := a.DB.GetUserByID(id); user != nil {
@ -239,6 +259,10 @@ func (a *UserAPI) DeleteUserByID(ctx *gin.Context) {
// responses:
// 200:
// description: Ok
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -285,6 +309,10 @@ func (a *UserAPI) ChangePassword(ctx *gin.Context) {
// description: Ok
// schema:
// $ref: "#/definitions/User"
// 400:
// description: Bad Request
// schema:
// $ref: "#/definitions/Error"
// 401:
// description: Unauthorized
// schema:
@ -293,6 +321,10 @@ func (a *UserAPI) ChangePassword(ctx *gin.Context) {
// description: Forbidden
// schema:
// $ref: "#/definitions/Error"
// 404:
// description: Not Found
// schema:
// $ref: "#/definitions/Error"
func (a *UserAPI) UpdateUserByID(ctx *gin.Context) {
withID(ctx, "id", func(id uint) {
var user *model.UserExternalWithPass

View File

@ -110,6 +110,12 @@
"$ref": "#/definitions/Application"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -191,6 +197,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
@ -230,6 +242,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -241,6 +259,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -292,6 +316,12 @@
"$ref": "#/definitions/Application"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -303,6 +333,18 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
},
"500": {
"description": "Server Error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -360,6 +402,12 @@
"$ref": "#/definitions/PagedMessages"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -371,6 +419,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
@ -407,6 +461,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -418,6 +478,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -511,6 +577,12 @@
"$ref": "#/definitions/Client"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -563,6 +635,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -574,6 +652,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -660,6 +744,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -721,6 +811,12 @@
"$ref": "#/definitions/PagedMessages"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -774,11 +870,23 @@
"$ref": "#/definitions/Message"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/Error"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
@ -855,6 +963,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -866,6 +980,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -898,6 +1018,12 @@
"$ref": "#/definitions/Message"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -909,6 +1035,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"500": {
"description": "Server Error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
@ -999,6 +1131,12 @@
"$ref": "#/definitions/User"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -1054,6 +1192,12 @@
"$ref": "#/definitions/User"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -1065,6 +1209,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
@ -1116,6 +1266,12 @@
"$ref": "#/definitions/User"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -1127,6 +1283,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
@ -1163,6 +1325,12 @@
"200": {
"description": "Ok"
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/Error"
}
},
"401": {
"description": "Unauthorized",
"schema": {
@ -1174,6 +1342,12 @@
"schema": {
"$ref": "#/definitions/Error"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}