mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 09:02:43 +00:00
[haskell-http-client] add cli option customTestInstanceModule (#2406)
setting `customTestInstanceModule` will import typeclasses from the specified module into tests/Instances.hs, to provide typeclass instances for types not known by the generator this property set using `--additional-properties` example: ``` --additional-properties=customTestInstanceModule=CustomInstances ```
This commit is contained in:
@@ -29,4 +29,5 @@ sidebar_label: haskell-http-client
|
||||
|useKatip|Sets the default value for the UseKatip cabal flag. If true, the katip package provides logging instead of monad-logger| |true|
|
||||
|dateTimeFormat|format string used to parse/render a datetime| |null|
|
||||
|dateFormat|format string used to parse/render a date| |%Y-%m-%d|
|
||||
|customTestInstanceModule|test module used to provide typeclass instances for types not known by the generator| |null|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|
||||
@@ -63,6 +63,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
public static final String PROP_CABAL_VERSION = "cabalVersion";
|
||||
public static final String PROP_CONFIG_TYPE = "configType";
|
||||
public static final String PROP_DATETIME_FORMAT = "dateTimeFormat";
|
||||
public static final String PROP_CUSTOM_TEST_INSTANCE_MODULE = "customTestInstanceModule";
|
||||
public static final String PROP_DATE_FORMAT = "dateFormat";
|
||||
public static final String PROP_GENERATE_ENUMS = "generateEnums";
|
||||
public static final String PROP_GENERATE_FORM_URLENCODED_INSTANCES = "generateFormUrlEncodedInstances";
|
||||
@@ -270,6 +271,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
cliOptions.add(CliOption.newString(PROP_DATETIME_FORMAT, "format string used to parse/render a datetime"));
|
||||
cliOptions.add(CliOption.newString(PROP_DATE_FORMAT, "format string used to parse/render a date").defaultValue(defaultDateFormat));
|
||||
|
||||
cliOptions.add(CliOption.newString(PROP_CUSTOM_TEST_INSTANCE_MODULE, "test module used to provide typeclass instances for types not known by the generator"));
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC).defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
}
|
||||
@@ -320,9 +323,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
setStringProp(PROP_DATETIME_FORMAT, value);
|
||||
}
|
||||
|
||||
public void setDateFormat(String value) {
|
||||
setStringProp(PROP_DATE_FORMAT, value);
|
||||
}
|
||||
public void setDateFormat(String value) { setStringProp(PROP_DATE_FORMAT, value); }
|
||||
|
||||
public void setCabalPackage(String value) {
|
||||
setStringProp(PROP_CABAL_PACKAGE, value);
|
||||
@@ -353,6 +354,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
this.useKatip = value;
|
||||
}
|
||||
|
||||
public void setCustomTestInstanceModule(String value) { setStringProp(PROP_CUSTOM_TEST_INSTANCE_MODULE, value); }
|
||||
|
||||
private void setStringProp(String key, String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
additionalProperties.remove(key);
|
||||
@@ -467,6 +470,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
if (additionalProperties.containsKey(PROP_CONFIG_TYPE)) {
|
||||
setConfigType(additionalProperties.get(PROP_CONFIG_TYPE).toString());
|
||||
}
|
||||
if (additionalProperties.containsKey(PROP_CUSTOM_TEST_INSTANCE_MODULE)) {
|
||||
setCustomTestInstanceModule(additionalProperties.get(PROP_CUSTOM_TEST_INSTANCE_MODULE).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,6 +62,7 @@ These options allow some customization of the code generation process.
|
||||
| baseModule | Set the base module namespace | | {{{baseModule}}} |
|
||||
| cabalPackage | Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens | | {{{cabalPackage}}} |
|
||||
| cabalVersion | Set the cabal version number, consisting of a sequence of one or more integers separated by dots | 0.1.0.0 | {{{cabalVersion}}} |
|
||||
| customTestInstanceModule | test module used to provide typeclass instances for types not known by the generator | | {{{customTestInstanceModule}}} |
|
||||
| configType | Set the name of the type used for configuration | | {{{configType}}} |
|
||||
| dateFormat | format string used to parse/render a date | %Y-%m-%d | {{{dateFormat}}} |
|
||||
| dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | {{{dateTimeFormat}}} |
|
||||
|
||||
@@ -113,5 +113,6 @@ test-suite tests
|
||||
other-modules:
|
||||
ApproxEq
|
||||
Instances
|
||||
PropMime
|
||||
PropMime{{#customTestInstanceModule}}
|
||||
{{.}}{{/customTestInstanceModule}}
|
||||
default-language: Haskell2010
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
module Instances where
|
||||
|
||||
import {{baseModule}}.Model
|
||||
import {{baseModule}}.Core
|
||||
import {{baseModule}}.Core{{#customTestInstanceModule}}
|
||||
import {{.}} (){{/customTestInstanceModule}}
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
|
||||
@@ -10,7 +10,8 @@ import Test.Hspec
|
||||
import Test.Hspec.QuickCheck
|
||||
|
||||
import PropMime
|
||||
import Instances ()
|
||||
import Instances (){{#customTestInstanceModule}}
|
||||
import {{.}} (){{/customTestInstanceModule}}
|
||||
|
||||
import {{baseModule}}.Model
|
||||
import {{baseModule}}.MimeTypes
|
||||
|
||||
@@ -62,6 +62,7 @@ These options allow some customization of the code generation process.
|
||||
| baseModule | Set the base module namespace | | OpenAPIPetstore |
|
||||
| cabalPackage | Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens | | openapi-petstore |
|
||||
| cabalVersion | Set the cabal version number, consisting of a sequence of one or more integers separated by dots | 0.1.0.0 | 0.1.0.0 |
|
||||
| customTestInstanceModule | test module used to provide typeclass instances for types not known by the generator | | |
|
||||
| configType | Set the name of the type used for configuration | | OpenAPIPetstoreConfig |
|
||||
| dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d |
|
||||
| dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | |
|
||||
|
||||
Reference in New Issue
Block a user