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

@@ -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()
);
}
}