add docs for update donate page
This commit is contained in:
parent
526aced06f
commit
ff4830d144
10
cmd/main.go
10
cmd/main.go
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"donat-widget/internal/app/http"
|
||||
"donat-widget/internal/config"
|
||||
"donat-widget/internal/docs"
|
||||
"donat-widget/pkg/logger"
|
||||
)
|
||||
|
||||
@ -23,9 +24,18 @@ import (
|
||||
WidgetService "donat-widget/internal/service/widget"
|
||||
)
|
||||
|
||||
// @title Donate Auth Documentation
|
||||
// @version 3.0
|
||||
// @description Donate auth service docs.
|
||||
// @BasePath /api/donat-wiget
|
||||
// @securityDefinitions.apikey BearerAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
|
||||
func main() {
|
||||
logger.New()
|
||||
cfg := config.Init()
|
||||
docs.SwaggerInfo.Host = cfg.HOST
|
||||
|
||||
// INFRASTRUCTURE
|
||||
db := pg.NewPgPool(context.Background(), cfg.Db.Username, cfg.Db.Password, cfg.Db.Host, cfg.Db.Port, cfg.Db.DBName)
|
||||
|
@ -129,6 +129,19 @@ func GetOuterDonatePage(donatService model.DonatService) echo.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateDonatePage godoc
|
||||
// @Summary Update personal streamer donate page.
|
||||
// @Description Update personal streamer donate page.
|
||||
// @Tags Donate
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.UpdateDonatPage true "Update fields"
|
||||
// @Param background formData file false "Background image"
|
||||
// @Success 200 {string} string "Donat page updated successfully"
|
||||
// @Failure 400 {object} echo.HTTPError "Bad request"
|
||||
// @Failure 401 {object} echo.HTTPError "Unauthorized or expired token"
|
||||
// @Failure 422 {object} echo.HTTPError "Validation error"
|
||||
// @Router /donat-page [patch]
|
||||
func UpdateDonatePage(donatService model.DonatService) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return nil
|
||||
|
@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
|
||||
"donat-widget/internal/model/sql"
|
||||
"github.com/labstack/echo/v4"
|
||||
@ -30,8 +31,21 @@ func NewApp(
|
||||
authClient model.AuthClient,
|
||||
) {
|
||||
server := echo.New()
|
||||
|
||||
server.Use(
|
||||
middleware.CORSWithConfig(
|
||||
middleware.CORSConfig{
|
||||
AllowOrigins: []string{"*"}, // Разрешить все домены
|
||||
AllowMethods: []string{"*"},
|
||||
AllowHeaders: []string{"*"},
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
server.Validator = validator.NewValidator()
|
||||
|
||||
server.GET(PREFIX+"/docs/*", echoSwagger.WrapHandler)
|
||||
|
||||
server.GET(PREFIX+"/docs/*", echoSwagger.WrapHandler)
|
||||
server.GET(PREFIX+"/table/create", CreateTale(db))
|
||||
server.GET(PREFIX+"/table/drop", DropTale(db))
|
||||
|
127
internal/docs/docs.go
Normal file
127
internal/docs/docs.go
Normal file
@ -0,0 +1,127 @@
|
||||
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"contact": {},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/donat-page": {
|
||||
"patch": {
|
||||
"description": "Update personal streamer donate page.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Donate"
|
||||
],
|
||||
"summary": "Update personal streamer donate page.",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Update fields",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/donat-widget_internal_model.UpdateDonatPage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Background image",
|
||||
"name": "background",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Donat page updated successfully",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized or expired token",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"donat-widget_internal_model.UpdateDonatPage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"pageBackground": {
|
||||
"type": "string"
|
||||
},
|
||||
"profileAvatar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"textAfterDonat": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"echo.HTTPError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"BearerAuth": {
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "3.0",
|
||||
Host: "",
|
||||
BasePath: "/api/donat-wiget",
|
||||
Schemes: []string{},
|
||||
Title: "Donate Auth Documentation",
|
||||
Description: "Donate auth service docs.",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
LeftDelim: "{{",
|
||||
RightDelim: "}}",
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
102
internal/docs/swagger.json
Normal file
102
internal/docs/swagger.json
Normal file
@ -0,0 +1,102 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Donate auth service docs.",
|
||||
"title": "Donate Auth Documentation",
|
||||
"contact": {},
|
||||
"version": "3.0"
|
||||
},
|
||||
"basePath": "/api/donat-wiget",
|
||||
"paths": {
|
||||
"/donat-page": {
|
||||
"patch": {
|
||||
"description": "Update personal streamer donate page.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Donate"
|
||||
],
|
||||
"summary": "Update personal streamer donate page.",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Update fields",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/donat-widget_internal_model.UpdateDonatPage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"description": "Background image",
|
||||
"name": "background",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Donat page updated successfully",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized or expired token",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/echo.HTTPError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"donat-widget_internal_model.UpdateDonatPage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"pageBackground": {
|
||||
"type": "string"
|
||||
},
|
||||
"profileAvatar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"textAfterDonat": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"echo.HTTPError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"BearerAuth": {
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
}
|
||||
}
|
||||
}
|
67
internal/docs/swagger.yaml
Normal file
67
internal/docs/swagger.yaml
Normal file
@ -0,0 +1,67 @@
|
||||
basePath: /api/donat-wiget
|
||||
definitions:
|
||||
donat-widget_internal_model.UpdateDonatPage:
|
||||
properties:
|
||||
description:
|
||||
type: string
|
||||
pageBackground:
|
||||
type: string
|
||||
profileAvatar:
|
||||
type: boolean
|
||||
textAfterDonat:
|
||||
type: string
|
||||
type: object
|
||||
echo.HTTPError:
|
||||
properties:
|
||||
message: {}
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
description: Donate auth service docs.
|
||||
title: Donate Auth Documentation
|
||||
version: "3.0"
|
||||
paths:
|
||||
/donat-page:
|
||||
patch:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update personal streamer donate page.
|
||||
parameters:
|
||||
- description: Update fields
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/donat-widget_internal_model.UpdateDonatPage'
|
||||
- description: Background image
|
||||
in: formData
|
||||
name: background
|
||||
type: file
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Donat page updated successfully
|
||||
schema:
|
||||
type: string
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/echo.HTTPError'
|
||||
"401":
|
||||
description: Unauthorized or expired token
|
||||
schema:
|
||||
$ref: '#/definitions/echo.HTTPError'
|
||||
"422":
|
||||
description: Validation error
|
||||
schema:
|
||||
$ref: '#/definitions/echo.HTTPError'
|
||||
summary: Update personal streamer donate page.
|
||||
tags:
|
||||
- Donate
|
||||
securityDefinitions:
|
||||
BearerAuth:
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
swagger: "2.0"
|
@ -52,6 +52,13 @@ type Target struct {
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
type UpdateDonatPage struct {
|
||||
ProfileAvatar bool `json:"profileAvatar"`
|
||||
Description string `json:"description"`
|
||||
TextAfterDonat string `json:"textAfterDonat"`
|
||||
PageBackground string `json:"pageBackground"`
|
||||
}
|
||||
|
||||
type DonatAndWidget struct {
|
||||
Widget *Widget
|
||||
Donat *Donat
|
||||
|
Loading…
x
Reference in New Issue
Block a user