fixwa/http-client-collection-generator

Generate Insomnia(r) collection.

1.3 2022-09-30 18:12 UTC

This package is auto-updated.

Last update: 2024-04-29 05:16:33 UTC


README

This tool was created to facilitate the generation of import files (in JSON format) compatible with HTTP-Clients/API-Clients like Postman or Insomnia to programmatically collect requests and automate such task for documentation or analysis purposes.

Currently, only INSOMNIA is supported.

Installation and Usage

composer require --dev fixwa/http-client-collection-generator
$generator = new Fixwa\HttpClientCollectionGenerator\Insomnia\Generator();

$generator->name('The Collection')
    ->group('Pokedex API')
    ->addRequest([
        'name' => 'Get Vaporeon Info',
        'url' => 'https://pokeapi.co/api/v2/pokemon/vaporeon',
        'method' => 'GET',
        'description' => 'Obtain information about the gorgeous Vaporeon'
    ]);
$generator->generateJson();

the code above will return a JSON string that can be used directly in Insomnia to import from clipboard or saved to a file and import it using the option: CREATE -> Import From

Import Insomnia

For the given example, the imported collection should look like the following:

Imported Insomnia

TODOs (ETA 2099)

This is a very basic version that will cover the basic needs. Pending features are:

  • Output to file.
  • Import requests directly from php-curl extension.
  • Import requests directly from Guzzle.
  • Support other major HTTP Clients (Postman, Testfully.io, Thunder).