Skip to content

Commit aaa36dc

Browse files
committed
Use JSON_UNESCAPED_UNICODE - Fixes mpociot#102
1 parent 0be8f19 commit aaa36dc

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343

4444
```json
4545
@if(is_object($parsedRoute['response']) || is_array($parsedRoute['response']))
46-
{!! json_encode($parsedRoute['response'], JSON_PRETTY_PRINT) !!}
46+
{!! json_encode($parsedRoute['response'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
4747
@else
48-
{!! json_encode(json_decode($parsedRoute['response']), JSON_PRETTY_PRINT) !!}
48+
{!! json_encode(json_decode($parsedRoute['response']), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
4949
@endif
5050
```
5151
@endif

tests/Fixtures/TestController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function dependencyInjection(DependencyInjection $dependency, TestRequest
6060
return '';
6161
}
6262

63+
public function utf8()
64+
{
65+
return ['result' => 'Лорем ипсум долор сит амет'];
66+
}
67+
6368
/**
6469
* @hideFromAPIDocumentation
6570
*/

tests/GenerateDocumentationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ public function testCanAppendCustomHttpHeaders()
176176
]', $generatedMarkdown);
177177
}
178178

179+
public function testGeneratesUTF8Responses()
180+
{
181+
RouteFacade::get('/api/utf8', TestController::class.'@utf8');
182+
183+
$output = $this->artisan('api:generate', [
184+
'--routePrefix' => 'api/*'
185+
]);
186+
187+
$generatedMarkdown = file_get_contents(__DIR__.'/../public/docs/source/index.md');
188+
$this->assertContains('Лорем ипсум долор сит амет', $generatedMarkdown);
189+
}
190+
179191
/**
180192
* @param string $command
181193
* @param array $parameters

0 commit comments

Comments
 (0)