Skip to content

Commit

Permalink
Add omitempty to fields not present in default flogo.json
Browse files Browse the repository at this point in the history
  • Loading branch information
debovema committed Feb 26, 2019
1 parent 966cc75 commit 6031f97
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 49 deletions.
10 changes: 5 additions & 5 deletions action/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import "encoding/json"
// Config is the configuration for the Action
type Config struct {
//inline action
Ref string `json:"ref"`
Type string `json:"type"` //an alias to the ref, can be used if imported
Settings map[string]interface{} `json:"settings"`
Ref string `json:"ref,omitempty"`
Type string `json:"type,omitempty"` //an alias to the ref, can be used if imported
Settings map[string]interface{} `json:"settings,omitempty"`

//referenced action
Id string `json:"id"`
Id string `json:"id,omitempty"`

//DEPRECATED
Data json.RawMessage `json:"data"`
Data json.RawMessage `json:"data,omitempty"`
}
13 changes: 7 additions & 6 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ type Config struct {
Type string `json:"type"`
Version string `json:"version"`
Description string `json:"description"`
AppModel string `json:"appModel"`

Imports []string `json:"imports"`
Properties []*data.Attribute `json:"properties"`
Channels []string `json:"channels"`
Triggers []*trigger.Config `json:"triggers"`
Resources []*resource.Config `json:"resources"`
Actions []*action.Config `json:"actions"`
Imports []string `json:"imports,omitempty"`
Properties []*data.Attribute `json:"properties,omitempty"`
Channels []string `json:"channels,omitempty"`
Triggers []*trigger.Config `json:"triggers,omitempty"`
Resources []*resource.Config `json:"resources,omitempty"`
Actions []*action.Config `json:"actions,omitempty"`
}
4 changes: 2 additions & 2 deletions internal/schema/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 8 additions & 33 deletions internal/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"type",
"version",
"description",
"imports",
"properties",
"channels",
"triggers",
"resources",
"actions"
"appModel"
],
"properties": {
"actions": {
Expand All @@ -20,6 +15,9 @@
},
"type": "array"
},
"appModel": {
"type": "string"
},
"channels": {
"items": {
"type": "string"
Expand Down Expand Up @@ -75,12 +73,7 @@
"type",
"version",
"description",
"imports",
"properties",
"channels",
"triggers",
"resources",
"actions"
"appModel"
],
"properties": {
"actions": {
Expand All @@ -90,6 +83,9 @@
},
"type": "array"
},
"appModel": {
"type": "string"
},
"channels": {
"items": {
"type": "string"
Expand Down Expand Up @@ -140,13 +136,6 @@
"type": "object"
},
"action.Config": {
"required": [
"ref",
"type",
"settings",
"id",
"data"
],
"properties": {
"data": {
"type": "object"
Expand Down Expand Up @@ -188,19 +177,7 @@
"type": "object"
},
"trigger.ActionConfig": {
"required": [
"ref",
"type",
"settings",
"id",
"data",
"Act"
],
"properties": {
"Act": {
"additionalProperties": true,
"type": "object"
},
"data": {
"type": "object"
},
Expand Down Expand Up @@ -232,8 +209,6 @@
"trigger.Config": {
"required": [
"id",
"type",
"ref",
"settings",
"handlers"
],
Expand Down
6 changes: 3 additions & 3 deletions trigger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
// Config is the configuration for a Trigger
type Config struct {
Id string `json:"id"`
Type string `json:"type"` //an alias to the ref, can be used if imported
Ref string `json:"ref"`
Type string `json:"type,omitempty"` //an alias to the ref, can be used if imported
Ref string `json:"ref,omitempty"`
Settings map[string]interface{} `json:"settings"`
Handlers []*HandlerConfig `json:"handlers"`
}
Expand Down Expand Up @@ -94,7 +94,7 @@ type ActionConfig struct {
Input map[string]interface{} `json:"input,omitempty"`
Output map[string]interface{} `json:"output,omitempty"`

Act action.Action
Act action.Action `json:"-,omitempty"`
}

// UnmarshalJSON overrides the default UnmarshalJSON for TaskInst
Expand Down

0 comments on commit 6031f97

Please sign in to comment.