Skip to content

Commit

Permalink
Don't even unmarshall _ui section in flows
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Mar 15, 2018
1 parent a51d25d commit c416b42
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions flows/definition/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ var _ utils.VariableResolver = (*flow)(nil)
//------------------------------------------------------------------------------------------

type flowEnvelope struct {
UUID flows.FlowUUID `json:"uuid" validate:"required,uuid4"`
Name string `json:"name" validate:"required"`
Language utils.Language `json:"language"`
ExpireAfterMinutes int `json:"expire_after_minutes"`
Localization localization `json:"localization"`
Nodes []*node `json:"nodes"`
UI map[string]interface{} `json:"_ui,omitempty"`
UUID flows.FlowUUID `json:"uuid" validate:"required,uuid4"`
Name string `json:"name" validate:"required"`
Language utils.Language `json:"language"`
ExpireAfterMinutes int `json:"expire_after_minutes"`
Localization localization `json:"localization"`
Nodes []*node `json:"nodes"`
}

type flowEnvelopeWithUI struct {
flowEnvelope
UI map[string]interface{} `json:"_ui,omitempty"`
}

// ReadFlow reads a single flow definition from the passed in byte array
Expand All @@ -155,12 +159,14 @@ func ReadFlow(data json.RawMessage) (flows.Flow, error) {

// MarshalJSON marshals this flow into JSON
func (f *flow) MarshalJSON() ([]byte, error) {
var fe = &flowEnvelope{
UUID: f.uuid,
Name: f.name,
Language: f.language,
ExpireAfterMinutes: f.expireAfterMinutes,
UI: f.ui,
var fe = &flowEnvelopeWithUI{
flowEnvelope: flowEnvelope{
UUID: f.uuid,
Name: f.name,
Language: f.language,
ExpireAfterMinutes: f.expireAfterMinutes,
},
UI: f.ui,
}

if f.localization != nil {
Expand Down

0 comments on commit c416b42

Please sign in to comment.