@@ -432,57 +432,57 @@ func (parser *Parser) ParseDefinition(typeSpecDef *TypeSpecDef) (*TypeSchema, er
432
432
return & sch , nil
433
433
}
434
434
435
- func (parser * Parser ) parseTypeExpr (file * ast.File , field * ast.Field , typeExpr ast.Expr , ref bool ) (* TypeSchema , error ) {
436
- switch expr := typeExpr .(type ) {
437
- // type Foo interface{}
438
- case * ast.InterfaceType :
439
- return & TypeSchema {}, nil
440
-
441
- // type Foo struct {...}
442
- case * ast.StructType :
443
- return parser .parseStruct (file , expr .Fields )
444
-
445
- // type Foo Baz
446
- case * ast.Ident :
447
- return parser .getTypeSchema (expr .Name , file , field , ref )
448
-
449
- // type Foo *Baz
450
- case * ast.StarExpr :
451
- return parser .parseTypeExpr (file , field , expr .X , ref )
452
-
453
- // type Foo pkg.Bar
454
- case * ast.SelectorExpr :
455
- if xIdent , ok := expr .X .(* ast.Ident ); ok {
456
- return parser .getTypeSchema (fullTypeName (xIdent .Name , expr .Sel .Name ), file , field , ref )
457
- }
458
- // type Foo []Baz
459
- case * ast.ArrayType :
460
- itemSchema , err := parser .parseTypeExpr (file , field , expr .Elt , true )
461
- if err != nil {
462
- return nil , err
463
- }
464
- return & TypeSchema {Type : "array" , ArraySchema : itemSchema }, nil
465
- // type Foo map[string]Bar
466
- // case *ast.MapType:
467
- // if _, ok := expr.Value.(*ast.InterfaceType); ok {
468
- // return &TypeSchema{Type: OBJECT, Properties: nil}, nil
469
- // }
470
- // schema, err := parser.parseTypeExpr(file, expr.Value, true)
471
- // if err != nil {
472
- // return nil, err
473
- // }
474
-
475
- // return spec.MapProperty(schema), nil
476
-
477
- // case *ast.FuncType:
478
- // return nil, ErrFuncTypeField
479
- // ...
480
- default :
481
- fmt .Printf ("Type definition of type '%T' is not supported yet. Using 'object' instead.\n " , typeExpr )
482
- }
483
-
484
- return & TypeSchema {Type : OBJECT }, nil
485
- }
435
+ // func (parser *Parser) parseTypeExpr(file *ast.File, field *ast.Field, typeExpr ast.Expr, ref bool) (*TypeSchema, error) {
436
+ // switch expr := typeExpr.(type) {
437
+ // // type Foo interface{}
438
+ // case *ast.InterfaceType:
439
+ // return &TypeSchema{}, nil
440
+
441
+ // // type Foo struct {...}
442
+ // case *ast.StructType:
443
+ // return parser.parseStruct(file, expr.Fields)
444
+
445
+ // // type Foo Baz
446
+ // case *ast.Ident:
447
+ // return parser.getTypeSchema(expr.Name, file, field, ref)
448
+
449
+ // // type Foo *Baz
450
+ // case *ast.StarExpr:
451
+ // return parser.parseTypeExpr(file, field, expr.X, ref)
452
+
453
+ // // type Foo pkg.Bar
454
+ // case *ast.SelectorExpr:
455
+ // if xIdent, ok := expr.X.(*ast.Ident); ok {
456
+ // return parser.getTypeSchema(fullTypeName(xIdent.Name, expr.Sel.Name), file, field, ref)
457
+ // }
458
+ // // type Foo []Baz
459
+ // case *ast.ArrayType:
460
+ // itemSchema, err := parser.parseTypeExpr(file, field, expr.Elt, true)
461
+ // if err != nil {
462
+ // return nil, err
463
+ // }
464
+ // return &TypeSchema{Type: "array", ArraySchema: itemSchema}, nil
465
+ // // type Foo map[string]Bar
466
+ // // case *ast.MapType:
467
+ // // if _, ok := expr.Value.(*ast.InterfaceType); ok {
468
+ // // return &TypeSchema{Type: OBJECT, Properties: nil}, nil
469
+ // // }
470
+ // // schema, err := parser.parseTypeExpr(file, expr.Value, true)
471
+ // // if err != nil {
472
+ // // return nil, err
473
+ // // }
474
+
475
+ // // return spec.MapProperty(schema), nil
476
+
477
+ // // case *ast.FuncType:
478
+ // // return nil, ErrFuncTypeField
479
+ // // ...
480
+ // default:
481
+ // fmt.Printf("Type definition of type '%T' is not supported yet. Using 'object' instead.\n", typeExpr)
482
+ // }
483
+
484
+ // return &TypeSchema{Type: OBJECT}, nil
485
+ // }
486
486
487
487
func (parser * Parser ) parseStruct (file * ast.File , fields * ast.FieldList ) (* TypeSchema , error ) {
488
488
properties := make (map [string ]* TypeSchema )
0 commit comments