Helper function for recursive types
(name string)
| 689 | |
| 690 | // Helper function for recursive types |
| 691 | func newRecursiveType(name string) *expr.AttributeExpr { |
| 692 | // Create a user type that references itself |
| 693 | ut := &expr.UserTypeExpr{ |
| 694 | TypeName: name, |
| 695 | } |
| 696 | att := &expr.AttributeExpr{ |
| 697 | Type: &expr.Object{ |
| 698 | &expr.NamedAttributeExpr{ |
| 699 | Name: "self", |
| 700 | Attribute: &expr.AttributeExpr{ |
| 701 | Type: ut, |
| 702 | }, |
| 703 | }, |
| 704 | }, |
| 705 | } |
| 706 | ut.AttributeExpr = att |
| 707 | return &expr.AttributeExpr{Type: ut} |
| 708 | } |
| 709 | |
| 710 | // nameFromRef does the reverse of toRef: it returns the type name from its |
| 711 | // JSON Schema reference. |