mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-05 15:10:49 +00:00
Use UTF-8 charset on writing files (#4984)
This commit is contained in:
parent
b22f7f033f
commit
b22fde6caa
@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -159,7 +160,7 @@ public class Meta implements Runnable {
|
||||
LOGGER.info("copying file to {}", outputFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
FileUtils.writeStringToFile(outputFile, formatted);
|
||||
FileUtils.writeStringToFile(outputFile, formatted, StandardCharsets.UTF_8);
|
||||
return outputFile;
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -29,6 +29,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
@ -75,7 +76,7 @@ public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
try {
|
||||
String outputFile = outputFolder + File.separator + "openapi.json";
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI);
|
||||
FileUtils.writeStringToFile(new File(outputFile), jsonOpenAPI, StandardCharsets.UTF_8);
|
||||
LOGGER.info("wrote file to " + outputFile);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
|
@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class ScalaGatlingCodegen extends AbstractScalaCodegen implements CodegenConfig {
|
||||
@ -312,7 +313,11 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen
|
||||
operation.setVendorExtension("x-gatling-body-feeder", operation.getOperationId() + "BodyFeeder");
|
||||
operation.setVendorExtension("x-gatling-body-feeder-params", StringUtils.join(sessionBodyVars, ","));
|
||||
try {
|
||||
FileUtils.writeStringToFile(new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + "bodyParams.csv"), StringUtils.join(bodyFeederParams, ","));
|
||||
FileUtils.writeStringToFile(
|
||||
new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + "bodyParams.csv"),
|
||||
StringUtils.join(bodyFeederParams, ","),
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Could not create feeder file for operationId" + operation.getOperationId(), ioe);
|
||||
}
|
||||
@ -358,7 +363,11 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen
|
||||
operation.addExtension("x-gatling-" + parameterType.toLowerCase(Locale.ROOT) + "-params", vendorList);
|
||||
operation.addExtension("x-gatling-" + parameterType.toLowerCase(Locale.ROOT) + "-feeder", operation.getOperationId() + parameterType.toUpperCase(Locale.ROOT) + "Feeder");
|
||||
try {
|
||||
FileUtils.writeStringToFile(new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + parameterType.toLowerCase(Locale.ROOT) + "Params.csv"), StringUtils.join(parameterNames, ","));
|
||||
FileUtils.writeStringToFile(
|
||||
new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + parameterType.toLowerCase(Locale.ROOT) + "Params.csv"),
|
||||
StringUtils.join(parameterNames, ","),
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
} catch (IOException ioe) {
|
||||
LOGGER.error("Could not create feeder file for operationId" + operation.getOperationId(), ioe);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user