Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function show($id)
#### @transformer, @transformerCollection, and @transformerModel
You can define the transformer that is used for the result of the route using the `@transformer` tag (or `@transformerCollection` if the route returns a list). The package will attempt to generate an instance of the model to be transformed using the following steps, stopping at the first successful one:

1. Check if there is a `@transformerModel` tag to define the model being transformed. If there is none, use the class of the first parameter to the method.
1. Check if there is a `@transformerModel` tag to define the model being transformed. If there is none, use the class of the first parameter to the transformer's `transform()` method.
2. Get an instance of the model from the Eloquent model factory
2. If the parameter is an Eloquent model, load the first from the database.
3. Create an instance using `new`.
Expand Down
56 changes: 56 additions & 0 deletions config/apidoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,62 @@
// 'Authorization' => 'Bearer: {token}',
// 'Api-Version' => 'v2',
],

/*
* If no @response or @transformer declaratons are found for the route,
* we'll try to get a sample response by attempting an API call.
* Configure the settings for the API call here,
*/
'response_calls' => [
/*
* What HTTP methods (GET, POST, etc) should API calls be made for. List the methods here
* or use '*' to mean all methods. Set to false to disable API calls.
*/
'methods' => ['*'],

/*
* For URLs which have parameters (/users/{user}, /orders/{id?}),
* specify what values the parameters should be replaced with.
* Note that you must specify the full parameter, including curly brackets and question marks if any.
*/
'bindings' => [
// '{user}' => 1
],

/*
* Environment variables which should be set for the API call.
*/
'env' => [
'APP_ENV' => 'documentation',
'APP_DEBUG' => false,
// 'env_var' => 'value',
],

/*
* Headers which should be sent with the API call.
*/
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
// 'key' => 'value',
],


/*
* Query parameters which should be sent with the API call.
*/
'query' => [
// 'key' => 'value',
],


/*
* Body parameters which should be sent with the API call.
*/
'body' => [
// 'key' => 'value',
],
],
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private function processRoutes(AbstractGenerator $generator, array $routes)
$route = $routeItem['route'];
/** @var Route $route */
if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
$parsedRoutes[] = $generator->processRoute($route) + $routeItem['apply'];
$parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']);
$this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
} else {
$this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
Expand Down
Loading