Extend extends target schema
(fromSchema *Schema)
| 567 | |
| 568 | // Extend extends target schema |
| 569 | func (schema *Schema) Extend(fromSchema *Schema) error { |
| 570 | if schema.Parent == "" { |
| 571 | schema.Parent = fromSchema.Parent |
| 572 | } |
| 573 | if schema.Prefix == "" { |
| 574 | schema.Prefix = fromSchema.Prefix |
| 575 | } |
| 576 | if schema.URL == "" { |
| 577 | schema.URL = fromSchema.URL |
| 578 | } |
| 579 | if schema.NamespaceID == "" { |
| 580 | schema.NamespaceID = fromSchema.NamespaceID |
| 581 | } |
| 582 | schema.JSONSchema["properties"] = util.ExtendMap( |
| 583 | util.MaybeMap(schema.JSONSchema["properties"]), |
| 584 | util.MaybeMap(fromSchema.JSONSchema["properties"])) |
| 585 | |
| 586 | if util.ContainsString(util.MaybeStringList(schema.OrderPropertiesBefore), fromSchema.ID) { |
| 587 | schema.JSONSchema["propertiesOrder"] = util.ExtendStringList( |
| 588 | util.MaybeStringList(schema.JSONSchema["propertiesOrder"]), |
| 589 | util.MaybeStringList(fromSchema.JSONSchema["propertiesOrder"])) |
| 590 | } else { |
| 591 | schema.JSONSchema["propertiesOrder"] = util.ExtendStringList( |
| 592 | util.MaybeStringList(fromSchema.JSONSchema["propertiesOrder"]), |
| 593 | util.MaybeStringList(schema.JSONSchema["propertiesOrder"])) |
| 594 | } |
| 595 | |
| 596 | schema.JSONSchema["required"] = util.ExtendStringList( |
| 597 | util.MaybeStringList(fromSchema.JSONSchema["required"]), |
| 598 | util.MaybeStringList(schema.JSONSchema["required"])) |
| 599 | MergeAction: |
| 600 | for _, action := range fromSchema.Actions { |
| 601 | for _, existingAction := range schema.Actions { |
| 602 | if action.ID == existingAction.ID { |
| 603 | continue MergeAction |
| 604 | } |
| 605 | } |
| 606 | schema.Actions = append(schema.Actions, action) |
| 607 | } |
| 608 | schema.Metadata = util.ExtendMap(schema.Metadata, fromSchema.Metadata) |
| 609 | schema.IsolationLevel = util.ExtendMap(schema.IsolationLevel, fromSchema.IsolationLevel) |
| 610 | return schema.Init() |
| 611 | } |
| 612 | |
| 613 | //Titles returns list of Titles |
| 614 | func (schema *Schema) Titles() []string { |
no test coverage detected