1.0.0 |
|
---|
#224 在 #rocket
51KB
1K SLoC
RocketAPI
第一次尝试从使用 rocket proc_macros 定义路径的项目生成 OpenApi 3.0 yaml 文件
用法
安装 roapi 后有两种使用方法
cargorocketapi
将尝试遍历 ./src
文件夹以查找 rust 文件并尝试生成 OAS
cargorocketapi 文件名
将尝试从单个文件生成 OAS
Cargo.toml 添加
您可以在 Cargo.toml 文件中通过添加以下内容来指定自定义服务器
[rocketapi]
servers = ["https://127.0.0.1:8000", "http://127.0.0.1:8000"]
功能
这是一个 WIP,直到我得到足够的帮助使其更加完整。对于 1.0 版本,只有每个路由都挂载在 "/" 并且结构在全局上是唯一的工程才会被处理。
解析挂载点和确定完整路径以及处理命名空间对于 v1.0 版本来说有点超出我的范围。帮助总是受欢迎的
已实现
- Find paths (does not handle the mountpount paths)
- Find input parameters for path and where they are located
- Use function comment as path comment
- Find type and limits for common input parameters (i8-u128,floats, doubles, strings)
- Find in all rust files under ./src
- Describe custom structures
- Option<types> to be marked as not required in spec
- Create a component tree from all the used structures
- Match component to parameter for special custom types
- Form<types> to be marked as formData
- Take project information from the Cargo file, and allow extra info in the cargo file for this
- Release 1.0 and maybe rename project to something better
计划(按实施可能性排序)
- Try to determine tags by filename the route was defined in
- Support Enums
- Support nested structs
- Try to determine outputs from a route
- Use rocket::mount to determine entire path
安装
cargo install cargo-rocketapi
依赖
~12–22MB
~341K SLoC