7 个版本 (稳定)
1.2.1 | 2024 年 1 月 31 日 |
---|---|
1.2.0 | 2023 年 11 月 30 日 |
1.1.0 | 2023 年 9 月 13 日 |
1.0.0 | 2022 年 8 月 1 日 |
0.1.0 | 2020 年 8 月 21 日 |
#215 in 数据结构
每月 609 次下载
在 postman2openapi-cli 中使用
185KB
3K SLoC
postman2openapi
将 Postman 集合转换为 OpenAPI 定义。
在线尝试: https://kevinswiber.github.io/postman2openapi/
命令行界面
安装
为 postman2openapi 提供预编译二进制文件的存档,适用于 Windows、macOS 和 Linux。
Linux 二进制文件是静态可执行文件。Windows 二进制文件可以是使用 MinGW (GNU) 或 Microsoft Visual C++ (MSVC) 构建的。如果可能,请优先选择 MSVC,但您需要安装 Microsoft VC++ 2015 redistributable。
对于 Rust 开发者,也可以通过 Cargo 进行安装。 安装 Rust 和 Cargo
要安装 crates.io 上最新发布的版本,使用
cargo install postman2openapi-cli
要从 GitHub 上的最新版本安装,使用
cargo install --git https://github.com/kevinswiber/postman2openapi postman2openapi-cli
使用方法
USAGE:
postman2openapi [OPTIONS] [input-file]
ARGS:
<input-file> The Postman collection to convert; data may also come from stdin
OPTIONS:
-f, --output-format <format> The output format [default: yaml] [possible values: yaml, json]
-h, --help Print help information
-V, --version Print version information
示例
postman2openapi collection.json > openapi.yaml
cat collection.json | postman2openapi -f json
JavaScript 库
安装
npm install postman2openapi
使用方法
const collection = require("./collection"); // any Postman collection JSON file
const { transpile } = require("postman2openapi");
// Returns a JavaScript object representation of the OpenAPI definition.
const openapi = transpile(collection);
console.log(JSON.stringify(openapi, null, 2));
JavaScript API
transpile(collection: object): object
- collection - 表示 Postman 集合的对象。
- 返回值 - 作为 JavaScript 对象的 OpenAPI 定义。
构建
注意:包含了一个 Dev Container 以方便使用。
要利用构建配方,请安装 just。
just build
构建 Rust 库和 CLI 软件包。
just test
运行所有 lint 检查 (cargo fmt --check
, cargo clippy
) 并运行所有测试,包括对 wasm32-unknown-unknown
目标(Node.js、Chrome、Firefox)的测试。
just start-web
构建 WebAssembly 项目并启动本地版本的 postman2openapi 网站。
just prepare
构建 Rust 库、CLI、Node.js 库和网站。然后运行所有测试。
许可证
Apache 许可证 2.0 (Apache-2.0)
依赖关系
~4.5–8.5MB
~147K SLoC