feat: 完胜增加schema逻辑

This commit is contained in:
2026-01-06 11:57:02 +08:00
parent 2f4e6851f3
commit c1d5dd89d4
3 changed files with 82 additions and 6 deletions

View File

@@ -69,12 +69,19 @@ func ParseStructField(field reflect.StructField) *StructFieldInfo {
// GenerateOpenAPISchema 生成完整的 OpenAPI Schema
func GenerateOpenAPISchema(s any) *openapi3.SchemaRef {
t := reflect.TypeOf(s)
if t.Kind() == reflect.Ptr {
t = t.Elem()
var (
ok bool
tType reflect.Type
)
if tType, ok = s.(reflect.Type); !ok {
tType = reflect.TypeOf(s)
if tType.Kind() == reflect.Ptr {
tType = tType.Elem()
}
}
return generateSchemaRecursive(t, make(map[string]bool))
return generateSchemaRecursive(tType, make(map[string]bool))
}
// 生成 schema