Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
fix issue-3
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgw committed Feb 8, 2018
1 parent 768b4a8 commit a193d0e
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,11 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
codegenOperation.getVendorExtensions().put(CodegenConstants.IS_RESPONSE_FILE_EXT_NAME, Boolean.TRUE);
}
}
if (codegenOperation.produces != null){
Set<String> mediaTypes = new HashSet<String>();
codegenOperation.produces.removeIf(map -> !mediaTypes.add(map.get("mediaType")));
codegenOperation.produces.get(codegenOperation.produces.size() - 1).remove("hasMore");
}
codegenOperation.responses.get(codegenOperation.responses.size() - 1).getVendorExtensions().put(CodegenConstants.HAS_MORE_EXT_NAME, Boolean.FALSE);

if (methodResponse != null) {
Expand Down Expand Up @@ -3519,7 +3524,6 @@ protected void addProducesInfo(ApiResponse response, CodegenOperation codegenOpe
if(codegenOperation.produces == null) {
codegenOperation.produces = new ArrayList<>();
}
int count = 0;
for (String key : produces) {
Map<String, String> mediaType = new HashMap<String, String>();
// escape quotation to avoid code injection
Expand All @@ -3528,12 +3532,7 @@ protected void addProducesInfo(ApiResponse response, CodegenOperation codegenOpe
} else {
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
}
count += 1;
if (count < produces.size()) {
mediaType.put("hasMore", "true");
} else {
mediaType.put("hasMore", null);
}
mediaType.put("hasMore", "true");
codegenOperation.produces.add(mediaType);
codegenOperation.getVendorExtensions().put(CodegenConstants.HAS_PRODUCES_EXT_NAME, Boolean.TRUE);
}
Expand Down

0 comments on commit a193d0e

Please sign in to comment.