goctl: v1.8.4-beta (#4890)

This commit is contained in:
kesonan
2025-05-25 13:36:56 +08:00
committed by GitHub
parent 2de3e397ff
commit f3edd4b880
5 changed files with 54 additions and 31 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/go-openapi/spec"
apiSpec "github.com/zeromicro/go-zero/tools/goctl/api/spec"
"github.com/zeromicro/go-zero/tools/goctl/util/stringx"
)
func spec2Paths(ctx Context, srv apiSpec.Service) *spec.Paths {
@@ -70,6 +71,12 @@ func spec2Path(ctx Context, group apiSpec.Group, route apiSpec.Route) spec.PathI
},
}
}
groupName := getStringFromKVOrDefault(group.Annotation.Properties, propertyKeyGroup, "")
operationId := route.Handler
if len(groupName) > 0 {
operationId = stringx.From(groupName + "_" + route.Handler).ToCamel()
}
operationId = stringx.From(operationId).Untitle()
op := &spec.Operation{
OperationProps: spec.OperationProps{
Description: getStringFromKVOrDefault(route.AtDoc.Properties, propertyKeyDescription, ""),
@@ -78,10 +85,10 @@ func spec2Path(ctx Context, group apiSpec.Group, route apiSpec.Route) spec.PathI
Schemes: getListFromInfoOrDefault(route.AtDoc.Properties, propertyKeySchemes, []string{schemeHttps}),
Tags: getListFromInfoOrDefault(group.Annotation.Properties, propertyKeyTags, getListFromInfoOrDefault(group.Annotation.Properties, propertyKeySummary, []string{})),
Summary: getStringFromKVOrDefault(route.AtDoc.Properties, propertyKeySummary, getFirstUsableString(route.AtDoc.Text, route.Handler)),
ID: getStringFromKVOrDefault(route.AtDoc.Properties, propertyKeyOperationId, getFirstUsableString(route.AtDoc.Text, route.Handler)),
ID: operationId,
Deprecated: getBoolFromKVOrDefault(route.AtDoc.Properties, propertyKeyDeprecated, false),
Security: security,
Parameters: parametersFromType(ctx, route.Method, route.RequestType),
Security: security,
Responses: jsonResponseFromType(ctx, route.AtDoc, route.ResponseType),
},
}