Vasara
Vasara (finnish: hammer) Extract Rest API json file for easy access by user and ignore unused element., (*1)
Getting Started
This package use for laravel only (lumen not tested yet). Extracting a single Rest API json file to an object. Separate value to info, and routes., (*2)
Rest API Json FIle
Now only support postman file. We will update for another json file in the future., (*3)
Installation
Require this package in your composer.json and run composer update (or run composer require composer require dyned/vasara directly)., (*4)
composer require dyned/vasara
After updating composer, add the ServiceProvider to the providers array in config/app.php, (*5)
DynEd\Vasara\VasaraServiceProvider::class
You need to publish the config file for this package. This will add the file config/vasara.php, where you can configure this package., (*6)
$ php artisan vendor:publish --provider="DynEd\Vasara\VasaraServiceProvider" --tag=config
Usage
Instantiate a vasara object with json content., (*7)
$vasara = new Vasara($json);
Or, (*8)
You can create it by access file directly using laravel File Facades., (*9)
$file = File::get('/path/to/postman/json/file.json');
$vasara = new Vasara($file);
Change host of url with proper url, (*10)
$vasara->changeHost('http://localhost:8181');
Tell vasara to collect all data from json file, (*11)
$vasara->run();
Check postman route existence to return laravel abort function., (*12)
if ( ! $vasara->routeExist()) {
abort(404, 'Route not found');
}
Retrieve all routes from json., (*13)
$vasara->getRoutes();
Another functions
- Retrieve all informations.
$vasara->getInfo();
Return value
Collection {#2343 ▼
#items: array:18 [▼
0 => {#200 ▼
+"name": "[Auth] Login"
+"description": "Retrieve user token"
+"method": "POST"
+"header": "[]"
+"body": "{"email":"email@example.com","password":"secret"}"
+"url": {#2344 ▼
+"host": "http://localhost:8000"
+"path": "auth/login"
+"full": "http://localhost:8000/auth/login"
}
}
1 => {#2345 ▶}
2 => {#2347 ▶}
3 => {#2349 ▶}
4 => {#2351 ▶}
5 => {#2353 ▶}
6 => {#2355 ▶}
7 => {#2357 ▶}
8 => {#2359 ▶}
9 => {#2361 ▶}
10 => {#2363 ▶}
11 => {#2365 ▶}
12 => {#2367 ▶}
13 => {#2369 ▶}
14 => {#2371 ▶}
15 => {#2373 ▶}
16 => {#2375 ▶}
17 => {#2377 ▶}
]
}
Authors
Owner
This package published on behalf of DynEd International, Inc., (*14)
License
This project is licensed under the MIT License - see the LICENSE.md file for details., (*15)