Merge pull request #1727 from lucassabreu/add-utf8-charset

(feat): add utf-8 charset to response
This commit is contained in:
Guilhem Niot 2020-10-04 09:48:59 +02:00 committed by GitHub
commit 00e4b53802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -65,10 +65,12 @@ final class SwaggerUiController
$spec['basePath'] = $request->getBaseUrl(); $spec['basePath'] = $request->getBaseUrl();
} }
return new Response( $response = new Response(
$this->twig->render('@NelmioApiDoc/SwaggerUi/index.html.twig', ['swagger_data' => ['spec' => $spec]]), $this->twig->render('@NelmioApiDoc/SwaggerUi/index.html.twig', ['swagger_data' => ['spec' => $spec]]),
Response::HTTP_OK, Response::HTTP_OK,
['Content-Type' => 'text/html'] ['Content-Type' => 'text/html']
); );
return $response->setCharset('UTF-8');
} }
} }

View File

@ -33,6 +33,7 @@ class SwaggerUiTest extends WebTestCase
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset());
$this->assertEquals('text/html; charset=UTF-8', $response->headers->get('Content-Type')); $this->assertEquals('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
$expected = $this->getSwaggerDefinition()->toArray(); $expected = $this->getSwaggerDefinition()->toArray();