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.
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
For the given example, the imported collection should look like the following:
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).