fix: 固定公共工作流接口响应类型

- 统一声明 application/json 响应并补充契约测试
This commit is contained in:
2026-08-03 14:51:34 +08:00
parent de0ccf03aa
commit 0860492446
2 changed files with 28 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import com.easyagents.flow.core.chain.runtime.ChainExecutor;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotBlank;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import tech.easyflow.approval.annotation.RequirePublishedAccess;
import tech.easyflow.ai.easyagentsflow.entity.ChainInfo;
@@ -38,7 +39,7 @@ import java.util.Map;
/**
* 工作流
*/
@RequestMapping("/public-api/workflow")
@RequestMapping(value = "/public-api/workflow", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
public class PublicWorkflowController {

View File

@@ -0,0 +1,26 @@
package tech.easyflow.publicapi.controller;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* {@link PublicWorkflowController} HTTP 响应契约测试。
*/
public class PublicWorkflowControllerContractTest {
/**
* 验证工作流公共 API 明确返回 JSON避免通配 Accept 请求被 CBOR 转换器接管。
*/
@Test
public void shouldDeclareJsonResponseMediaType() {
RequestMapping requestMapping = PublicWorkflowController.class.getAnnotation(RequestMapping.class);
Assert.assertNotNull(requestMapping);
Assert.assertArrayEquals(
new String[]{MediaType.APPLICATION_JSON_VALUE},
requestMapping.produces()
);
}
}