Skip to content
Closed
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
3 changes: 2 additions & 1 deletion src/Mpociot/ApiDoc/Generators/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ protected function parseRule($rule, $ruleName, &$attributeData, $seed)
break;
case 'in':
$attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
$attributeData['value'] = $faker->randomElement($parameters);
// $attributeData['value'] = $faker->randomElement($parameters);
Copy link
Contributor

@shalvah shalvah Sep 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @prodigy7 thanks for the PR. I'm not sure I understand why we're always choosing the first parameter. Maybe you should add a code comment for anyone who sees it in the future.

I get that we're using a default value, but what if the user doesn't want to use a default value? I'm thinking we can find another way of doing this. Maybe an annotation (// @apidocs default-value)

Also, please don't comment out old code. Delete it. Let Git do the tracking. 😀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with cURL, but the rest of the PR looks okay. So, if you attend to this, I can merge this PR. Also, can you update the documentation to mention the env variables it uses?

$attributeData['value'] = $parameters[0];
break;
case 'not_in':
$attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/partials/info.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Welcome to the generated API reference.
@if($showPostmanCollectionButton)
[Get Postman Collection]({{url($outputPath.'/collection.json')}})
[Get Postman Collection]({{url(env('APP_DOCS_URL', env('APP_URL', '')).'/'.$outputPath.'/collection.json')}})
@endif
8 changes: 4 additions & 4 deletions src/resources/views/partials/route.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
> Example request:

```bash
curl -X {{$parsedRoute['methods'][0]}} "{{config('app.docs_url') ?: config('app.url')}}/{{$parsedRoute['uri']}}" \
-H "Accept: application/json"@if(count($parsedRoute['parameters'])) \
curl -X {{$parsedRoute['methods'][0]}} {{$parsedRoute['methods'][0] == 'GET' ? '-G ' : ''}}"{{config('app.docs_url') ?: config('app.url')}}/{{$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 ($attribute == end($parsedRoute['parameters']))\@endif
@endforeach
@endif

Expand All @@ -26,7 +26,7 @@
"url": "{{config('app.docs_url') ?: config('app.url')}}/{{$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('}', ' }', 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"
Expand Down
8 changes: 4 additions & 4 deletions tests/Fixtures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,8 +70,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
Expand Down
22 changes: 11 additions & 11 deletions tests/Fixtures/resource_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,8 +69,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
Expand Down Expand Up @@ -112,7 +112,7 @@ $.ajax(settings).done(function (response) {

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

```javascript
Expand Down Expand Up @@ -144,8 +144,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
Expand Down Expand Up @@ -186,8 +186,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
Expand Down Expand Up @@ -229,7 +229,7 @@ $.ajax(settings).done(function (response) {

```bash
curl -X PUT "http://localhost/api/user/{user}" \
-H "Accept: application/json"
-H "Accept: application/json"
```

```javascript
Expand Down Expand Up @@ -264,7 +264,7 @@ $.ajax(settings).done(function (response) {

```bash
curl -X DELETE "http://localhost/api/user/{user}" \
-H "Accept: application/json"
-H "Accept: application/json"
```

```javascript
Expand Down