matijajanc/postman

Postman file generator

Installs: 161

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

1.0.0 2021-11-02 14:32 UTC

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

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