feature/goctl-api-swagger (#4780)

This commit is contained in:
kesonan
2025-04-17 22:38:55 +08:00
committed by GitHub
parent 801c283478
commit 9c478626d2
38 changed files with 2445 additions and 23 deletions

View File

@@ -0,0 +1,28 @@
package swagger
import (
"github.com/go-openapi/spec"
apiSpec "github.com/zeromicro/go-zero/tools/goctl/api/spec"
)
func jsonResponseFromType(info apiSpec.Info, tp apiSpec.Type) *spec.Responses {
p, _ := propertiesFromType(tp)
props := spec.SchemaProps{
Type: typeFromGoType(tp),
Properties: p,
AdditionalProperties: mapFromGoType(tp),
Items: itemsFromGoType(tp),
}
return &spec.Responses{
ResponsesProps: spec.ResponsesProps{
Default: &spec.Response{
ResponseProps: spec.ResponseProps{
Schema: &spec.Schema{
SchemaProps: wrapCodeMsgProps(props, info),
},
},
},
},
}
}