https://github.com/dwolfhub/apidocscontroller
Laravel controller class that allows for output of API docs if the "accept" header is not set to json.
https://github.com/dwolfhub/apidocscontroller
Last synced: 10 months ago
JSON representation
Laravel controller class that allows for output of API docs if the "accept" header is not set to json.
- Host: GitHub
- URL: https://github.com/dwolfhub/apidocscontroller
- Owner: dwolfhub
- License: mit
- Created: 2014-01-09T22:01:12.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-10T17:08:16.000Z (about 12 years ago)
- Last Synced: 2025-01-19T06:44:09.069Z (12 months ago)
- Language: PHP
- Size: 172 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ApiDocsController
Laravel controller class that allows for output of API docs if the "accept" header is not set to json.
### Set up
Add the following to your composer.json and composer update / composer install
```json
{
"require": {
"dwolf555/api-docs-controller": "dev-master"
}
}
```
Add the following to your app/config/app.php providers array
```php
'Dwolf555\ApiDocsController\ApiDocsControllerServiceProvider',
```
### Example Controller
```php
class UserController extends Dwolf555\ApiDocsController\ApiDocsController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// For documentation
$this->apiDocInfo = [
'wordOfWarning' => 'Just be ok, ok?',
'exampleResponse' => ['message' => 'ok'],
'inputs' => [
'limit' => 10,
'offset' => 0
],
'possibleErrors' => [
'limit' => 'Limit must be a valid integer.',
'offset' => 'Limit must be a valid integer.',
]
];
$content = array(
'actualcontent' => 'realstuff'
);
$statusCode = 200;
return $this->generateResponse($content, $statusCode);
}
}
```
### Example Output
