diff --git a/src/Writing/PostmanCollectionWriter.php b/src/Writing/PostmanCollectionWriter.php index 68e97e01..609ca811 100644 --- a/src/Writing/PostmanCollectionWriter.php +++ b/src/Writing/PostmanCollectionWriter.php @@ -77,6 +77,13 @@ protected function generateAuthObject(): array ], "bearer" => [ 'type' => 'bearer', + 'bearer' => [ + [ + 'key' => $this->config->get('auth.name'), + 'value' => $this->config->get('auth.use_value'), + 'type' => 'string', + ], + ], ], default => [ 'type' => 'apikey', diff --git a/tests/Fixtures/collection.json b/tests/Fixtures/collection.json index 25c7a2ed..91b6e990 100644 --- a/tests/Fixtures/collection.json +++ b/tests/Fixtures/collection.json @@ -340,6 +340,13 @@ } ], "auth": { - "type": "bearer" + "type": "bearer", + "bearer": [ + { + "key": "key", + "value": null, + "type": "string" + } + ] } -} \ No newline at end of file +} diff --git a/tests/Unit/PostmanCollectionWriterTest.php b/tests/Unit/PostmanCollectionWriterTest.php index f53c9552..4d4c3b86 100644 --- a/tests/Unit/PostmanCollectionWriterTest.php +++ b/tests/Unit/PostmanCollectionWriterTest.php @@ -224,7 +224,18 @@ public function auth_info_is_added_correctly() $config['auth']['in'] = 'bearer'; $collection = $this->generate($config, [$endpoints]); - $this->assertEquals(['type' => 'bearer'], $collection['auth']); + $expected = [ + 'type' => 'bearer', + 'bearer' => [ + [ + 'key' => null, + 'value' => null, + 'type' => 'string', + ], + ], + ]; + + $this->assertEquals($expected, $collection['auth']); $this->assertArrayNotHasKey('auth', $collection['item'][0]['item'][0]['request']); $this->assertEquals(['type' => 'noauth'], $collection['item'][0]['item'][1]['request']['auth']);