Skip to content

Commit 5e4ccbd

Browse files
committed
Fix formatting issues with generated markdown (Fixes #191)
1 parent 810e56d commit 5e4ccbd

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/resources/views/partials/route.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
> Example request:
1111

1212
```bash
13-
curl -X {{$parsedRoute['methods'][0]}} "{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($parsedRoute['uri'], '/') }}" \
14-
-H "Accept: application/json"@if(count($parsedRoute['parameters'])) \
13+
curl -X {{$parsedRoute['methods'][0]}} {{$parsedRoute['methods'][0] == 'GET' ? '-G ' : ''}}"{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($parsedRoute['uri'], '/') }}" \
14+
-H "Accept: application/json"@if(count($parsedRoute['parameters'])) \
1515
@foreach($parsedRoute['parameters'] as $attribute => $parameter)
16-
-d "{{$attribute}}"="{{$parameter['value']}}" \
16+
-d "{{$attribute}}"="{{$parameter['value']}}" @if(! ($loop->last))\
17+
@endif
1718
@endforeach
1819
@endif
1920

@@ -26,7 +27,7 @@
2627
"url": "{{ rtrim(config('app.docs_url') ?: config('app.url'), '/') }}/{{ ltrim($parsedRoute['uri'], '/') }}",
2728
"method": "{{$parsedRoute['methods'][0]}}",
2829
@if(count($parsedRoute['parameters']))
29-
"data": {!! str_replace(' ',' ',json_encode(array_combine(array_keys($parsedRoute['parameters']), array_map(function($param){ return $param['value']; },$parsedRoute['parameters'])), JSON_PRETTY_PRINT)) !!},
30+
"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))) !!},
3031
@endif
3132
"headers": {
3233
"accept": "application/json"

tests/Fixtures/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ It can also be multiple lines long.
3030
> Example request:
3131
3232
```bash
33-
curl -X GET "http://localhost/api/test" \
34-
-H "Accept: application/json"
33+
curl -X GET -G "http://localhost/api/test" \
34+
-H "Accept: application/json"
3535
```
3636

3737
```javascript
@@ -68,8 +68,8 @@ null
6868
> Example request:
6969
7070
```bash
71-
curl -X GET "http://localhost/api/fetch" \
72-
-H "Accept: application/json"
71+
curl -X GET -G "http://localhost/api/fetch" \
72+
-H "Accept: application/json"
7373
```
7474

7575
```javascript

tests/Fixtures/resource_index.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ Welcome to the generated API reference.
2727
> Example request:
2828
2929
```bash
30-
curl -X GET "http://localhost/api/user" \
31-
-H "Accept: application/json"
30+
curl -X GET -G "http://localhost/api/user" \
31+
-H "Accept: application/json"
3232
```
3333

3434
```javascript
@@ -67,8 +67,8 @@ $.ajax(settings).done(function (response) {
6767
> Example request:
6868
6969
```bash
70-
curl -X GET "http://localhost/api/user/create" \
71-
-H "Accept: application/json"
70+
curl -X GET -G "http://localhost/api/user/create" \
71+
-H "Accept: application/json"
7272
```
7373

7474
```javascript
@@ -108,7 +108,7 @@ $.ajax(settings).done(function (response) {
108108
109109
```bash
110110
curl -X POST "http://localhost/api/user" \
111-
-H "Accept: application/json"
111+
-H "Accept: application/json"
112112
```
113113

114114
```javascript
@@ -140,8 +140,8 @@ $.ajax(settings).done(function (response) {
140140
> Example request:
141141
142142
```bash
143-
curl -X GET "http://localhost/api/user/{user}" \
144-
-H "Accept: application/json"
143+
curl -X GET -G "http://localhost/api/user/{user}" \
144+
-H "Accept: application/json"
145145
```
146146

147147
```javascript
@@ -180,8 +180,8 @@ $.ajax(settings).done(function (response) {
180180
> Example request:
181181
182182
```bash
183-
curl -X GET "http://localhost/api/user/{user}/edit" \
184-
-H "Accept: application/json"
183+
curl -X GET -G "http://localhost/api/user/{user}/edit" \
184+
-H "Accept: application/json"
185185
```
186186

187187
```javascript
@@ -221,7 +221,7 @@ $.ajax(settings).done(function (response) {
221221
222222
```bash
223223
curl -X PUT "http://localhost/api/user/{user}" \
224-
-H "Accept: application/json"
224+
-H "Accept: application/json"
225225
```
226226

227227
```javascript
@@ -256,7 +256,7 @@ $.ajax(settings).done(function (response) {
256256
257257
```bash
258258
curl -X DELETE "http://localhost/api/user/{user}" \
259-
-H "Accept: application/json"
259+
-H "Accept: application/json"
260260
```
261261

262262
```javascript

0 commit comments

Comments
 (0)