Skip to content
Merged
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
104 changes: 104 additions & 0 deletions tests/Fixtures/partial_resource_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: API Reference

language_tabs:
- bash
- javascript

includes:

search: true

toc_footers:
- <a href='http://github.com/mpociot/documentarian'>Documentation Powered by Documentarian</a>
---
<!-- START_INFO -->
# Info

Welcome to the generated API reference.
[Get Postman Collection](http://localhost/docs/collection.json)

<!-- END_INFO -->

#general
<!-- START_2b6e5a4b188cb183c7e59558cce36cb6 -->
## Display a listing of the resource.

> Example request:

```bash
curl -X GET -G "http://localhost/api/user" \
-H "Accept: application/json"
```

```javascript
var settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost/api/user",
"method": "GET",
"headers": {
"accept": "application/json"
}
}

$.ajax(settings).done(function (response) {
console.log(response);
});
```

> Example response:

```json
{
"index_resource": true
}
```

### HTTP Request
`GET api/user`


<!-- END_2b6e5a4b188cb183c7e59558cce36cb6 -->

<!-- START_7f66c974d24032cb19061d55d801f62b -->
## Show the form for creating a new resource.

> Example request:

```bash
curl -X GET -G "http://localhost/api/user/create" \
-H "Accept: application/json"
```

```javascript
var settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost/api/user/create",
"method": "GET",
"headers": {
"accept": "application/json"
}
}

$.ajax(settings).done(function (response) {
console.log(response);
});
```

> Example response:

```json
{
"create_resource": true
}
```

### HTTP Request
`GET api/user/create`


<!-- END_7f66c974d24032cb19061d55d801f62b -->


27 changes: 27 additions & 0 deletions tests/GenerateDocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,33 @@ public function testCanParseResourceRoutes()
$this->assertFilesHaveSameContent($fixtureMarkdown, $generatedMarkdown);
}

public function testCanParsePartialResourceRoutes()
{
RouteFacade::resource('/api/user', TestResourceController::class, [
'only' => [
'index', 'create'
]
]);
$output = $this->artisan('api:generate', [
'--routePrefix' => 'api/*',
]);
$fixtureMarkdown = __DIR__.'/Fixtures/partial_resource_index.md';
$generatedMarkdown = __DIR__.'/../public/docs/source/index.md';
$this->assertFilesHaveSameContent($fixtureMarkdown, $generatedMarkdown);

RouteFacade::apiResource('/api/user', TestResourceController::class, [
'only' => [
'index', 'create'
]
]);
$output = $this->artisan('api:generate', [
'--routePrefix' => 'api/*',
]);
$fixtureMarkdown = __DIR__.'/Fixtures/partial_resource_index.md';
$generatedMarkdown = __DIR__.'/../public/docs/source/index.md';
$this->assertFilesHaveSameContent($fixtureMarkdown, $generatedMarkdown);
}

public function testGeneratedMarkdownFileIsCorrect()
{
RouteFacade::get('/api/test', TestController::class.'@parseMethodDescription');
Expand Down