feat: 支持配置Security + 移除不必要的components
This commit is contained in:
@@ -29,7 +29,7 @@ var (
|
||||
func NewOpenApiDoc(optionFunc ...OptionFunc) *openapi3.T {
|
||||
t := &openapi3.T{
|
||||
Extensions: map[string]any{},
|
||||
OpenAPI: "3.1.0",
|
||||
OpenAPI: "3.0.3",
|
||||
Components: &openapi3.Components{
|
||||
Extensions: map[string]any{},
|
||||
Origin: &openapi3.Origin{
|
||||
@@ -167,7 +167,7 @@ func (g *Generate) AddApiDoc(docFlag string, apiMeta define.UriConfig, request a
|
||||
|
||||
schemaData := GenerateOpenAPISchema(requestType)
|
||||
apiOperate, isRead := g.initApiConfig(docFlag, apiMeta)
|
||||
requestTypeStr := requestType.String()
|
||||
//requestTypeStr := requestType.String()
|
||||
if isRead {
|
||||
for paramName, paramConfig := range schemaData.Value.Properties {
|
||||
apiOperate.Parameters = append(apiOperate.Parameters, &openapi3.ParameterRef{
|
||||
@@ -217,14 +217,13 @@ func (g *Generate) AddApiDoc(docFlag string, apiMeta define.UriConfig, request a
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化接口配置
|
||||
if _, exist := g.docTable[docFlag].Components.Schemas[requestTypeStr]; !exist {
|
||||
/*if _, exist := g.docTable[docFlag].Components.Schemas[requestTypeStr]; !exist {
|
||||
g.docTable[docFlag].Components.Schemas[requestTypeStr] = schemaData
|
||||
}
|
||||
responseTypeStr := responseType.String()
|
||||
}*/
|
||||
/*responseTypeStr := responseType.String()
|
||||
if _, exist := g.docTable[docFlag].Components.Schemas[responseTypeStr]; !exist {
|
||||
g.docTable[docFlag].Components.Schemas[responseTypeStr] = GenerateOpenAPISchema(responseType)
|
||||
}
|
||||
}*/
|
||||
desc := "请求成功"
|
||||
apiOperate.Responses.Set(fmt.Sprintf("%v", http.StatusOK), &openapi3.ResponseRef{
|
||||
Extensions: nil,
|
||||
@@ -239,7 +238,7 @@ func (g *Generate) AddApiDoc(docFlag string, apiMeta define.UriConfig, request a
|
||||
consts.MimeTypeJson: {
|
||||
Extensions: nil,
|
||||
Origin: nil,
|
||||
Schema: g.docTable[docFlag].Components.Schemas[responseTypeStr],
|
||||
Schema: GenerateOpenAPISchema(responseType),
|
||||
Example: nil,
|
||||
Examples: nil,
|
||||
Encoding: nil,
|
||||
|
||||
Reference in New Issue
Block a user