Fix Swagger @router

This commit is contained in:
Yang Luo
2024-01-15 23:27:42 +08:00
parent dc6fe13f75
commit b469928780
7 changed files with 941 additions and 483 deletions

View File

@ -453,7 +453,7 @@ func (c *ApiController) GetUserinfo2() {
// GetCaptcha ... // GetCaptcha ...
// @Tag Login API // @Tag Login API
// @Title GetCaptcha // @Title GetCaptcha
// @router /api/get-captcha [get] // @router /get-captcha [get]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) GetCaptcha() { func (c *ApiController) GetCaptcha() {
applicationId := c.Input().Get("applicationId") applicationId := c.Input().Get("applicationId")

View File

@ -918,7 +918,7 @@ func (c *ApiController) HandleSamlLogin() {
// HandleOfficialAccountEvent ... // HandleOfficialAccountEvent ...
// @Tag HandleOfficialAccountEvent API // @Tag HandleOfficialAccountEvent API
// @Title HandleOfficialAccountEvent // @Title HandleOfficialAccountEvent
// @router /api/webhook [POST] // @router /webhook [POST]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) HandleOfficialAccountEvent() { func (c *ApiController) HandleOfficialAccountEvent() {
respBytes, err := ioutil.ReadAll(c.Ctx.Request.Body) respBytes, err := ioutil.ReadAll(c.Ctx.Request.Body)
@ -949,7 +949,7 @@ func (c *ApiController) HandleOfficialAccountEvent() {
// GetWebhookEventType ... // GetWebhookEventType ...
// @Tag GetWebhookEventType API // @Tag GetWebhookEventType API
// @Title GetWebhookEventType // @Title GetWebhookEventType
// @router /api/get-webhook-event [GET] // @router /get-webhook-event [GET]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) GetWebhookEventType() { func (c *ApiController) GetWebhookEventType() {
lock.Lock() lock.Lock()
@ -970,7 +970,7 @@ func (c *ApiController) GetWebhookEventType() {
// @Description Get Login Error Counts // @Description Get Login Error Counts
// @Param id query string true "The id ( owner/name ) of user" // @Param id query string true "The id ( owner/name ) of user"
// @Success 200 {object} controllers.Response The Response object // @Success 200 {object} controllers.Response The Response object
// @router /api/get-captcha-status [get] // @router /get-captcha-status [get]
func (c *ApiController) GetCaptchaStatus() { func (c *ApiController) GetCaptchaStatus() {
organization := c.Input().Get("organization") organization := c.Input().Get("organization")
userId := c.Input().Get("userId") userId := c.Input().Get("userId")
@ -1001,7 +1001,7 @@ func (c *ApiController) GetCaptchaStatus() {
// @Title Callback // @Title Callback
// @Tag Callback API // @Tag Callback API
// @Description Get Login Error Counts // @Description Get Login Error Counts
// @router /api/Callback [post] // @router /Callback [post]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) Callback() { func (c *ApiController) Callback() {
code := c.GetString("code") code := c.GetString("code")

View File

@ -52,7 +52,7 @@ type NotificationForm struct {
// @Param clientSecret query string true "The clientSecret of the application" // @Param clientSecret query string true "The clientSecret of the application"
// @Param from body controllers.EmailForm true "Details of the email request" // @Param from body controllers.EmailForm true "Details of the email request"
// @Success 200 {object} controllers.Response The Response object // @Success 200 {object} controllers.Response The Response object
// @router /api/send-email [post] // @router /send-email [post]
func (c *ApiController) SendEmail() { func (c *ApiController) SendEmail() {
userId, ok := c.RequireSignedIn() userId, ok := c.RequireSignedIn()
if !ok { if !ok {
@ -148,7 +148,7 @@ func (c *ApiController) SendEmail() {
// @Param clientSecret query string true "The clientSecret of the application" // @Param clientSecret query string true "The clientSecret of the application"
// @Param from body controllers.SmsForm true "Details of the sms request" // @Param from body controllers.SmsForm true "Details of the sms request"
// @Success 200 {object} controllers.Response The Response object // @Success 200 {object} controllers.Response The Response object
// @router /api/send-sms [post] // @router /send-sms [post]
func (c *ApiController) SendSms() { func (c *ApiController) SendSms() {
provider, err := c.GetProviderFromContext("SMS") provider, err := c.GetProviderFromContext("SMS")
if err != nil { if err != nil {
@ -186,7 +186,7 @@ func (c *ApiController) SendSms() {
// @Description This API is not for Casdoor frontend to call, it is for Casdoor SDKs. // @Description This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
// @Param from body controllers.NotificationForm true "Details of the notification request" // @Param from body controllers.NotificationForm true "Details of the notification request"
// @Success 200 {object} controllers.Response The Response object // @Success 200 {object} controllers.Response The Response object
// @router /api/send-notification [post] // @router /send-notification [post]
func (c *ApiController) SendNotification() { func (c *ApiController) SendNotification() {
provider, err := c.GetProviderFromContext("Notification") provider, err := c.GetProviderFromContext("Notification")
if err != nil { if err != nil {

View File

@ -156,7 +156,7 @@ func (c *ApiController) DeleteToken() {
// @Success 200 {object} object.TokenWrapper The Response object // @Success 200 {object} object.TokenWrapper The Response object
// @Success 400 {object} object.TokenError The Response object // @Success 400 {object} object.TokenError The Response object
// @Success 401 {object} object.TokenError The Response object // @Success 401 {object} object.TokenError The Response object
// @router api/login/oauth/access_token [post] // @router /login/oauth/access_token [post]
func (c *ApiController) GetOAuthToken() { func (c *ApiController) GetOAuthToken() {
clientId := c.Input().Get("client_id") clientId := c.Input().Get("client_id")
clientSecret := c.Input().Get("client_secret") clientSecret := c.Input().Get("client_secret")

View File

@ -272,7 +272,7 @@ func (c *ApiController) VerifyCaptcha() {
// ResetEmailOrPhone ... // ResetEmailOrPhone ...
// @Tag Account API // @Tag Account API
// @Title ResetEmailOrPhone // @Title ResetEmailOrPhone
// @router /api/reset-email-or-phone [post] // @router /reset-email-or-phone [post]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) ResetEmailOrPhone() { func (c *ApiController) ResetEmailOrPhone() {
user, ok := c.RequireSignedInUser() user, ok := c.RequireSignedInUser()
@ -367,7 +367,7 @@ func (c *ApiController) ResetEmailOrPhone() {
// VerifyCode // VerifyCode
// @Tag Verification API // @Tag Verification API
// @Title VerifyCode // @Title VerifyCode
// @router /api/verify-code [post] // @router /verify-code [post]
// @Success 200 {object} object.Userinfo The Response object // @Success 200 {object} object.Userinfo The Response object
func (c *ApiController) VerifyCode() { func (c *ApiController) VerifyCode() {
var authForm form.AuthForm var authForm form.AuthForm

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,17 @@ paths:
description: "" description: ""
schema: schema:
$ref: '#/definitions/object.OidcDiscovery' $ref: '#/definitions/object.OidcDiscovery'
/api/Callback:
post:
tags:
- Callback API
description: Get Login Error Counts
operationId: ApiController.Callback
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/add-adapter: /api/add-adapter:
post: post:
tags: tags:
@ -121,6 +132,24 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/add-invitation:
post:
tags:
- Invitation API
description: add invitation
operationId: ApiController.AddInvitation
parameters:
- in: body
name: body
description: The details of the invitation
required: true
schema:
$ref: '#/definitions/object.Invitation'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/add-ldap: /api/add-ldap:
post: post:
tags: tags:
@ -442,158 +471,6 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/api/Callback:
post:
tags:
- Callback API
description: Get Login Error Counts
operationId: ApiController.Callback
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/api/get-captcha:
get:
tags:
- Login API
operationId: ApiController.GetCaptcha
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/api/get-captcha-status:
get:
tags:
- Token API
description: Get Login Error Counts
operationId: ApiController.GetCaptchaStatus
parameters:
- in: query
name: id
description: The id ( owner/name ) of user
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/api/get-webhook-event:
get:
tags:
- GetWebhookEventType API
operationId: ApiController.GetWebhookEventType
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/api/reset-email-or-phone:
post:
tags:
- Account API
operationId: ApiController.ResetEmailOrPhone
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/api/send-email:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendEmail
parameters:
- in: query
name: clientId
description: The clientId of the application
required: true
type: string
- in: query
name: clientSecret
description: The clientSecret of the application
required: true
type: string
- in: body
name: from
description: Details of the email request
required: true
schema:
$ref: '#/definitions/controllers.EmailForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/api/send-notification:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendNotification
parameters:
- in: body
name: from
description: Details of the notification request
required: true
schema:
$ref: '#/definitions/controllers.NotificationForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/api/send-sms:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendSms
parameters:
- in: query
name: clientId
description: The clientId of the application
required: true
type: string
- in: query
name: clientSecret
description: The clientSecret of the application
required: true
type: string
- in: body
name: from
description: Details of the sms request
required: true
schema:
$ref: '#/definitions/controllers.SmsForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/api/verify-code:
post:
tags:
- Verification API
operationId: ApiController.VerifyCode
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/api/webhook:
post:
tags:
- HandleOfficialAccountEvent API
operationId: ApiController.HandleOfficialAccountEvent
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/batch-enforce: /api/batch-enforce:
post: post:
tags: tags:
@ -617,6 +494,10 @@ paths:
name: modelId name: modelId
description: model id description: model id
type: string type: string
- in: query
name: owner
description: owner
type: string
responses: responses:
"200": "200":
description: The Response object description: The Response object
@ -744,6 +625,24 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/delete-invitation:
post:
tags:
- Invitation API
description: delete invitation
operationId: ApiController.DeleteInvitation
parameters:
- in: body
name: body
description: The details of the invitation
required: true
schema:
$ref: '#/definitions/object.Invitation'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/delete-ldap: /api/delete-ldap:
post: post:
tags: tags:
@ -1088,6 +987,10 @@ paths:
name: resourceId name: resourceId
description: resource id description: resource id
type: string type: string
- in: query
name: owner
description: owner
type: string
responses: responses:
"200": "200":
description: The Response object description: The Response object
@ -1213,6 +1116,33 @@ paths:
type: array type: array
items: items:
$ref: '#/definitions/object.Application' $ref: '#/definitions/object.Application'
/api/get-captcha:
get:
tags:
- Login API
operationId: ApiController.GetCaptcha
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/get-captcha-status:
get:
tags:
- Token API
description: Get Login Error Counts
operationId: ApiController.GetCaptchaStatus
parameters:
- in: query
name: id
description: The id ( owner/name ) of user
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/get-cert: /api/get-cert:
get: get:
tags: tags:
@ -1410,6 +1340,42 @@ paths:
type: array type: array
items: items:
$ref: '#/definitions/object.Group' $ref: '#/definitions/object.Group'
/api/get-invitation:
get:
tags:
- Invitation API
description: get invitation
operationId: ApiController.GetInvitation
parameters:
- in: query
name: id
description: The id ( owner/name ) of the invitation
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Invitation'
/api/get-invitations:
get:
tags:
- Invitation API
description: get invitations
operationId: ApiController.GetInvitations
parameters:
- in: query
name: owner
description: The owner of invitations
required: true
type: string
responses:
"200":
description: The Response object
schema:
type: array
items:
$ref: '#/definitions/object.Invitation'
/api/get-ldap: /api/get-ldap:
get: get:
tags: tags:
@ -2269,6 +2235,16 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/object.Webhook' $ref: '#/definitions/object.Webhook'
/api/get-webhook-event:
get:
tags:
- GetWebhookEventType API
operationId: ApiController.GetWebhookEventType
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/get-webhooks: /api/get-webhooks:
get: get:
tags: tags:
@ -2396,6 +2372,46 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/login/oauth/access_token:
post:
tags:
- Token API
description: get OAuth access token
operationId: ApiController.GetOAuthToken
parameters:
- in: query
name: grant_type
description: OAuth grant type
required: true
type: string
- in: query
name: client_id
description: OAuth client id
required: true
type: string
- in: query
name: client_secret
description: OAuth client secret
required: true
type: string
- in: query
name: code
description: OAuth code
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.TokenWrapper'
"400":
description: The Response object
schema:
$ref: '#/definitions/object.TokenError'
"401":
description: The Response object
schema:
$ref: '#/definitions/object.TokenError'
/api/login/oauth/introspect: /api/login/oauth/introspect:
post: post:
description: The introspection endpoint is an OAuth 2.0 endpoint that takes a description: The introspection endpoint is an OAuth 2.0 endpoint that takes a
@ -2543,6 +2559,16 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/reset-email-or-phone:
post:
tags:
- Account API
operationId: ApiController.ResetEmailOrPhone
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/run-syncer: /api/run-syncer:
get: get:
tags: tags:
@ -2561,6 +2587,80 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/send-email:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendEmail
parameters:
- in: query
name: clientId
description: The clientId of the application
required: true
type: string
- in: query
name: clientSecret
description: The clientSecret of the application
required: true
type: string
- in: body
name: from
description: Details of the email request
required: true
schema:
$ref: '#/definitions/controllers.EmailForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/send-notification:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendNotification
parameters:
- in: body
name: from
description: Details of the notification request
required: true
schema:
$ref: '#/definitions/controllers.NotificationForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/send-sms:
post:
tags:
- Service API
description: This API is not for Casdoor frontend to call, it is for Casdoor SDKs.
operationId: ApiController.SendSms
parameters:
- in: query
name: clientId
description: The clientId of the application
required: true
type: string
- in: query
name: clientSecret
description: The clientSecret of the application
required: true
type: string
- in: body
name: from
description: Details of the sms request
required: true
schema:
$ref: '#/definitions/controllers.SmsForm'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/send-verification-code: /api/send-verification-code:
post: post:
tags: tags:
@ -2778,6 +2878,29 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/api/update-invitation:
post:
tags:
- Invitation API
description: update invitation
operationId: ApiController.UpdateInvitation
parameters:
- in: query
name: id
description: The id ( owner/name ) of the invitation
required: true
type: string
- in: body
name: body
description: The details of the invitation
required: true
schema:
$ref: '#/definitions/object.Invitation'
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/update-ldap: /api/update-ldap:
post: post:
tags: tags:
@ -3245,6 +3368,33 @@ paths:
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/object.Userinfo' $ref: '#/definitions/object.Userinfo'
/api/verify-code:
post:
tags:
- Verification API
operationId: ApiController.VerifyCode
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/object.Userinfo'
/api/verify-invitation:
get:
tags:
- Invitation API
description: verify invitation
operationId: ApiController.VerifyInvitation
parameters:
- in: query
name: id
description: The id ( owner/name ) of the invitation
required: true
type: string
responses:
"200":
description: The Response object
schema:
$ref: '#/definitions/controllers.Response'
/api/webauthn/signin/begin: /api/webauthn/signin/begin:
get: get:
tags: tags:
@ -3314,46 +3464,16 @@ paths:
description: '"The Response object"' description: '"The Response object"'
schema: schema:
$ref: '#/definitions/controllers.Response' $ref: '#/definitions/controllers.Response'
/apiapi/login/oauth/access_token: /api/webhook:
post: post:
tags: tags:
- Token API - HandleOfficialAccountEvent API
description: get OAuth access token operationId: ApiController.HandleOfficialAccountEvent
operationId: ApiController.GetOAuthToken
parameters:
- in: query
name: grant_type
description: OAuth grant type
required: true
type: string
- in: query
name: client_id
description: OAuth client id
required: true
type: string
- in: query
name: client_secret
description: OAuth client secret
required: true
type: string
- in: query
name: code
description: OAuth code
required: true
type: string
responses: responses:
"200": "200":
description: The Response object description: The Response object
schema: schema:
$ref: '#/definitions/object.TokenWrapper' $ref: '#/definitions/object.Userinfo'
"400":
description: The Response object
schema:
$ref: '#/definitions/object.TokenError'
"401":
description: The Response object
schema:
$ref: '#/definitions/object.TokenError'
definitions: definitions:
casbin.Enforcer: casbin.Enforcer:
title: Enforcer title: Enforcer
@ -3546,10 +3666,10 @@ definitions:
expireInHours: expireInHours:
type: integer type: integer
format: int64 format: int64
failedSigninLimit: failedSigninFrozenTime:
type: integer type: integer
format: int64 format: int64
failedSigninFrozenTime: failedSigninLimit:
type: integer type: integer
format: int64 format: int64
forgetUrl: forgetUrl:
@ -3606,6 +3726,10 @@ definitions:
type: string type: string
signinHtml: signinHtml:
type: string type: string
signinMethods:
type: array
items:
$ref: '#/definitions/object.SigninMethod'
signinUrl: signinUrl:
type: string type: string
signupHtml: signupHtml:
@ -3624,6 +3748,10 @@ definitions:
type: string type: string
themeData: themeData:
$ref: '#/definitions/object.ThemeData' $ref: '#/definitions/object.ThemeData'
tokenFields:
type: array
items:
type: string
tokenFormat: tokenFormat:
type: string type: string
object.Cert: object.Cert:
@ -3780,6 +3908,40 @@ definitions:
type: string type: string
username: username:
type: string type: string
object.Invitation:
title: Invitation
type: object
properties:
application:
type: string
code:
type: string
createdTime:
type: string
displayName:
type: string
email:
type: string
name:
type: string
owner:
type: string
phone:
type: string
quota:
type: integer
format: int64
signupGroup:
type: string
state:
type: string
updatedTime:
type: string
usedCount:
type: integer
format: int64
username:
type: string
object.Ldap: object.Ldap:
title: Ldap title: Ldap
type: object type: object
@ -4455,6 +4617,16 @@ definitions:
type: string type: string
value: value:
type: string type: string
object.SigninMethod:
title: SigninMethod
type: object
properties:
displayName:
type: string
name:
type: string
rule:
type: string
object.SignupItem: object.SignupItem:
title: SignupItem title: SignupItem
type: object type: object
@ -4467,6 +4639,8 @@ definitions:
type: string type: string
prompted: prompted:
type: boolean type: boolean
regex:
type: string
required: required:
type: boolean type: boolean
rule: rule: