mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
(feat): add utf-8 charset to response
`swagger-ui-bundle` is very sensible to encoding changes because of the RegExp performed. ensuring UTF-8 on the response prevents end-user config to break it. the annotations already needs to be UTF-8 compatible to generate the JSON, so it should not break users applications.
This commit is contained in:
parent
290df23dc0
commit
b022f6b219
@ -65,10 +65,12 @@ final class SwaggerUiController
|
||||
$spec['basePath'] = $request->getBaseUrl();
|
||||
}
|
||||
|
||||
return new Response(
|
||||
$response = new Response(
|
||||
$this->twig->render('@NelmioApiDoc/SwaggerUi/index.html.twig', ['swagger_data' => ['spec' => $spec]]),
|
||||
Response::HTTP_OK,
|
||||
['Content-Type' => 'text/html']
|
||||
);
|
||||
|
||||
return $response->setCharset('UTF-8');
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class SwaggerUiTest extends WebTestCase
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertEquals('UTF-8', $response->getCharset());
|
||||
$this->assertEquals('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
|
||||
|
||||
$expected = $this->getSwaggerDefinition()->toArray();
|
||||
|
Loading…
x
Reference in New Issue
Block a user