"express"; import type { paths } from "./my-openapi-3-schema"; // OpenAPI のpaths から直接型を取得 type UpdateUserBody = paths["/users/{id}"]["patch"]["requestBody"]["content"]["application/json"]; type UpdateUserPath = paths["/users/{id}"]["patch"]["parameters"]["path"]; type UpdateUserQuery = paths["/users/{id}"]["patch"]["parameters"]["query"]; // Express Request 型に適用 app.patch("/users/:id", async ( req: Request<UpdateUserPath, unknown, UpdateUserBody, UpdateUserQuery>, res: Response ) => { const { id } = req.params; // 型安全! const { name } = req.body; // 型安全! const { sort } = req.query; // 型安全! }); 2025/08/20 | Mita.ts 13