Compare commits

...

2 Commits

Author SHA1 Message Date
8d8bfa3db5 Merge branch 'develop' of ssh://git.asnk.io/nixcn/nixcn-cms into develop
All checks were successful
Client CMS Check Build (NixCN CMS) TeamCity build finished
Backend Check Build (NixCN CMS) TeamCity build finished
2026-01-29 10:20:42 +08:00
220b4d2ea3 Optimize swagger
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-01-29 10:19:34 +08:00
17 changed files with 205 additions and 161 deletions

View File

@@ -10,17 +10,17 @@ import (
) )
// Exchange handles the authorization code swap process. // Exchange handles the authorization code swap process.
// @Summary Exchange Auth Code // @Summary Exchange Auth Code
// @Description Exchanges client credentials and user session for a specific redirect authorization code. // @Description Exchanges client credentials and user session for a specific redirect authorization code.
// @Tags Authentication // @Tags Authentication
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_auth.ExchangeData true "Exchange Request Credentials" // @Param payload body service_auth.ExchangeData true "Exchange Request Credentials"
// @Success 200 {object} utils.RespStatus{data=service_auth.ExchangeResponse} "Successful exchange" // @Success 200 {object} utils.RespStatus{data=service_auth.ExchangeResponse} "Successful exchange"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 401 {object} utils.RespStatus{data=nil} "Unauthorized" // @Failure 401 {object} utils.RespStatus{data=nil} "Unauthorized"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Router /auth/exchange [post] // @Router /auth/exchange [post]
func (self *AuthHandler) Exchange(c *gin.Context) { func (self *AuthHandler) Exchange(c *gin.Context) {
var exchangeData service_auth.ExchangeData var exchangeData service_auth.ExchangeData

View File

@@ -9,17 +9,17 @@ import (
) )
// Magic handles the "Magic Link" authentication request. // Magic handles the "Magic Link" authentication request.
// @Summary Request Magic Link // @Summary Request Magic Link
// @Description Verifies Turnstile token and sends an authentication link via email. Returns the URI directly if debug mode is enabled. // @Description Verifies Turnstile token and sends an authentication link via email. Returns the URI directly if debug mode is enabled.
// @Tags Authentication // @Tags Authentication
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_auth.MagicData true "Magic Link Request Data" // @Param payload body service_auth.MagicData true "Magic Link Request Data"
// @Success 200 {object} utils.RespStatus{data=service_auth.MagicResponse} "Successful request" // @Success 200 {object} utils.RespStatus{data=service_auth.MagicResponse} "Successful request"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 403 {object} utils.RespStatus{data=nil} "Turnstile Verification Failed" // @Failure 403 {object} utils.RespStatus{data=nil} "Turnstile Verification Failed"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Router /auth/magic [post] // @Router /auth/magic [post]
func (self *AuthHandler) Magic(c *gin.Context) { func (self *AuthHandler) Magic(c *gin.Context) {
var magicData service_auth.MagicData var magicData service_auth.MagicData

View File

@@ -9,21 +9,21 @@ import (
) )
// Redirect handles the post-verification callback and redirects the user to the target application. // Redirect handles the post-verification callback and redirects the user to the target application.
// @Summary Handle Auth Callback and Redirect // @Summary Handle Auth Callback and Redirect
// @Description Verifies the temporary email code, ensures the user exists (or creates one), validates the client's redirect URI, and finally performs a 302 redirect with a new authorization code. // @Description Verifies the temporary email code, ensures the user exists (or creates one), validates the client's redirect URI, and finally performs a 302 redirect with a new authorization code.
// @Tags Authentication // @Tags Authentication
// @Accept x-www-form-urlencoded // @Accept x-www-form-urlencoded
// @Produce json // @Produce json
// @Produce html // @Produce html
// @Param client_id query string true "Client Identifier" // @Param client_id query string true "Client Identifier"
// @Param redirect_uri query string true "Target Redirect URI" // @Param redirect_uri query string true "Target Redirect URI"
// @Param code query string true "Temporary Verification Code" // @Param code query string true "Temporary Verification Code"
// @Param state query string false "Opaque state used to maintain state between the request and callback" // @Param state query string false "Opaque state used to maintain state between the request and callback"
// @Success 302 {string} string "Redirect to the provided RedirectUri with a new code" // @Success 302 {string} string "Redirect to the provided RedirectUri with a new code"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input / Client Not Found / URI Mismatch" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input / Client Not Found / URI Mismatch"
// @Failure 403 {object} utils.RespStatus{data=nil} "Invalid or Expired Verification Code" // @Failure 403 {object} utils.RespStatus{data=nil} "Invalid or Expired Verification Code"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Router /auth/redirect [get] // @Router /auth/redirect [get]
func (self *AuthHandler) Redirect(c *gin.Context) { func (self *AuthHandler) Redirect(c *gin.Context) {
data := &service_auth.RedirectData{ data := &service_auth.RedirectData{
ClientId: c.Query("client_id"), ClientId: c.Query("client_id"),

View File

@@ -9,17 +9,17 @@ import (
) )
// Refresh handles the token rotation process. // Refresh handles the token rotation process.
// @Summary Refresh Access Token // @Summary Refresh Access Token
// @Description Accepts a valid refresh token to issue a new access token and a rotated refresh token. // @Description Accepts a valid refresh token to issue a new access token and a rotated refresh token.
// @Tags Authentication // @Tags Authentication
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_auth.RefreshData true "Refresh Token Body" // @Param payload body service_auth.RefreshData true "Refresh Token Body"
// @Success 200 {object} utils.RespStatus{data=service_auth.TokenResponse} "Successful rotation" // @Success 200 {object} utils.RespStatus{data=service_auth.TokenResponse} "Successful rotation"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 401 {object} utils.RespStatus{data=nil} "Invalid Refresh Token" // @Failure 401 {object} utils.RespStatus{data=nil} "Invalid Refresh Token"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Router /auth/refresh [post] // @Router /auth/refresh [post]
func (self *AuthHandler) Refresh(c *gin.Context) { func (self *AuthHandler) Refresh(c *gin.Context) {
var refreshData service_auth.RefreshData var refreshData service_auth.RefreshData

View File

@@ -9,17 +9,17 @@ import (
) )
// Token exchanges an authorization code for access and refresh tokens. // Token exchanges an authorization code for access and refresh tokens.
// @Summary Exchange Code for Token // @Summary Exchange Code for Token
// @Description Verifies the provided authorization code and issues a pair of JWT tokens (Access and Refresh). // @Description Verifies the provided authorization code and issues a pair of JWT tokens (Access and Refresh).
// @Tags Authentication // @Tags Authentication
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_auth.TokenData true "Token Request Body" // @Param payload body service_auth.TokenData true "Token Request Body"
// @Success 200 {object} utils.RespStatus{data=service_auth.TokenResponse} "Successful token issuance" // @Success 200 {object} utils.RespStatus{data=service_auth.TokenResponse} "Successful token issuance"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 403 {object} utils.RespStatus{data=nil} "Invalid or Expired Code" // @Failure 403 {object} utils.RespStatus{data=nil} "Invalid or Expired Code"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Router /auth/token [post] // @Router /auth/token [post]
func (self *AuthHandler) Token(c *gin.Context) { func (self *AuthHandler) Token(c *gin.Context) {
var tokenData service_auth.TokenData var tokenData service_auth.TokenData

View File

@@ -10,17 +10,17 @@ import (
) )
// Checkin generates a check-in code for a specific event. // Checkin generates a check-in code for a specific event.
// @Summary Generate Check-in Code // @Summary Generate Check-in Code
// @Description Creates a temporary check-in code for the authenticated user and event. // @Description Creates a temporary check-in code for the authenticated user and event.
// @Tags Event // @Tags Event
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param event_id query string true "Event UUID" // @Param event_id query string true "Event UUID"
// @Success 200 {object} utils.RespStatus{data=service_event.CheckinResponse} "Successfully generated code" // @Success 200 {object} utils.RespStatus{data=service_event.CheckinResponse} "Successfully generated code"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /event/checkin [get] // @Router /event/checkin [get]
func (self *EventHandler) Checkin(c *gin.Context) { func (self *EventHandler) Checkin(c *gin.Context) {
userIdOrig, _ := c.Get("user_id") userIdOrig, _ := c.Get("user_id")
userId, _ := uuid.Parse(userIdOrig.(string)) userId, _ := uuid.Parse(userIdOrig.(string))
@@ -49,16 +49,16 @@ func (self *EventHandler) Checkin(c *gin.Context) {
} }
// CheckinSubmit validates a check-in code to complete attendance. // CheckinSubmit validates a check-in code to complete attendance.
// @Summary Submit Check-in Code // @Summary Submit Check-in Code
// @Description Submits the generated code to mark the user as attended. // @Description Submits the generated code to mark the user as attended.
// @Tags Event // @Tags Event
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_event.CheckinSubmitData true "Checkin Code Data" // @Param payload body service_event.CheckinSubmitData true "Checkin Code Data"
// @Success 200 {object} utils.RespStatus{data=nil} "Attendance marked successfully" // @Success 200 {object} utils.RespStatus{data=nil} "Attendance marked successfully"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Code or Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Code or Input"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /event/checkin/submit [post] // @Router /event/checkin/submit [post]
func (self *EventHandler) CheckinSubmit(c *gin.Context) { func (self *EventHandler) CheckinSubmit(c *gin.Context) {
var data service_event.CheckinSubmitData var data service_event.CheckinSubmitData
if err := c.ShouldBindJSON(&data); err != nil { if err := c.ShouldBindJSON(&data); err != nil {
@@ -82,17 +82,17 @@ func (self *EventHandler) CheckinSubmit(c *gin.Context) {
} }
// CheckinQuery retrieves the check-in status of a user for an event. // CheckinQuery retrieves the check-in status of a user for an event.
// @Summary Query Check-in Status // @Summary Query Check-in Status
// @Description Returns the timestamp of when the user checked in, or null if not yet checked in. // @Description Returns the timestamp of when the user checked in, or null if not yet checked in.
// @Tags Event // @Tags Event
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param event_id query string true "Event UUID" // @Param event_id query string true "Event UUID"
// @Success 200 {object} utils.RespStatus{data=service_event.CheckinQueryResponse} "Current attendance status" // @Success 200 {object} utils.RespStatus{data=service_event.CheckinQueryResponse} "Current attendance status"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 404 {object} utils.RespStatus{data=nil} "Record Not Found" // @Failure 404 {object} utils.RespStatus{data=nil} "Record Not Found"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /event/checkin/query [get] // @Router /event/checkin/query [get]
func (self *EventHandler) CheckinQuery(c *gin.Context) { func (self *EventHandler) CheckinQuery(c *gin.Context) {
userIdOrig, _ := c.Get("user_id") userIdOrig, _ := c.Get("user_id")
userId, _ := uuid.Parse(userIdOrig.(string)) userId, _ := uuid.Parse(userIdOrig.(string))

View File

@@ -10,18 +10,18 @@ import (
) )
// Info retrieves basic information about a specific event. // Info retrieves basic information about a specific event.
// @Summary Get Event Information // @Summary Get Event Information
// @Description Fetches the name, start time, and end time of an event using its UUID. // @Description Fetches the name, start time, and end time of an event using its UUID.
// @Tags Event // @Tags Event
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param event_id query string true "Event UUID" // @Param event_id query string true "Event UUID"
// @Success 200 {object} utils.RespStatus{data=service_event.InfoResponse} "Successful retrieval" // @Success 200 {object} utils.RespStatus{data=service_event.InfoResponse} "Successful retrieval"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input"
// @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found" // @Failure 404 {object} utils.RespStatus{data=nil} "Event Not Found"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /event/info [get] // @Router /event/info [get]
func (self *EventHandler) Info(c *gin.Context) { func (self *EventHandler) Info(c *gin.Context) {
eventIdOrig := c.Query("event_id") eventIdOrig := c.Query("event_id")
eventId, err := uuid.Parse(eventIdOrig) eventId, err := uuid.Parse(eventIdOrig)

View File

@@ -9,15 +9,15 @@ import (
) )
// Full retrieves the complete list of users directly from the database table. // Full retrieves the complete list of users directly from the database table.
// @Summary Get Full User Table // @Summary Get Full User Table
// @Description Fetches all user records without pagination. This is typically used for administrative overview or data export. // @Description Fetches all user records without pagination. This is typically used for administrative overview or data export.
// @Tags User // @Tags User
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} utils.RespStatus{data=service_user.UserTableResponse} "Successful retrieval of full user table" // @Success 200 {object} utils.RespStatus{data=service_user.UserTableResponse} "Successful retrieval of full user table"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Database Error)" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Database Error)"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /user/full [get] // @Router /user/full [get]
func (self *UserHandler) Full(c *gin.Context) { func (self *UserHandler) Full(c *gin.Context) {
userTablePayload := &service_user.UserTablePayload{ userTablePayload := &service_user.UserTablePayload{
Context: c, Context: c,

View File

@@ -10,17 +10,17 @@ import (
) )
// Info retrieves the profile information of the currently authenticated user. // Info retrieves the profile information of the currently authenticated user.
// @Summary Get My User Information // @Summary Get My User Information
// @Description Fetches the complete profile data for the user associated with the provided session/token. // @Description Fetches the complete profile data for the user associated with the provided session/token.
// @Tags User // @Tags User
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Success 200 {object} utils.RespStatus{data=service_user.UserInfoData} "Successful profile retrieval" // @Success 200 {object} utils.RespStatus{data=service_user.UserInfoData} "Successful profile retrieval"
// @Failure 403 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized" // @Failure 403 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized"
// @Failure 404 {object} utils.RespStatus{data=nil} "User Not Found" // @Failure 404 {object} utils.RespStatus{data=nil} "User Not Found"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (UUID Parse Failed)" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (UUID Parse Failed)"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /user/info [get] // @Router /user/info [get]
func (self *UserHandler) Info(c *gin.Context) { func (self *UserHandler) Info(c *gin.Context) {
userIdOrig, ok := c.Get("user_id") userIdOrig, ok := c.Get("user_id")
if !ok { if !ok {

View File

@@ -9,18 +9,18 @@ import (
) )
// List retrieves a paginated list of users from the search engine. // List retrieves a paginated list of users from the search engine.
// @Summary List Users // @Summary List Users
// @Description Fetches a list of users with support for pagination via limit and offset. Data is sourced from the search engine for high performance. // @Description Fetches a list of users with support for pagination via limit and offset. Data is sourced from the search engine for high performance.
// @Tags User // @Tags User
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param limit query string false "Maximum number of users to return (default 0)" // @Param limit query string false "Maximum number of users to return (default 0)"
// @Param offset query string true "Number of users to skip" // @Param offset query string true "Number of users to skip"
// @Success 200 {object} utils.RespStatus{data=[]data.UserSearchDoc} "Successful paginated list retrieval" // @Success 200 {object} utils.RespStatus{data=[]data.UserSearchDoc} "Successful paginated list retrieval"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input (Format Error)" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input (Format Error)"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Search Engine or Missing Offset)" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Search Engine or Missing Offset)"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /user/list [get] // @Router /user/list [get]
func (self *UserHandler) List(c *gin.Context) { func (self *UserHandler) List(c *gin.Context) {
type ListQuery struct { type ListQuery struct {
Limit *string `form:"limit"` Limit *string `form:"limit"`

View File

@@ -10,19 +10,19 @@ import (
) )
// Update modifies the profile information for the currently authenticated user. // Update modifies the profile information for the currently authenticated user.
// @Summary Update User Information // @Summary Update User Information
// @Description Updates specific profile fields such as username, nickname, subtitle, avatar (URL), and bio (Base64). // @Description Updates specific profile fields such as username, nickname, subtitle, avatar (URL), and bio (Base64).
// @Description Validation: Username (5-255 chars), Nickname (max 24 chars), Subtitle (max 32 chars). // @Description Validation: Username (5-255 chars), Nickname (max 24 chars), Subtitle (max 32 chars).
// @Tags User // @Tags User
// @Accept json // @Accept json
// @Produce json // @Produce json
// @Param payload body service_user.UserInfoData true "Updated User Profile Data" // @Param payload body service_user.UserInfoData true "Updated User Profile Data"
// @Success 200 {object} utils.RespStatus{data=nil} "Successful profile update" // @Success 200 {object} utils.RespStatus{data=nil} "Successful profile update"
// @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input (Validation Failed)" // @Failure 400 {object} utils.RespStatus{data=nil} "Invalid Input (Validation Failed)"
// @Failure 403 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized" // @Failure 403 {object} utils.RespStatus{data=nil} "Missing User ID / Unauthorized"
// @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Database Error / UUID Parse Failed)" // @Failure 500 {object} utils.RespStatus{data=nil} "Internal Server Error (Database Error / UUID Parse Failed)"
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /user/update [patch] // @Router /user/update [patch]
func (self *UserHandler) Update(c *gin.Context) { func (self *UserHandler) Update(c *gin.Context) {
userIdOrig, ok := c.Get("user_id") userIdOrig, ok := c.Get("user_id")
if !ok { if !ok {

View File

@@ -9,7 +9,16 @@ const docTemplate = `{
"info": { "info": {
"description": "{{escape .Description}}", "description": "{{escape .Description}}",
"title": "{{.Title}}", "title": "{{.Title}}",
"contact": {}, "termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}" "version": "{{.Version}}"
}, },
"host": "{{.Host}}", "host": "{{.Host}}",
@@ -1462,12 +1471,12 @@ const docTemplate = `{
// SwaggerInfo holds exported Swagger Info so clients can modify it // SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{ var SwaggerInfo = &swag.Spec{
Version: "", Version: "1.0",
Host: "", Host: "localhost:8000",
BasePath: "", BasePath: "/api/v1",
Schemes: []string{}, Schemes: []string{"http", "https"},
Title: "", Title: "NixCN CMS API",
Description: "", Description: "API Docs based on Gin framework",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate, SwaggerTemplate: docTemplate,
LeftDelim: "{{", LeftDelim: "{{",

View File

@@ -1,8 +1,26 @@
{ {
"schemes": [
"http",
"https"
],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"contact": {} "description": "API Docs based on Gin framework",
"title": "NixCN CMS API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0"
}, },
"host": "localhost:8000",
"basePath": "/api/v1",
"paths": { "paths": {
"/auth/exchange": { "/auth/exchange": {
"post": { "post": {

View File

@@ -1,3 +1,4 @@
basePath: /api/v1
definitions: definitions:
data.User: data.User:
properties: properties:
@@ -154,8 +155,19 @@ definitions:
status: status:
type: string type: string
type: object type: object
host: localhost:8000
info: info:
contact: {} contact:
email: support@swagger.io
name: API Support
url: http://www.swagger.io/support
description: API Docs based on Gin framework
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: NixCN CMS API
version: "1.0"
paths: paths:
/auth/exchange: /auth/exchange:
post: post:
@@ -823,4 +835,7 @@ paths:
summary: Update User Information summary: Update User Information
tags: tags:
- User - User
schemes:
- http
- https
swagger: "2.0" swagger: "2.0"

View File

@@ -2,4 +2,5 @@ package main
//go:generate go run ./cmd/gen_exception/main.go //go:generate go run ./cmd/gen_exception/main.go
//go:generate swag init //go:generate swag fmt
//go:generate swag init -g server/server.go

2
go.mod
View File

@@ -19,7 +19,6 @@ require (
github.com/spf13/viper v1.21.0 github.com/spf13/viper v1.21.0
github.com/swaggo/files v1.0.1 github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.1 github.com/swaggo/gin-swagger v1.6.1
github.com/swaggo/swag v1.16.6
go.opentelemetry.io/contrib/bridges/otelslog v0.14.0 go.opentelemetry.io/contrib/bridges/otelslog v0.14.0
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0 go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0
@@ -113,6 +112,7 @@ require (
github.com/spf13/cast v1.10.0 // indirect github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/swag v1.16.6 // indirect
github.com/tjfoc/gmsm v1.4.1 // indirect github.com/tjfoc/gmsm v1.4.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.1 // indirect github.com/ugorji/go/codec v1.3.1 // indirect

View File

@@ -27,7 +27,7 @@ import (
// @contact.email support@swagger.io // @contact.email support@swagger.io
// @license.name Apache 2.0 // @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html // @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080 // @host localhost:8000
// @BasePath /api/v1 // @BasePath /api/v1
// @schemes http https // @schemes http https
func Start(ctx context.Context) { func Start(ctx context.Context) {
@@ -39,10 +39,11 @@ func Start(ctx context.Context) {
r := gin.New() r := gin.New()
r.Use(otelgin.Middleware(viper.GetString("server.service_name"))) r.Use(otelgin.Middleware(viper.GetString("server.service_name")))
r.Use(middleware.GinLogger()) r.Use(middleware.GinLogger())
r.Use(gin.Recovery())
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
r.Use(gin.Recovery())
api.Handler(r.Group("/api/v1")) api.Handler(r.Group("/api/v1"))
// Start http server // Start http server