Skip to content

Commit 3289e73

Browse files
committed
feat: support workflow version in run requests
1 parent a1dad15 commit 3289e73

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

api/src/main/java/com/coze/openapi/client/workflows/run/RunWorkflowReq.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,11 @@ public class RunWorkflowReq extends BaseReq {
5555
* */
5656
@JsonProperty("app_id")
5757
private String appID;
58+
59+
/*
60+
* The version number of the workflow is only valid when the running workflow belongs to the
61+
* resource library workflow. If no version number is specified, the latest version is used.
62+
* */
63+
@JsonProperty("workflow_version")
64+
private String workflowVersion;
5865
}

api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.coze.openapi.client.workflows.run.model.WorkflowEvent;
2222
import com.coze.openapi.client.workflows.run.model.WorkflowEventType;
2323
import com.coze.openapi.utils.Utils;
24+
import com.fasterxml.jackson.databind.JsonNode;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
2426

2527
import io.reactivex.subscribers.TestSubscriber;
2628
import okhttp3.MediaType;
@@ -31,6 +33,8 @@
3133

3234
public class WorkFlowRunServiceTest {
3335

36+
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
37+
3438
private String eventData =
3539
"id: 0\n"
3640
+ "event: Message\n"
@@ -157,6 +161,22 @@ void testCreate() throws Exception {
157161
assertEquals(50, result.getUsage().getOutputCount());
158162
}
159163

164+
@Test
165+
void testRunWorkflowReqSerializesWorkflowVersion() throws Exception {
166+
RunWorkflowReq req =
167+
RunWorkflowReq.builder()
168+
.workflowID("test_workflow_id")
169+
.appID("test_app_id")
170+
.workflowVersion("1.2.3")
171+
.build();
172+
173+
JsonNode json = OBJECT_MAPPER.readTree(OBJECT_MAPPER.writeValueAsString(req));
174+
175+
assertEquals("1.2.3", json.get("workflow_version").asText());
176+
assertEquals("test_workflow_id", json.get("workflow_id").asText());
177+
assertEquals("test_app_id", json.get("app_id").asText());
178+
}
179+
160180
@Test
161181
void testHistories() {
162182
// 验证 histories 方法

0 commit comments

Comments
 (0)