Skip to content

Commit

Permalink
[haskell-http-client] remove duplicates in produces/consumes; fix pat…
Browse files Browse the repository at this point in the history
…hParam paramName issue (#273)
  • Loading branch information
jonschoning authored and wing328 committed May 1, 2018
1 parent 0b3ec6b commit d340139
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,14 @@ private void processProducesConsumes(CodegenOperation op) {
SetNoContent(op, X_INLINE_CONTENT_TYPE);
}
if (op.hasConsumes) {
// deduplicate
Map<String, Map<String, String>> consumes = new HashMap<>();
for (Map<String, String> m : op.consumes) {
consumes.put(m.get(MEDIA_TYPE), m);
}
op.consumes = new ArrayList<>(consumes.values());

// add metadata
for (Map<String, String> m : op.consumes) {
processMediaType(op, m);
processInlineConsumesContentType(op, m);
Expand All @@ -817,6 +825,14 @@ private void processProducesConsumes(CodegenOperation op) {
}
}
if (op.hasProduces) {
// deduplicate
Map<String, Map<String, String>> produces = new HashMap<>();
for (Map<String, String> m : op.produces) {
produces.put(m.get(MEDIA_TYPE), m);
}
op.produces = new ArrayList<>(produces.values());

// add metadata
for (Map<String, String> m : op.produces) {
processMediaType(op, m);
processInlineProducesContentType(op, m);
Expand Down Expand Up @@ -920,8 +936,10 @@ private void addEnumToUniques(String paramNameType, String datatype, String enum
private void processPathExpr(CodegenOperation op) {
String xPath = "[\"" + escapeText(op.path) + "\"]";
if (op.getHasPathParams()) {
for (CodegenParameter param : op.pathParams) {
xPath = xPath.replaceAll("\\{" + param.baseName + "\\}", "\",toPath " + param.paramName + ",\"");
for (CodegenParameter param : op.allParams) {
if(param.isPathParam) {
xPath = xPath.replaceAll("\\{" + param.baseName + "\\}", "\",toPath " + param.paramName + ",\"");
}
}
xPath = xPath.replaceAll(",\"\",", ",");
xPath = xPath.replaceAll("\"\",", ",");
Expand Down

0 comments on commit d340139

Please sign in to comment.