Loading...
Loading...
Compare original and translation side by side
references/wso2-rest-api-design-guidelines.mdreferences/wso2-rest-api-design-guidelines.md"What would you like to build? Describe your service in a sentence or two."
“您想要构建什么?用一两句话描述您的服务。”
"Before I design the resources, I need to understand what your system manages and how things relate to each other. Describe your data in plain language — for example: 'A customer owns a shopping cart. The cart has items. Each item refers to a product.' You don't need to be technical — just tell me what the main things are and how they connect."
"Here's what I understand:
- Customer — owns a shopping cart
- Cart — belongs to a customer; contains items
- CartItem — belongs to a cart; references a product
- Product — standalone catalog entry
Does this look right? Anything missing or different?"
“在设计资源之前,我需要了解您的系统管理的内容以及各内容间的关联。用通俗语言描述您的数据——例如:‘客户拥有购物车,购物车包含商品项,每个商品项关联一个产品。’无需使用技术术语,只需告诉我核心对象及其关联方式即可。”
“我的理解如下:
- Customer — 拥有购物车
- Cart — 属于客户;包含商品项
- CartItem — 属于购物车;关联产品
- Product — 独立的目录条目
是否正确?有没有遗漏或需要调整的地方?”
references/wso2-rest-api-design-guidelines.md"Based on your data model, here are the resources I'd design:GET /products — List all products POST /products — Add a product GET /products/{productId} — Get a product PUT /products/{productId} — Update a product DELETE /products/{productId} — Remove a product GET /customers/{customerId}/cart — Get a customer's cart POST /customers/{customerId}/cart/items — Add an item to the cart DELETE /customers/{customerId}/cart/items/{itemId} — Remove an item from the cart POST /customers/{customerId}/cart/checkout — Checkout the cartDo these look right? Anything missing, renamed, or that doesn't fit?"
references/wso2-rest-api-design-guidelines.md“基于您的数据模型,我设计的资源如下:GET /products — 列出所有产品 POST /products — 添加产品 GET /products/{productId} — 获取单个产品 PUT /products/{productId} — 更新产品 DELETE /products/{productId} — 删除产品 GET /customers/{customerId}/cart — 获取客户的购物车 POST /customers/{customerId}/cart/items — 向购物车添加商品项 DELETE /customers/{customerId}/cart/items/{itemId} — 从购物车移除商品项 POST /customers/{customerId}/cart/checkout — 结账这些资源是否符合需求?有没有遗漏、需要重命名或不合适的地方?”
"Before I build the outline, here's what I'm planning — let me know if anything should change:
- Format — JSON only. <add XML if context suggests it, e.g. enterprise/B2B integrations>
- Version — v1.0.
- Authentication — <suggest based on context, e.g. "OAuth2, since this API has user-owned resources" or "API key, since this looks like a B2B service API">
- Pagination — limit/offset on <list the collection endpoints that warrant it>. <omit if there are no collection GETs>"
undefined“在生成大纲之前,我的规划如下——如有需要调整的地方请告知:
- 格式 — 仅JSON。<如果上下文需要,可添加XML,例如企业/B2B集成场景>
- 版本 — v1.0。
- 认证 — <根据上下文建议,例如“OAuth2,因为此API包含用户自有资源”或“API密钥,因为这看起来是B2B服务API”>
- 分页 — 在<列出需要分页的集合端点>上使用limit/offset。 <如果没有集合GET请求则省略>”
undefined
After presenting:
> "Does this outline look good, or would you like any changes before I generate the spec?"
---
展示大纲后:
> “此大纲是否符合需求?在生成规范之前是否需要调整?”
---"Updated. Anything else, or ready to generate?"
"WSO2 guidelines recommend kebab-case paths — I'd suggestrather than/order-items. Want me to apply the guideline, or keep your preference?"/orderItems
“已更新。还有其他修改吗?还是可以开始生成规范了?”
“WSO2准则推荐使用短横线分隔(kebab-case)路径——我建议使用而非/order-items。您希望遵循准则,还是保留您的偏好?”/orderItems
"Generating your OpenAPI spec…"
openapi: "3.0.3"infov1.0serverstagspathscomponents.schemascomponents.securitySchemesoperationIdlistProductscreateOrdergetOrderByIdsummarydescriptiontagsparameterslimitoffsetrequestBody$refresponses{ count, next, previous, data: [...] }LocationContent-LocationErrorIf-MatchIf-Unmodified-SinceErrorRetry-AfterErrorreferences/wso2-rest-api-design-guidelines.mdexample:description:summary:Any string value that contains prose with punctuation must be double-quoted (or written as ablock scalar). "Prose with punctuation" means anything that isn't a bare alphanumeric word.>-
'`< >{ }[ ]-: #> | & * ! % @ ?undefined“正在生成您的OpenAPI规范……”
openapi: "3.0.3"infov1.0serverstagspathscomponents.schemascomponents.securitySchemesoperationIdlistProductscreateOrdergetOrderByIdsummarydescriptiontagsparameterslimitoffsetrequestBody$refresponses{ count, next, previous, data: [...] }LocationContent-LocationErrorIf-MatchIf-Unmodified-SinceErrorRetry-AfterErrorreferences/wso2-rest-api-design-guidelines.mdexample:description:summary:任何包含标点符号的文本字符串必须使用双引号包裹(或写成块标量)。“包含标点符号的文本”指非纯字母数字的内容。>-
'`< >{ }[ ]-: #> | & * ! % @ ?undefinedAuthorization: Bearer <token>Authorization: Bearer <token>Authorization: Bearer <token>
Also keep example **shapes** matching their schema: don't write `example:` as a YAML sequence (`- ...`) under a schema whose `type` is `object`. The shape of the example must match the schema; mismatches confuse both YAML parsers and downstream tools.
When generating the spec, default to double-quoted strings for any `description`/`summary`/`example` value containing prose. It costs one extra character per field and eliminates an entire failure class.
**Pagination envelope.** This is the most-frequently-missed item from the outline. Every collection GET response must use the `{ count, next, previous, data: [...] }` envelope shape from Step 4, not a bare array. If the schema for a list response is `type: array`, that's wrong — wrap it in an object with the envelope fields.
Save the file as `<api-name>-openapi.yaml` in the current directory. Tell the user:
> "Saved to `<filename>.yaml`."
---Authorization: Bearer <token>
同时确保示例**结构**与schema匹配:不要在`type`为`object`的schema下将`example:`写成YAML序列(`- ...`)。示例的结构必须与schema一致;不匹配会混淆YAML解析器和下游工具。
生成规范时,默认对任何包含文本的`description`/`summary`/`example`值使用双引号包裹。这仅需每个字段多一个字符,却能避免一整类错误。
**分页结构**。这是大纲中最常遗漏的项。每个集合GET响应必须使用步骤4中的`{ count, next, previous, data: [...] }`结构,而非裸数组。如果列表响应的schema是`type: array`,则是错误的——需将其包裹在包含结构字段的对象中。
将文件保存到当前目录,命名为`<api-name>-openapi.yaml`。告知用户:
> “已保存至`<filename>.yaml`。”
---"Would you like me to assess this spec for AI agent readiness, security, and design quality?"
“是否需要我评估此规范的AI Agent适配性、安全性和设计质量?”
"Please share the file path to your OpenAPI spec."
./api-reports/"What would you like to check?
- API Design Guidelines — WSO2 REST design rules (28 checks)
- Security Readiness — OWASP-derived API security checks
- AI Agent Readiness — Spectral rules (69 checks) + AI analysis (11 guideline categories)
You can pick one, a few, or all three."
“请分享您的OpenAPI规范文件路径。”
./api-reports/“您想要检查哪些维度?
- API设计准则 — WSO2 REST设计规则(28项检查)
- 安全适配性 — 基于OWASP的API安全检查
- AI Agent适配性 — Spectral规则(69项检查)+ AI分析(11项准则类别)
您可以选择一个、多个或全部三个维度。”
spectral --version"Spectral CLI is required for this assessment. Install it with:Then confirm here."npm install -g @stoplight/spectral-cli
spectral --versionassess.jsassess.jsspectral --version“此评估需要Spectral CLI。请使用以下命令安装:安装完成后请在此确认。”npm install -g @stoplight/spectral-cli
spectral --versionassess.jsassess.jsassess.js"Running AI analysis — reviewing spec against 11 agent-readiness guideline categories…"
references/agent-readiness-guidelines.mdidassess.jsseverityruleRule 3.3pathpaths./orders.postissuedescriptionfixSuggestion./api-reports/ai-issues.json./api-reports/--ai-issues ./api-reports/ai-issues.jsonassess.jsassess.js./api-reports/assess.jsassess.js“正在运行AI分析——对照11项agent适配性准则类别审查规范……”
references/agent-readiness-guidelines.mdidassess.jsseverityruleRule 3.3pathpaths./orders.postissuedescriptionfixSuggestion./api-reports/ai-issues.json./api-reports/assess.js--ai-issues ./api-reports/ai-issues.jsonassess.js./api-reports/assess.jsassess.jsRunning security rules (OWASP-derived)...Running design guidelines rules (WSO2 REST)...assess.jsassess.jsRunning security rules (OWASP-derived)...Running design guidelines rules (WSO2 REST)...assess.jsassess.js--ai-issuesspectral --versionlsnode <absolute-path-to-skill>/scripts/assess.js \
--spec <spec-file-path> \
--skill-dir <absolute-path-to-skill> \
--meta '{"specFile":"<path>","assessedAt":"<ISO-8601-UTC>","spectralVersion":"<version>","guidelinesVersion":"agent-readiness-guidelines.md","model":"<model-id>"}' \
[--agent] [--security] [--design] \
[--ai-issues ./api-reports/ai-issues.json] \
[--open]--ai-issues ./api-reports/ai-issues.json--agentassess.js--ai-issues--spec--openopenInApiDesignerassess.jsnpm install -g @stoplight/spectral-cliopenInApiDesigneropenInApiDesigneropenInApiDesigner--openassess.jsassess.jsopen <html-path>xdg-open <html-path>start <html-path>assess.jsassess.js--ai-issuesspectral --versionnode <技能绝对路径>/scripts/assess.js \
--spec <规范文件路径> \
--skill-dir <技能绝对路径> \
--meta '{"specFile":"<路径>","assessedAt":"<ISO-8601-UTC>","spectralVersion":"<版本>","guidelinesVersion":"agent-readiness-guidelines.md","model":"<模型ID>"}' \
[--agent] [--security] [--design] \
[--ai-issues ./api-reports/ai-issues.json] \
[--open]--agent--ai-issues ./api-reports/ai-issues.jsonassess.js--ai-issues--spec--openopenInApiDesignerassess.jsnpm install -g @stoplight/spectral-cliopenInApiDesigneropenInApiDesigneropenInApiDesigner--openassess.jsassess.jsopen <HTML路径>xdg-open <HTML路径>start <HTML路径>agentReadiness.spectral.issuesagentReadiness.aiAnalysis.issuessecurityReadiness.spectral.issuesdesignReadiness.spectral.issuesautoFixable: true"Do you have an assessment report JSON? If so, share the path. If not, I can run an assessment first."
assess.js--agent --security --designspectralagentReadiness.spectral.issuesagentReadiness.aiAnalysis.issuessecurityReadiness.spectral.issuesdesignReadiness.spectral.issuesautoFixable: true“您有评估报告JSON文件吗?如果有,请分享路径。如果没有,我可以先运行评估。”
assess.js--agent --security --designspectralautoFixable: trueoperationIdtype: objectRetry-Afterpaths-no-trailing-slashpath-casingpaths-no-http-verbsautoFixable: falseautoFixable: trueoperationIdtype: objectRetry-Afterpaths-no-trailing-slashpath-casingpaths-no-http-verbsautoFixable: falsepathpaths./orders.post.operationIdpaths/orderspostoperationIdfixSuggestionpathpaths./orders.post.operationIdpaths/orderspostoperationIdfixSuggestion"The following fixes rename path URLs. This is a breaking change for any existing clients using these endpoints:
→/users/(trailing slash removal)/users →/getUsers(HTTP verb removal)/usersConfirm to apply, or say 'skip' to leave these unchanged."
paths:$ref“以下修复会重命名路径URL。这对使用这些端点的现有客户端来说是破坏性变更:
→/users/(移除尾部斜杠)/users →/getUsers(移除HTTP动词)/users请确认是否应用,或说‘跳过’以保持原样。”
paths:$reffixSuggestionpath"I'll add the following content — confirm to apply, or let me know what to change:
: "Returns a paginated list of all registered users."paths./users.get.description : "Creates a new user account." ..."paths./users.post.description
fixSuggestionpath“我将添加以下内容——请确认是否应用,或告知需要修改的地方:
: "返回所有注册用户的分页列表。"paths./users.get.description : "创建新用户账户。" ..."paths./users.post.description
"Fix complete. Applied (N issues): spec-001, des-003, ai-007 … Skipped — path-rename (N): des-010, des-011 (not confirmed) Requires manual action (N): sec-001 — OAuth scheme configuration requires architectural decisions; see the fixSuggestion in the report.The spec athas been updated in place."<path>
“修复完成。 已应用(N个问题): spec-001, des-003, ai-007 … 已跳过——路径重命名(N个): des-010, des-011(未确认) 需手动操作(N个): sec-001 — OAuth方案配置需要架构决策;请查看报告中的fixSuggestion。位于的规范已就地更新。”<路径>
references/wso2-rest-api-design-guidelines.mdreferences/agent-readiness-guidelines.mdreferences/ai-readiness-metadata.jsonreferences/owasp-top-10-metadata.jsonreferences/wso2-design-guidelines-metadata.jsonreferences/report-schema.mdreferences/wso2-rest-api-design-guidelines.mdreferences/agent-readiness-guidelines.mdreferences/ai-readiness-metadata.jsonreferences/owasp-top-10-metadata.jsonreferences/wso2-design-guidelines-metadata.jsonreferences/report-schema.md