From d3401396f52745515e62aa94970282ed1f516a34 Mon Sep 17 00:00:00 2001 From: Jon Schoning Date: Mon, 30 Apr 2018 23:27:20 -0500 Subject: [PATCH] [haskell-http-client] remove duplicates in produces/consumes; fix pathParam paramName issue (#273) --- .../languages/HaskellHttpClientCodegen.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 93e7efebf462..15aa485c8ae9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -807,6 +807,14 @@ private void processProducesConsumes(CodegenOperation op) { SetNoContent(op, X_INLINE_CONTENT_TYPE); } if (op.hasConsumes) { + // deduplicate + Map> consumes = new HashMap<>(); + for (Map m : op.consumes) { + consumes.put(m.get(MEDIA_TYPE), m); + } + op.consumes = new ArrayList<>(consumes.values()); + + // add metadata for (Map m : op.consumes) { processMediaType(op, m); processInlineConsumesContentType(op, m); @@ -817,6 +825,14 @@ private void processProducesConsumes(CodegenOperation op) { } } if (op.hasProduces) { + // deduplicate + Map> produces = new HashMap<>(); + for (Map m : op.produces) { + produces.put(m.get(MEDIA_TYPE), m); + } + op.produces = new ArrayList<>(produces.values()); + + // add metadata for (Map m : op.produces) { processMediaType(op, m); processInlineProducesContentType(op, m); @@ -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("\"\",", ",");