From 5fb50250fe27b57acfd7a27daa7af6f1e2f17014 Mon Sep 17 00:00:00 2001 From: Jon Schoning Date: Tue, 12 Mar 2019 23:22:23 -0500 Subject: [PATCH] [haskell-http-client] fix bug in test for Maybe A.Value from aa7ea8bdca --- .../codegen/languages/HaskellHttpClientCodegen.java | 7 +++++++ .../resources/haskell-http-client/tests/Instances.mustache | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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 9466b9c0279a..9db81b88d431 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 @@ -97,6 +97,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC static final String X_INLINE_ACCEPT = "x-inlineAccept"; static final String X_IS_BODY_OR_FORM_PARAM = "x-isBodyOrFormParam"; static final String X_IS_BODY_PARAM = "x-isBodyParam"; + static final String X_IS_MAYBE_VALUE = "x-isMaybeValue"; static final String X_MEDIA_DATA_TYPE = "x-mediaDataType"; static final String X_DATA_TYPE = "x-dataType"; static final String X_ENUM_VALUES = "x-enumValues"; @@ -1203,12 +1204,18 @@ public Map postProcessModels(Map objs) { dataType = "[" + cm.arrayModelType + "]"; } cm.vendorExtensions.put(X_DATA_TYPE, dataType); + if (dataType.equals("Maybe A.Value")) { + cm.vendorExtensions.put(X_IS_MAYBE_VALUE, true); + } } for (CodegenProperty var : cm.vars) { String datatype = genEnums && !StringUtils.isBlank(var.datatypeWithEnum) ? var.datatypeWithEnum : var.dataType; var.vendorExtensions.put(X_DATA_TYPE, datatype); + if (!var.required && datatype.equals("A.Value") || var.required && datatype.equals("Maybe A.Value")) { + var.vendorExtensions.put(X_IS_MAYBE_VALUE, true); + } } } return postProcessModelsEnum(objs); diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache index 7e7966235282..7ee2d27d983a 100644 --- a/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache +++ b/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache @@ -114,7 +114,7 @@ gen{{classname}} :: Int -> Gen {{classname}} gen{{classname}} n = {{#isAlias}}{{classname}} <$> arbitrary{{/isAlias}}{{^isAlias}}{{^hasVars}} pure {{/hasVars}}{{classname}} - {{#hasVars}} <$>{{/hasVars}} {{#vars}}{{#required}}{{#isPrimitiveType}}arbitrary{{/isPrimitiveType}}{{^isPrimitiveType}}arbitraryReduced n{{/isPrimitiveType}}{{/required}}{{^required}}{{^isFreeFormObject}}arbitraryReducedMaybe n{{/isFreeFormObject}}{{#isFreeFormObject}}arbitraryReducedMaybeValue n{{/isFreeFormObject}}{{/required}} -- {{name}} :: {{^required}}Maybe {{/required}}{{{vendorExtensions.x-dataType}}} + {{#hasVars}} <$>{{/hasVars}} {{#vars}}{{#required}}{{#isPrimitiveType}}arbitrary{{/isPrimitiveType}}{{^isPrimitiveType}}arbitraryReduced n{{/isPrimitiveType}}{{/required}}{{^required}}{{^vendorExtensions.x-isMaybeValue}}arbitraryReducedMaybe n{{/vendorExtensions.x-isMaybeValue}}{{#vendorExtensions.x-isMaybeValue}}arbitraryReducedMaybeValue n{{/vendorExtensions.x-isMaybeValue}}{{/required}} -- {{name}} :: {{^required}}Maybe {{/required}}{{{vendorExtensions.x-dataType}}} {{#hasMore}} <*> {{/hasMore}}{{/vars}}{{/isAlias}} {{/isEnum}} {{/model}}