Explorar o código

Merge pull request #6 from mpociot/master

Update from base
Shalvah A %!s(int64=6) %!d(string=hai) anos
pai
achega
1d5b871108
Modificáronse 2 ficheiros con 131 adicións e 0 borrados
  1. 104 0
      tests/Fixtures/partial_resource_index.md
  2. 27 0
      tests/GenerateDocumentationTest.php

+ 104 - 0
tests/Fixtures/partial_resource_index.md

@@ -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 - 0
tests/GenerateDocumentationTest.php

@@ -127,6 +127,33 @@ class GenerateDocumentationTest extends TestCase
         $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');