Skip to content

Commit 2f49e87

Browse files
authored
Merge pull request #2 from AndreasElia/feature/option-values
config options and typo fix
2 parents 8951e57 + ddc300f commit 2f49e87

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ To use the command simply run:
2929
php artisan export:postman
3030
```
3131

32-
You can also supply the `--structured` option to nest the routes into folders based on their name, or `--bearer` to create a bearer authorization token which can be managed in a single place within variables.
33-
34-
The output Postman collection will have a `base_url` variable set by default for ease of use.
32+
- `--structured` generates routes in folders based on their namespace
33+
- `--bearer=<token>` generates a token variable in Postman for the specified token
34+
- `--base-url=<base_url>` defaults to https://api.example.com/ unless specified
3535

3636
## Contributing
3737

38-
You're more that welcome to submit a pull request, or if you're not feeling up to it - create an issue so someone else can pick it up.
38+
You're more than welcome to submit a pull request, or if you're not feeling up to it - create an issue so someone else can pick it up.

src/ExportPostman.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
class ExportPostman extends Command
1010
{
1111
/** @var string */
12-
protected $signature = 'export:postman {--structured} {--bearer}';
12+
protected $signature = '
13+
export:postman
14+
{--structured= : If you want folders to be generated based on namespace}
15+
{--base-url= : The base URL for all of your endpoints}
16+
{--bearer= : The bearer token to use on your endpoints}
17+
';
1318

1419
/** @var string */
1520
protected $description = 'Automatically generate a Postman collection for your API routes';
@@ -27,13 +32,14 @@ public function __construct(Router $router)
2732
public function handle(): void
2833
{
2934
$structured = $this->option('structured') ?? false;
35+
$baseUrl = $this->option('base-url') ?? 'https://api.example.com/';
3036
$bearer = $this->option('bearer') ?? false;
3137

3238
$this->routes = [
3339
'variable' => [
3440
[
3541
'key' => 'base_url',
36-
'value' => 'https://api.example.com/',
42+
'value' => $baseUrl,
3743
],
3844
],
3945
'info' => [
@@ -46,7 +52,7 @@ public function handle(): void
4652
if ($bearer) {
4753
$this->routes['variable'][] = [
4854
'key' => 'token',
49-
'value' => '1|token',
55+
'value' => $bearer,
5056
];
5157
}
5258

0 commit comments

Comments
 (0)