feat: 支持配置Security + 移除不必要的components
This commit is contained in:
@@ -11,10 +11,13 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/api-doc/define"
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
)
|
||||
|
||||
func TestGenerate_AddApiDoc(t *testing.T) {
|
||||
@@ -35,7 +38,21 @@ func TestGenerate_AddApiDoc(t *testing.T) {
|
||||
Category *Category `json:"category,omitempty" description:"分类"`
|
||||
}
|
||||
docFlag := "demo"
|
||||
DocManager.NewOpenApiDoc(docFlag)
|
||||
DocManager.NewOpenApiDoc(docFlag, WithSecurity(&openapi3.SecuritySchemes{
|
||||
"Token-Auth": {
|
||||
Extensions: nil,
|
||||
Origin: nil,
|
||||
Ref: "",
|
||||
Value: &openapi3.SecurityScheme{
|
||||
Extensions: nil,
|
||||
Origin: nil,
|
||||
Type: "apiKey",
|
||||
Description: "Token 身份认证",
|
||||
Name: "token",
|
||||
In: strings.ToLower(consts.RequestDataLocationHeader.String()),
|
||||
},
|
||||
},
|
||||
}))
|
||||
DocManager.AddApiDoc(docFlag, define.UriConfig{
|
||||
Path: "/a/b/c",
|
||||
RequestMethod: http.MethodGet,
|
||||
|
||||
Reference in New Issue
Block a user