Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show number as strings #8003

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public void processOpts() {
@Override
public void processSwagger(Swagger swagger) {
try {
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()
.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true));
configureMapper(mapper);
String swaggerString = mapper.writeValueAsString(swagger);
String outputFile = outputFolder + File.separator + this.outputFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,29 @@ public void testLongText() throws Exception {
folder.delete();

}

@Test
public void testNumberAsStrings() throws Exception {
final TemporaryFolder folder = new TemporaryFolder();
folder.create();
final File output = folder.getRoot();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setLang("swagger-yaml")
.setInputSpec("src/test/resources/2_0/petstore_issue_7999.json")
.setOutputDir(output.getAbsolutePath());

final ClientOptInput clientOptInput = configurator.toClientOptInput();
new DefaultGenerator().opts(clientOptInput).generate();

File outputFile = new File(output, "swagger.yaml");
Assert.assertTrue(outputFile.exists());

String content = FileUtils.readFileToString(outputFile);

Assert.assertTrue(content.contains("swagger: \"2.0\""));
Assert.assertTrue(content.contains("version: \"1.0\""));

folder.delete();

}
}
Loading