Skip to content

Commit 7c9f943

Browse files
committed
fixed examples over quotes
1 parent 305deec commit 7c9f943

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,8 +2748,13 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
27482748

27492749
// set the example value
27502750
// if not specified in x-example, generate a default value
2751-
if (p.vendorExtensions.containsKey("x-example")) {
2752-
p.example = Json.pretty(p.vendorExtensions.get("x-example"));
2751+
if (p.vendorExtensions != null && p.vendorExtensions.containsKey("x-example")) {
2752+
boolean isObject = "object".equalsIgnoreCase(p.baseType) || "object".equalsIgnoreCase(p.dataType);
2753+
if (isObject) {
2754+
p.example = Json.pretty(p.vendorExtensions.get("x-example"));
2755+
} else {
2756+
p.example = p.vendorExtensions.get("x-example").toString();
2757+
}
27532758
} else if (Boolean.TRUE.equals(p.isUuid) && (Boolean.TRUE.equals(p.isString))) {
27542759
p.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
27552760
} else if (Boolean.TRUE.equals(p.isString)) {

0 commit comments

Comments
 (0)