@@ -91,6 +91,8 @@ func (c converter) convertSchema(schema *zsscore.ZSSSchema) (Schema, error) {
9191 out , err = c .convertStruct (schema )
9292 case zconst .TypePtr :
9393 out , err = c .convertPtr (schema )
94+ case zconst .TypeUnion :
95+ out , err = c .convertUnion (schema )
9496 case zconst .TypePreprocess , zconst .TypeBoxed :
9597 out , err = c .convertSchema (schema .Element )
9698 case zconst .TypeAny , zconst .TypeCustom :
@@ -187,6 +189,18 @@ func (c converter) convertPtr(schema *zsscore.ZSSSchema) (Schema, error) {
187189 return nullable (inner ), nil
188190}
189191
192+ func (c converter ) convertUnion (schema * zsscore.ZSSSchema ) (Schema , error ) {
193+ children := make ([]any , 0 , len (schema .Children ))
194+ for i , child := range schema .Children {
195+ converted , err := c .convertSchema (child )
196+ if err != nil {
197+ return nil , fmt .Errorf ("convert union child %d: %w" , i , err )
198+ }
199+ children = append (children , converted )
200+ }
201+ return Schema {"anyOf" : children }, nil
202+ }
203+
190204func nullable (schema Schema ) Schema {
191205 typeValue , ok := schema ["type" ]
192206 if ! ok {
0 commit comments