Install any skill in seconds. Free to start, no credit card required.
Get Started Free →doccker/api-design-safety
当设计或修改 REST API 响应结构、处理 API 返回值时触发。防止 API 设计缺陷导致的字段错位、类型歧义等问题。
Passed 21 of 22 test cases with the skill, and 12 of 22 without it.
and 7 more in the full report
9 fixed12 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 9 test cases the skill fixed. Same model, same prompt, with and without the skill.
Our REST API endpoints return inconsistent JSON payloads when queries return no records: sometimes missing user profiles return `{}` and empty order history lists return `null`. How should single entity endpoints vs collection/list endpoints standardly represent 'no data' in their JSON payloads?
| Checked | Without skill | With skill |
|---|---|---|
| Specifies returning null in the data field when a single requested entity is missing. | Missed | Passed |
| Specifies returning an empty array in the data field when a list query returns no items. | Passed | Passed |
The instructions your model reads when the skill loads.
当设计或修改 REST API 响应结构时,防止常见的设计缺陷。
场景: 返回类型为 String 时,Java 重载解析可能匹配错误的方法
Java 方法重载解析时,String 类型参数会优先匹配 success(String message) 而非 success(T data),导致数据进入错误的字段。
// ApiResponse 有两个重载:
public static <T> ApiResponse<T> success(T data)
public static <T> ApiResponse<T> success(String message, T data)
// ❌ 错误: String 类型匹配到 success(String message)
String avatarUrl = "http://example.com/avatar.jpg";
return ApiResponse.success(avatarUrl);
// 结果: {"code":200, "message":"http://...", "data":null}
// 前端 data.data 拿到 null,导致功能异常
// ✅ 方案1: 明确指定 message 参数(推荐)
return ApiResponse.success("上传成功", avatarUrl);
// 结果: {"code":200, "message":"上传成功", "data":"http://..."}
// ✅ 方案2: 使用泛型明确类型
return ApiResponse.<String>success(avatarUrl);
test cases passed, vs 12 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.