Forráskód Böngészése

Fix formatting issues with generated markdown (Fixes #191)

shalvah 6 éve
szülő
commit
5e4ccbd1ef

+ 5 - 4
src/resources/views/partials/route.blade.php

@@ -10,10 +10,11 @@
 > Example request:
 
 ```bash
-curl -X {{$parsedRoute['methods'][0]}} "{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($parsedRoute['uri'], '/') }}" \
--H "Accept: application/json"@if(count($parsedRoute['parameters'])) \
+curl -X {{$parsedRoute['methods'][0]}} {{$parsedRoute['methods'][0] == 'GET' ? '-G ' : ''}}"{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($parsedRoute['uri'], '/') }}" \
+    -H "Accept: application/json"@if(count($parsedRoute['parameters'])) \
 @foreach($parsedRoute['parameters'] as $attribute => $parameter)
-    -d "{{$attribute}}"="{{$parameter['value']}}" \
+    -d "{{$attribute}}"="{{$parameter['value']}}" @if(! ($loop->last))\
+    @endif
 @endforeach
 @endif
 
@@ -26,7 +27,7 @@ var settings = {
     "url": "{{ rtrim(config('app.docs_url') ?: config('app.url'), '/') }}/{{ ltrim($parsedRoute['uri'], '/') }}",
     "method": "{{$parsedRoute['methods'][0]}}",
     @if(count($parsedRoute['parameters']))
-"data": {!! str_replace('    ','        ',json_encode(array_combine(array_keys($parsedRoute['parameters']), array_map(function($param){ return $param['value']; },$parsedRoute['parameters'])), JSON_PRETTY_PRINT)) !!},
+"data": {!! str_replace("\n}","\n    }", str_replace('    ','        ',json_encode(array_combine(array_keys($parsedRoute['parameters']), array_map(function($param){ return $param['value']; },$parsedRoute['parameters'])), JSON_PRETTY_PRINT))) !!},
     @endif
 "headers": {
         "accept": "application/json"

+ 4 - 4
tests/Fixtures/index.md

@@ -30,8 +30,8 @@ It can also be multiple lines long.
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/test" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/test" \
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -68,8 +68,8 @@ null
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/fetch" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/fetch" \
+    -H "Accept: application/json"
 ```
 
 ```javascript

+ 11 - 11
tests/Fixtures/resource_index.md

@@ -27,8 +27,8 @@ Welcome to the generated API reference.
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/user" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/user" \
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -67,8 +67,8 @@ $.ajax(settings).done(function (response) {
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/user/create" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/user/create" \
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -108,7 +108,7 @@ $.ajax(settings).done(function (response) {
 
 ```bash
 curl -X POST "http://localhost/api/user" \
--H "Accept: application/json"
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -140,8 +140,8 @@ $.ajax(settings).done(function (response) {
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/user/{user}" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/user/{user}" \
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -180,8 +180,8 @@ $.ajax(settings).done(function (response) {
 > Example request:
 
 ```bash
-curl -X GET "http://localhost/api/user/{user}/edit" \
--H "Accept: application/json"
+curl -X GET -G "http://localhost/api/user/{user}/edit" \
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -221,7 +221,7 @@ $.ajax(settings).done(function (response) {
 
 ```bash
 curl -X PUT "http://localhost/api/user/{user}" \
--H "Accept: application/json"
+    -H "Accept: application/json"
 ```
 
 ```javascript
@@ -256,7 +256,7 @@ $.ajax(settings).done(function (response) {
 
 ```bash
 curl -X DELETE "http://localhost/api/user/{user}" \
--H "Accept: application/json"
+    -H "Accept: application/json"
 ```
 
 ```javascript