swagger-codegen
swagger-codegen copied to clipboard
swagger-codegen-cli-2.4.21.jar -l html creates empty "examples"
Description
Swagger-codegen version
Generated correctly with 2.4.20, but no longer with 2.4.21
Swagger declaration file content or url
"examples" : [ {
"contentType" : "application/json",
"example" : "{\"empty\": false}"
} ],
Command line used for generation
-DdebugSupportingFiles -l html
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Looking at the changes in code, it's probably caused by replacing "m.modelJson = Json.pretty(model);" swagger-codegen\modules\swagger-codegen\src\main\java\io\swagger\codegen\DefaultCodegen.java by
// NOTE: not using Json.pretty() to write out model, as it
// can raise memory consumption (see comment in ExampleGenerator)
try {
m.modelJson = Json.mapper().writeValueAsString(model);
} catch (Exception e) {
m.modelJson = "{}";
}
So maybe it needs to be reverted to
m.modelJson = Json.pretty(model);
See https://github.com/swagger-api/swagger-codegen/pull/11071
I can confirm this. Generated examples are still serialized.