mirror of
https://github.com/pushbits/server.git
synced 2025-05-03 20:26:23 +02:00
add documentation for applications
This commit is contained in:
parent
f9ae7f319a
commit
b940b159a9
1 changed files with 40 additions and 5 deletions
|
@ -117,7 +117,8 @@ func (h *ApplicationHandler) updateApplication(ctx *gin.Context, a *model.Applic
|
||||||
// @Param name query string true "Name of the application"
|
// @Param name query string true "Name of the application"
|
||||||
// @Param strict_compatability query boolean false "Use strict compatability mode"
|
// @Param strict_compatability query boolean false "Use strict compatability mode"
|
||||||
// @Success 200 {object} model.Application
|
// @Success 200 {object} model.Application
|
||||||
// @Failure 400 {string} ""
|
// @Failure 400 {string} string ""
|
||||||
|
// @Security BasicAuth
|
||||||
// @Router /application [post]
|
// @Router /application [post]
|
||||||
func (h *ApplicationHandler) CreateApplication(ctx *gin.Context) {
|
func (h *ApplicationHandler) CreateApplication(ctx *gin.Context) {
|
||||||
var createApplication model.CreateApplication
|
var createApplication model.CreateApplication
|
||||||
|
@ -140,7 +141,14 @@ func (h *ApplicationHandler) CreateApplication(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, &application)
|
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) {
|
func (h *ApplicationHandler) GetApplications(ctx *gin.Context) {
|
||||||
user := authentication.GetUser(ctx)
|
user := authentication.GetUser(ctx)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
|
@ -155,7 +163,15 @@ func (h *ApplicationHandler) GetApplications(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, &applications)
|
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) {
|
func (h *ApplicationHandler) GetApplication(ctx *gin.Context) {
|
||||||
application, err := getApplication(ctx, h.DB)
|
application, err := getApplication(ctx, h.DB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -176,7 +192,15 @@ func (h *ApplicationHandler) GetApplication(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, &application)
|
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) {
|
func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
|
||||||
application, err := getApplication(ctx, h.DB)
|
application, err := getApplication(ctx, h.DB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -194,7 +218,18 @@ func (h *ApplicationHandler) DeleteApplication(ctx *gin.Context) {
|
||||||
ctx.JSON(http.StatusOK, gin.H{})
|
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) {
|
func (h *ApplicationHandler) UpdateApplication(ctx *gin.Context) {
|
||||||
application, err := getApplication(ctx, h.DB)
|
application, err := getApplication(ctx, h.DB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue