add documentation for applications

This commit is contained in:
Cubicroot 2021-09-30 19:56:46 +02:00
parent f9ae7f319a
commit b940b159a9

View file

@ -117,7 +117,8 @@ func (h *ApplicationHandler) updateApplication(ctx *gin.Context, a *model.Applic
// @Param name query string true "Name of the application"
// @Param strict_compatability query boolean false "Use strict compatability mode"
// @Success 200 {object} model.Application
// @Failure 400 {string} ""
// @Failure 400 {string} string ""
// @Security BasicAuth
// @Router /application [post]
func (h *ApplicationHandler) CreateApplication(ctx *gin.Context) {
var createApplication model.CreateApplication
@ -140,7 +141,14 @@ func (h *ApplicationHandler) CreateApplication(ctx *gin.Context) {
ctx.JSON(http.StatusOK, &application)
}
// GetApplications returns all applications of the current user.
// GetApplications godoc
// @Summary Get Applications
// @Description Get all applications from current user
// @Accept mpfd
// @Produce json
// @Success 200 {array} model.Application
// @Failure 500 {string} string ""
// @Router /application [get]
func (h *ApplicationHandler) GetApplications(ctx *gin.Context) {
user := authentication.GetUser(ctx)
if user == nil {
@ -155,7 +163,15 @@ func (h *ApplicationHandler) GetApplications(ctx *gin.Context) {
ctx.JSON(http.StatusOK, &applications)
}
// GetApplication returns the application with the specified ID.
// GetApplication godoc
// @Summary Get Application
// @Description Get single application by ID
// @Accept mpfd
// @Produce json
// @Param id path int true "ID of the application"
// @Success 200 {object} model.Application
// @Failure 404,403 {string} string ""
// @Router /application/{id} [get]
func (h *ApplicationHandler) GetApplication(ctx *gin.Context) {
application, err := getApplication(ctx, h.DB)
if err != nil {
@ -176,7 +192,15 @@ func (h *ApplicationHandler) GetApplication(ctx *gin.Context) {
ctx.JSON(http.StatusOK, &application)
}
// DeleteApplication deletes an application with a certain ID.
// DeleteApplication godoc
// @Summary Delete Application
// @Description Delete an application
// @Accept mpfd
// @Produce json
// @Param id path int true "ID of the application"
// @Success 200 {string} string ""
// @Failure 500,404,403 {string} string ""
// @Router /application/{id} [delete]
func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
application, err := getApplication(ctx, h.DB)
if err != nil {
@ -194,7 +218,18 @@ func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{})
}
// UpdateApplication updates an application with a certain ID.
// UpdateApplication godoc
// @Summary Update Application
// @Description Update an application
// @Accept mpfd
// @Produce json
// @Param id path int true "ID of the application"
// @Param name query string false "New name for the application"
// @Param refresh_token query bool false "Generate new refresh token for the application"
// @Param strict_compatability query bool false "Whether to use strict compataibility mode"
// @Success 200 {string} string ""
// @Failure 500,404,403,404 {string} string ""
// @Router /application/{id} [put]
func (h *ApplicationHandler) UpdateApplication(ctx *gin.Context) {
application, err := getApplication(ctx, h.DB)
if err != nil {