Srd*_*jic 6 api-doc swagger typescript typedoc next.js
我可以使用https://github.com/TypeStrong/typedoc创建 REST API 文档,例如https://apidocjs.com/吗?
欢迎提供有关如何重用 TypeScript 类型来生成 REST API 文档的任何建议(使用 Next.js)
如果您真正想要的是用 TypeScript 描述您的 API 并从中得出 Swagger/OpenAPI 定义,请尝试https://github.com/airtasker/spot
IT 不仅可以生成 REST API 文档,还可以让您使用适合 REST API 定义(用于测试客户端)的随机数据和数据模型验证器(用于测试服务器)运行模拟服务器。
项目自述文件中的示例:
import { api, endpoint, request, response, body } from "@airtasker/spot";
@api({
name: "My API"
})
class Api {}
@endpoint({
method: "POST",
path: "/users"
})
class CreateUser {
@request
request(@body body: CreateUserRequest) {}
@response({ status: 201 })
response(@body body: CreateUserResponse) {}
}
interface CreateUserRequest {
firstName: string;
lastName: string;
}
interface CreateUserResponse {
firstName: string;
lastName: string;
role: string;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6976 次 |
| 最近记录: |