Skip to content

Commit

Permalink
swagger-initializer.js is sent endcoded in the JVM's default charset..
Browse files Browse the repository at this point in the history
…Fixes #2207
  • Loading branch information
bnasslahsen committed Apr 17, 2023
1 parent 534ad5e commit 1734071
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Expand Up @@ -3,6 +3,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -48,7 +49,7 @@ public class AbstractSwaggerIndexTransformerTest {
"\n" +
" //</editor-fold>\n" +
"};";
private final InputStream is = new ByteArrayInputStream(swaggerInitJs.getBytes());
private final InputStream is = new ByteArrayInputStream(swaggerInitJs.getBytes(StandardCharsets.UTF_8));

private final String apiDocUrl = "http://test.springdoc.com/apidoc";

Expand Down
Expand Up @@ -23,6 +23,7 @@
package org.springdoc.webmvc.ui;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import javax.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -75,7 +76,7 @@ public Resource transform(HttpServletRequest request, Resource resource,

if (isIndexFound) {
String html = defaultTransformations(resource.getInputStream());
return new TransformedResource(resource, html.getBytes());
return new TransformedResource(resource, html.getBytes(StandardCharsets.UTF_8));
}
else
return resource;
Expand Down
Expand Up @@ -22,6 +22,8 @@

package org.springdoc.webflux.ui;

import java.nio.charset.StandardCharsets;

import org.springdoc.core.SwaggerUiConfigParameters;
import org.springdoc.core.SwaggerUiConfigProperties;
import org.springdoc.core.SwaggerUiOAuthProperties;
Expand Down Expand Up @@ -73,7 +75,7 @@ public Mono<Resource> transform(ServerWebExchange serverWebExchange, Resource re
boolean isIndexFound = antPathMatcher.match("**/swagger-ui/**/" + SWAGGER_INITIALIZER_JS, resource.getURL().toString());
if (isIndexFound) {
String html = defaultTransformations(resource.getInputStream());
return Mono.just(new TransformedResource(resource, html.getBytes()));
return Mono.just(new TransformedResource(resource, html.getBytes(StandardCharsets.UTF_8)));
}
else {
return Mono.just(resource);
Expand Down

0 comments on commit 1734071

Please sign in to comment.