为 Devin 指定你的 OpenAPI 规范
首先告诉 Devin 规范文件位于何处,以及要实现哪个资源。Devin 会读取 YAML 中的每个路径、schema 和错误定义,然后与现有的 Express 路由进行交叉比对,自动匹配既有约定。下面是 Devin 能处理的这类规范的一个节选——针对 bookings 资源的标准 OpenAPI 3.0 定义:If your spec isn’t checked into the repo yet, paste it directly into the session or attach the YAML/JSON file when starting.
Devin matches your Express patterns
The single most impactful thing you can do is reference a well-implemented resource in your codebase. Devin studies that code and replicates the folder structure, naming conventions, middleware chain, and error handling — so the new endpoints look like they were written by the same developer.For example, Devin reads Devin also derives Zod schemas directly from the OpenAPI component definitions, so request validation stays in sync with the spec:请确保你的仓库设置中包含测试数据库配置和所有所需的环境变量,以便 Devin 能够在本地运行完整的测试套件。如果你的 API 需要凭据 (数据库 URL、JWT 密钥等) ,请在开始会话前将其添加为 Secrets,或在会话期间通过聊天提供。
src/api/v2/users/router.ts and produces a matching bookings router:Devin delivers a tested PR
Devin reads the spec, studies your existing code, and implements each endpoint to match both the OpenAPI contract and your Express codebase conventions. Here’s what a typical PR looks like:Devin runs the Supertest suite before opening the PR:
使用 Devin Review 审查此 PR
一旦 Devin 创建 PR,使用 Devin Review 来审查实现。Devin Review 可以发现诸如缺少错误处理、响应格式不一致,或者端点与规范不匹配之类的问题。如果 Devin Review 指出了问题,你可以使用 Autofix 让 Devin 自动修复这些被标记的问题——它会开启一个后续会话,应用修复,并推送更新后的提交,而你无需手动逐一描述每项更改。
