|
@@ -231,18 +231,17 @@ class GenerateDocumentationTest extends TestCase
|
|
|
{
|
|
|
RouteFacade::get('/api/withDescription', [TestController::class, 'withEndpointDescription']);
|
|
|
RouteFacade::post('/api/withFormDataParams', TestController::class . '@withFormDataParams');
|
|
|
- RouteFacade::get('/api/withResponseTag', TestController::class . '@withResponseTag');
|
|
|
RouteFacade::post('/api/withBodyParameters', TestController::class . '@withBodyParameters');
|
|
|
RouteFacade::get('/api/withQueryParameters', TestController::class . '@withQueryParameters');
|
|
|
RouteFacade::get('/api/withAuthTag', TestController::class . '@withAuthenticatedTag');
|
|
|
- RouteFacade::get('/api/withEloquentApiResource', [TestController::class, 'withEloquentApiResource']);
|
|
|
- RouteFacade::get('/api/withEloquentApiResourceCollectionClass', [TestController::class, 'withEloquentApiResourceCollectionClass']);
|
|
|
- RouteFacade::post('/api/withMultipleResponseTagsAndStatusCode', [TestController::class, 'withMultipleResponseTagsAndStatusCode']);
|
|
|
RouteFacade::get('/api/echoesUrlParameters/{param}-{param2}/{param3?}', [TestController::class, 'echoesUrlParameters']);
|
|
|
// We want to have the same values for params each time
|
|
|
config(['scribe.faker_seed' => 1234]);
|
|
|
config(['scribe.title' => 'GREAT API!']);
|
|
|
config(['scribe.routes.0.match.prefixes' => ['api/*']]);
|
|
|
+ config(['scribe.postman.overrides' => [
|
|
|
+ 'info.version' => '3.9.9',
|
|
|
+ ]]);
|
|
|
config([
|
|
|
'scribe.routes.0.apply.headers' => [
|
|
|
'Custom-Header' => 'NotSoCustom',
|
|
@@ -258,47 +257,22 @@ class GenerateDocumentationTest extends TestCase
|
|
|
$this->assertEquals($fixtureCollection, $generatedCollection);
|
|
|
}
|
|
|
|
|
|
- /** @test */
|
|
|
- public function can_override_fields_in_generated_postman_collection_file()
|
|
|
- {
|
|
|
- RouteFacade::get('/api/withDescription', [TestController::class, 'withEndpointDescription']);
|
|
|
- RouteFacade::get('/api/withResponseTag', TestController::class . '@withResponseTag');
|
|
|
- RouteFacade::post('/api/withBodyParameters', TestController::class . '@withBodyParameters');
|
|
|
- RouteFacade::get('/api/withQueryParameters', TestController::class . '@withQueryParameters');
|
|
|
-
|
|
|
- config(['scribe.faker_seed' => 1234]);
|
|
|
- config(['scribe.postman.enabled' => true]);
|
|
|
- config(['scribe.postman.overrides' => [
|
|
|
- 'info.version' => '3.9.9',
|
|
|
- 'info.name' => 'Custom API',
|
|
|
- ]]);
|
|
|
- config(['scribe.routes.0.match.prefixes' => ['api/*']]);
|
|
|
-
|
|
|
- $this->artisan('scribe:generate');
|
|
|
-
|
|
|
- $generatedCollection = json_decode(file_get_contents(__DIR__ . '/../public/docs/collection.json'), true);
|
|
|
- $generatedCollection['info']['_postman_id'] = '';
|
|
|
- $fixtureCollection = json_decode(file_get_contents(__DIR__ . '/Fixtures/collection-overridden.json'), true);
|
|
|
- $this->assertEquals($fixtureCollection, $generatedCollection);
|
|
|
- }
|
|
|
-
|
|
|
/** @test */
|
|
|
public function generated_openapi_spec_file_is_correct()
|
|
|
{
|
|
|
RouteFacade::get('/api/withDescription', [TestController::class, 'withEndpointDescription']);
|
|
|
RouteFacade::post('/api/withFormDataParams', TestController::class . '@withFormDataParams');
|
|
|
RouteFacade::get('/api/withResponseTag', TestController::class . '@withResponseTag');
|
|
|
- RouteFacade::post('/api/withBodyParameters', TestController::class . '@withBodyParameters');
|
|
|
RouteFacade::get('/api/withQueryParameters', TestController::class . '@withQueryParameters');
|
|
|
RouteFacade::get('/api/withAuthTag', TestController::class . '@withAuthenticatedTag');
|
|
|
- RouteFacade::get('/api/withEloquentApiResource', [TestController::class, 'withEloquentApiResource']);
|
|
|
- RouteFacade::get('/api/withEloquentApiResourceCollectionClass', [TestController::class, 'withEloquentApiResourceCollectionClass']);
|
|
|
- RouteFacade::post('/api/withMultipleResponseTagsAndStatusCode', [TestController::class, 'withMultipleResponseTagsAndStatusCode']);
|
|
|
RouteFacade::get('/api/echoesUrlParameters/{param}-{param2}/{param3?}', [TestController::class, 'echoesUrlParameters']);
|
|
|
|
|
|
// We want to have the same values for params each time
|
|
|
config(['scribe.faker_seed' => 1234]);
|
|
|
config(['scribe.openapi.enabled' => true]);
|
|
|
+ config(['scribe.openapi.overrides' => [
|
|
|
+ 'info.version' => '3.9.9',
|
|
|
+ ]]);
|
|
|
config(['scribe.routes.0.match.prefixes' => ['api/*']]);
|
|
|
config([
|
|
|
'scribe.routes.0.apply.headers' => [
|
|
@@ -313,29 +287,6 @@ class GenerateDocumentationTest extends TestCase
|
|
|
$this->assertEquals($fixtureCollection, $generatedCollection);
|
|
|
}
|
|
|
|
|
|
- /** @test */
|
|
|
- public function can_override_fields_in_generated_openapi_spec_file()
|
|
|
- {
|
|
|
- RouteFacade::get('/api/withDescription', [TestController::class, 'withEndpointDescription']);
|
|
|
- RouteFacade::get('/api/withResponseTag', TestController::class . '@withResponseTag');
|
|
|
- RouteFacade::post('/api/withBodyParameters', TestController::class . '@withBodyParameters');
|
|
|
- RouteFacade::get('/api/withQueryParameters', TestController::class . '@withQueryParameters');
|
|
|
-
|
|
|
- config(['scribe.faker_seed' => 1234]);
|
|
|
- config(['scribe.openapi.enabled' => true]);
|
|
|
- config(['scribe.openapi.overrides' => [
|
|
|
- 'info.version' => '3.9.9',
|
|
|
- 'servers.0.url' => 'http://okay.dev',
|
|
|
- ]]);
|
|
|
- config(['scribe.routes.0.match.prefixes' => ['api/*']]);
|
|
|
-
|
|
|
- $this->artisan('scribe:generate');
|
|
|
-
|
|
|
- $generatedCollection = json_decode(file_get_contents(__DIR__ . '/../public/docs/openapi.yaml'), true);
|
|
|
- $fixtureCollection = json_decode(file_get_contents(__DIR__ . '/Fixtures/openapi-overridden.yaml'), true);
|
|
|
- $this->assertEquals($fixtureCollection, $generatedCollection);
|
|
|
- }
|
|
|
-
|
|
|
/** @test */
|
|
|
public function can_append_custom_http_headers()
|
|
|
{
|