Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions model/task_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type HTTPArguments struct {
Body json.RawMessage `json:"body,omitempty"`
Query map[string]interface{} `json:"query,omitempty"`
Output string `json:"output,omitempty" validate:"omitempty,oneof=raw content response"`
Redirect bool `json:"redirect,omitempty"`
}

type CallOpenAPI struct {
Expand All @@ -51,6 +52,7 @@ type OpenAPIArguments struct {
Parameters map[string]interface{} `json:"parameters,omitempty"`
Authentication *ReferenceableAuthenticationPolicy `json:"authentication,omitempty"`
Output string `json:"output,omitempty" validate:"omitempty,oneof=raw content response"`
Redirect bool `json:"redirect,omitempty"`
}

type CallGRPC struct {
Expand Down
20 changes: 14 additions & 6 deletions model/task_call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestCallHTTP_MarshalJSON(t *testing.T) {
Query: map[string]interface{}{
"q": "search",
},
Output: "content",
Output: "content",
Redirect: true,
},
}

Expand All @@ -64,7 +65,8 @@ func TestCallHTTP_MarshalJSON(t *testing.T) {
"endpoint": "http://example.com",
"headers": {"Authorization": "Bearer token"},
"query": {"q": "search"},
"output": "content"
"output": "content",
"redirect": true
}
}`, string(data))
}
Expand All @@ -83,7 +85,8 @@ func TestCallHTTP_UnmarshalJSON(t *testing.T) {
"endpoint": "http://example.com",
"headers": {"Authorization": "Bearer token"},
"query": {"q": "search"},
"output": "content"
"output": "content",
"redirect": true
}
}`

Expand All @@ -102,6 +105,7 @@ func TestCallHTTP_UnmarshalJSON(t *testing.T) {
assert.Equal(t, map[string]string{"Authorization": "Bearer token"}, callHTTP.With.Headers)
assert.Equal(t, map[string]interface{}{"q": "search"}, callHTTP.With.Query)
assert.Equal(t, "content", callHTTP.With.Output)
assert.Equal(t, true, callHTTP.With.Redirect)
}

func TestCallOpenAPI_MarshalJSON(t *testing.T) {
Expand Down Expand Up @@ -133,7 +137,8 @@ func TestCallOpenAPI_MarshalJSON(t *testing.T) {
Authentication: &ReferenceableAuthenticationPolicy{
Use: &authPolicy,
},
Output: "content",
Output: "content",
Redirect: true,
},
}

Expand All @@ -160,7 +165,8 @@ func TestCallOpenAPI_MarshalJSON(t *testing.T) {
"authentication": {
"use": "my-auth"
},
"output": "content"
"output": "content",
"redirect": true
}
}`, string(data))
}
Expand All @@ -187,7 +193,8 @@ func TestCallOpenAPI_UnmarshalJSON(t *testing.T) {
"authentication": {
"use": "my-auth"
},
"output": "content"
"output": "content",
"redirect": true
}
}`

Expand All @@ -207,6 +214,7 @@ func TestCallOpenAPI_UnmarshalJSON(t *testing.T) {
assert.Equal(t, map[string]interface{}{"param1": "value1", "param2": "value2"}, callOpenAPI.With.Parameters)
assert.Equal(t, "my-auth", *callOpenAPI.With.Authentication.Use)
assert.Equal(t, "content", callOpenAPI.With.Output)
assert.Equal(t, true, callOpenAPI.With.Redirect)
}

func TestCallGRPC_MarshalJSON(t *testing.T) {
Expand Down
Loading