andreaselia/laravel-api-to-postman

自动从您的Laravel API生成Postman集合

v2.0.6 2024-07-23 15:33 UTC

README

Laravel API to Postman Header

Latest Stable Version StyleCI

Laravel API to Postman

此包允许您根据API路由自动生成Postman集合。它还提供了对位于认证中间件之后的路由的bearer认证令牌和基本认证的基本配置和支持。

对于使用FormRequest的POSTPUT请求,您可以可选地构建请求,并以原始或可读格式发布规则。

Postman Schema

生成器适用于发布时的最新Postman Schema版本(v2.1.0)。

安装

安装包

composer require andreaselia/laravel-api-to-postman

发布配置文件

php artisan vendor:publish --provider="AndreasElia\PostmanGenerator\PostmanGeneratorServiceProvider" --tag="postman-config"

配置

您可以修改任何api-postman.php配置值以符合您的导出需求。

点击这里查看配置属性。

用法

命令运行的输出是您的storage/app目录。

要使用该命令,只需运行

php artisan export:postman

以下用法将生成带有指定bearer令牌的路由。

php artisan export:postman --bearer="1|XXNKXXqJjfzG8XXSvXX1Q4pxxnkXmp8tT8TXXKXX"

以下用法将生成带有指定基本认证的路由。

php artisan export:postman --basic="username:password123"

如果指定了两种认证方式,将优先使用bearer。

示例

这是默认配置和传入bearer令牌的情况

php artisan export:postman --bearer=123456789

贡献

您随时可以提交一个拉取请求,或者如果您觉得没有心情 - 创建一个问题,以便其他人可以接手。