feat: 完胜增加schema逻辑
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user