Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[haskell-http-client] fix bug in test for Maybe A.Value #2382

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -1203,12 +1204,18 @@ public Map<String, Object> postProcessModels(Map<String, Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down