matijajanc / postman
Postman file generator
Installs: 161
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.0
- ext-json: *
Requires (Dev)
- orchestra/testbench: >=6.0
This package is auto-updated.
Last update: 2024-10-29 06:36:25 UTC
README
Installation
composer require matijajanc/postman
Laravel
Publish config file
php artisan vendor:publish --provider="Matijajanc\Postman\Providers\PostmanServiceProvider"
Lumen
add below line to bootstrap/app.php
$app->register(Matijajanc\Postman\Providers\PostmanLumenServiceProvider::class);
Publish config file
cp vendor/matijajanc/postman/config/postman.php config/postman.php
Run command to generate Postman files
php artisan postman:generate
This command generates 2 files:
- postman-environment.json (where variables are defined)
- postman.json (where all API routes are defined)
Currently it supports bearer token authorization, if you have other wishes please create new issue or pull request on github and I'll add/extend it.
Requirements
- Laravel 8 or Lumen 8 (it works with older version of Laravel/Lumen also, but you need to provide "method" property in Postman attribute definition)
- PHP ^8.0
- If you want to use JWT bearer token then you need to configure it first https://jwt-auth.readthedocs.io/en/develop/laravel-installation/
PHP 8 attributes
I used new PHP 8 attributes feature to define new properties I use for postman file generator. This is not needed to define for GET, DELETE routes, you provide this Postman attribute only where you want your custom request payload POST, PUT.
Usages
If no method is provided it calls default factory "definition" method
#[Postman(['factory' => ContractFactory::class])]
public function createContract(Request $request): JsonResponse
You can override which methods get called with additional "method" property
#[Postman(['factory' => ContractFactory::class, 'method' => 'postCreateContract'])]
public function createContract(Request $request): JsonResponse
You can override body type with property "mode"
#[Postman(['factory' => ContractFactory::class, 'method' => 'postCreateContract', 'mode' => 'raw'])]
public function createContract(Request $request): JsonResponse