[haskell-http-client] add config options: cabalPackage, cabalVersion, baseModule, requestType, configType (#7515)

- add new config options:

    cabalPackage
      Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens

    cabalVersion
      Set the cabal version number, consisting of a sequence of one or more integers separated by dots

    baseModule
      Set the base module namespace

    requestType
      Set the name of the type used to generate requests

    configType
      Set the name of the type used for configuration
This commit is contained in:
Jon Schoning 2018-01-28 00:59:04 -06:00 committed by William Cheng
parent 0de7f972fe
commit 9fba9c3255
26 changed files with 240 additions and 162 deletions

View File

@ -31,10 +31,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
// source folder where to write the files // source folder where to write the files
protected String sourceFolder = "lib"; protected String sourceFolder = "lib";
protected String artifactId = "swagger-haskell-http-client";
protected String artifactVersion = "1.0.0";
protected String defaultDateFormat = "%Y-%m-%d"; protected String defaultDateFormat = "%Y-%m-%d";
protected String defaultCabalVersion = "0.1.0.0";
protected String modulePath = null;
protected Boolean useMonadLogger = false; protected Boolean useMonadLogger = false;
protected Boolean allowNonUniqueOperationIds = false; protected Boolean allowNonUniqueOperationIds = false;
@ -42,8 +41,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
// CLI PROPS // CLI PROPS
public static final String PROP_ALLOW_FROMJSON_NULLS = "allowFromJsonNulls"; public static final String PROP_ALLOW_FROMJSON_NULLS = "allowFromJsonNulls";
public static final String PROP_ALLOW_TOJSON_NULLS = "allowToJsonNulls";
public static final String PROP_ALLOW_NONUNIQUE_OPERATION_IDS = "allowNonUniqueOperationIds"; public static final String PROP_ALLOW_NONUNIQUE_OPERATION_IDS = "allowNonUniqueOperationIds";
public static final String PROP_ALLOW_TOJSON_NULLS = "allowToJsonNulls";
public static final String PROP_BASE_MODULE = "baseModule";
public static final String PROP_CABAL_PACKAGE = "cabalPackage";
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_DATETIME_FORMAT = "dateTimeFormat";
public static final String PROP_DATE_FORMAT = "dateFormat"; public static final String PROP_DATE_FORMAT = "dateFormat";
public static final String PROP_GENERATE_ENUMS = "generateEnums"; public static final String PROP_GENERATE_ENUMS = "generateEnums";
@ -52,6 +55,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
public static final String PROP_GENERATE_MODEL_CONSTRUCTORS = "generateModelConstructors"; public static final String PROP_GENERATE_MODEL_CONSTRUCTORS = "generateModelConstructors";
public static final String PROP_INLINE_MIME_TYPES = "inlineMimeTypes"; public static final String PROP_INLINE_MIME_TYPES = "inlineMimeTypes";
public static final String PROP_MODEL_DERIVING = "modelDeriving"; public static final String PROP_MODEL_DERIVING = "modelDeriving";
public static final String PROP_REQUEST_TYPE = "requestType";
public static final String PROP_STRICT_FIELDS = "strictFields"; public static final String PROP_STRICT_FIELDS = "strictFields";
public static final String PROP_USE_MONAD_LOGGER = "useMonadLogger"; public static final String PROP_USE_MONAD_LOGGER = "useMonadLogger";
@ -134,7 +138,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
outputFolder = "generated-code/haskell-http-client"; outputFolder = "generated-code/haskell-http-client";
embeddedTemplateDir = templateDir = "haskell-http-client"; embeddedTemplateDir = templateDir = "haskell-http-client";
//apiPackage = "API"; apiPackage = "API";
//modelPackage = "Model"; //modelPackage = "Model";
// Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords // Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords
@ -155,9 +159,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
) )
); );
additionalProperties.put("artifactId", artifactId);
additionalProperties.put("artifactVersion", artifactVersion);
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml")); supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml"));
supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs")); supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs"));
@ -218,8 +219,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
importMapping.clear(); importMapping.clear();
cliOptions.add(CliOption.newString(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); //cliOptions.add(CliOption.newString(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); //cliOptions.add(CliOption.newString(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));
cliOptions.add(CliOption.newString(PROP_CABAL_PACKAGE, "Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens"));
cliOptions.add(CliOption.newString(PROP_CABAL_VERSION, "Set the cabal version number, consisting of a sequence of one or more integers separated by dots"));
cliOptions.add(CliOption.newString(PROP_BASE_MODULE, "Set the base module namespace"));
cliOptions.add(CliOption.newString(PROP_REQUEST_TYPE, "Set the name of the type used to generate requests"));
cliOptions.add(CliOption.newString(PROP_CONFIG_TYPE, "Set the name of the type used for configuration"));
cliOptions.add(CliOption.newBoolean(PROP_ALLOW_FROMJSON_NULLS, "allow JSON Null during model decoding from JSON").defaultValue(Boolean.TRUE.toString())); cliOptions.add(CliOption.newBoolean(PROP_ALLOW_FROMJSON_NULLS, "allow JSON Null during model decoding from JSON").defaultValue(Boolean.TRUE.toString()));
cliOptions.add(CliOption.newBoolean(PROP_ALLOW_TOJSON_NULLS, "allow emitting JSON Null during model encoding to JSON").defaultValue(Boolean.FALSE.toString())); cliOptions.add(CliOption.newBoolean(PROP_ALLOW_TOJSON_NULLS, "allow emitting JSON Null during model encoding to JSON").defaultValue(Boolean.FALSE.toString()));
@ -281,20 +288,31 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
} }
public void setDateTimeFormat(String value) { public void setDateTimeFormat(String value) {
if (StringUtils.isBlank(value)) { setStringProp(PROP_DATETIME_FORMAT, value);
additionalProperties.remove(PROP_DATETIME_FORMAT);
} else {
additionalProperties.put(PROP_DATETIME_FORMAT, value);
}
} }
public void setDateFormat(String value) { public void setDateFormat(String value) {
if (StringUtils.isBlank(value)) { setStringProp(PROP_DATE_FORMAT, value);
additionalProperties.remove(PROP_DATE_FORMAT); }
} else {
additionalProperties.put(PROP_DATE_FORMAT, value); public void setCabalPackage(String value) {
} setStringProp(PROP_CABAL_PACKAGE, value);
}
public void setCabalVersion(String value) {
setStringProp(PROP_CABAL_VERSION, value);
}
public void setBaseModule(String value) {
setStringProp(PROP_BASE_MODULE, value);
}
public void setRequestType(String value) {
setStringProp(PROP_REQUEST_TYPE, value);
}
public void setConfigType(String value) {
setStringProp(PROP_CONFIG_TYPE, value);
} }
public void setStrictFields(Boolean value) { public void setStrictFields(Boolean value) {
@ -306,6 +324,18 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
this.useMonadLogger = value; this.useMonadLogger = value;
} }
private void setStringProp(String key, String value) {
if (StringUtils.isBlank(value)) {
additionalProperties.remove(key);
} else {
additionalProperties.put(key, value);
}
}
private String getStringProp(String key) {
return (String)additionalProperties.get(key);
}
@Override @Override
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
@ -393,75 +423,99 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
setUseMonadLogger(false); setUseMonadLogger(false);
} }
if (additionalProperties.containsKey(PROP_CABAL_PACKAGE)) {
setCabalPackage(additionalProperties.get(PROP_CABAL_PACKAGE).toString());
}
if (additionalProperties.containsKey(PROP_CABAL_VERSION)) {
setCabalVersion(additionalProperties.get(PROP_CABAL_VERSION).toString());
} else {
setCabalVersion(defaultCabalVersion);
}
if (additionalProperties.containsKey(PROP_BASE_MODULE)) {
setBaseModule(additionalProperties.get(PROP_BASE_MODULE).toString());
}
if (additionalProperties.containsKey(PROP_REQUEST_TYPE)) {
setRequestType(additionalProperties.get(PROP_REQUEST_TYPE).toString());
}
if (additionalProperties.containsKey(PROP_CONFIG_TYPE)) {
setConfigType(additionalProperties.get(PROP_CONFIG_TYPE).toString());
}
} }
@Override @Override
public void preprocessSwagger(Swagger swagger) { public void preprocessSwagger(Swagger swagger) {
// From the title, compute a reasonable name for the package and the API String baseTitle = swagger.getInfo().getTitle();
String title = swagger.getInfo().getTitle();
// Drop any API suffix if (baseTitle == null) {
if (title == null) { baseTitle = "Swagger";
title = "Swagger";
} else { } else {
title = title.trim(); baseTitle = baseTitle.trim();
if (title.toUpperCase().endsWith("API")) { // Drop any API suffix
title = title.substring(0, title.length() - 3); if (baseTitle.toUpperCase().endsWith("API")) {
baseTitle = baseTitle.substring(0, baseTitle.length() - 3);
} }
} }
String[] words = title.split(" "); if (!additionalProperties.containsKey(PROP_CABAL_PACKAGE)) {
List<String> words = new ArrayList<>();
// The package name is made by appending the lowercased words of the title interspersed with dashes for (String word : baseTitle.split(" ")) {
List<String> wordsLower = new ArrayList<String>(); words.add(word.toLowerCase());
for (String word : words) { }
wordsLower.add(word.toLowerCase()); setCabalPackage(StringUtils.join(words, "-"));
} }
String cabalName = StringUtils.join(wordsLower, "-");
String pathsName = StringUtils.join(wordsLower, "_");
// The API name is made by appending the capitalized words of the title if (!additionalProperties.containsKey(PROP_BASE_MODULE)) {
List<String> wordsCaps = new ArrayList<String>(); List<String> wordsCaps = new ArrayList<String>();
for (String word : words) { for (String word : baseTitle.split(" ")) {
wordsCaps.add(firstLetterToUpper(word)); wordsCaps.add(firstLetterToUpper(word));
}
setBaseModule(StringUtils.join(wordsCaps, ""));
} }
apiPackage = StringUtils.join(wordsCaps, "");
// Set the filenames to write for the API modulePath = sourceFolder + File.separator + getStringProp(PROP_BASE_MODULE).replace('.', File.separatorChar);
String topLevelPath = StringUtils.substringBeforeLast(modulePath, String.valueOf(File.separatorChar));
String lastPath = StringUtils.substringAfterLast(modulePath, String.valueOf(File.separatorChar));
if (!additionalProperties.containsKey(PROP_REQUEST_TYPE)) {
setRequestType(lastPath + "Request");
}
if (!additionalProperties.containsKey(PROP_CONFIG_TYPE)) {
setConfigType(lastPath + "Config");
}
// root // root
supportingFiles.add(new SupportingFile("haskell-http-client.cabal.mustache", "", cabalName + ".cabal")); supportingFiles.add(new SupportingFile("haskell-http-client.cabal.mustache", "", getStringProp(PROP_CABAL_PACKAGE) + ".cabal"));
supportingFiles.add(new SupportingFile("swagger.mustache", "", "swagger.yaml")); supportingFiles.add(new SupportingFile("swagger.mustache", "", "swagger.yaml"));
// lib // lib
supportingFiles.add(new SupportingFile("TopLevel.mustache", sourceFolder + File.separator, apiPackage + ".hs")); supportingFiles.add(new SupportingFile("TopLevel.mustache", topLevelPath, lastPath + ".hs"));
supportingFiles.add(new SupportingFile("Client.mustache", sourceFolder + File.separator + apiPackage, "Client.hs")); supportingFiles.add(new SupportingFile("Client.mustache", modulePath, "Client.hs"));
if(!allowNonUniqueOperationIds) { if(!allowNonUniqueOperationIds) {
supportingFiles.add(new SupportingFile("APIS.mustache", sourceFolder + File.separator + apiPackage, "API.hs")); supportingFiles.add(new SupportingFile("APIS.mustache", modulePath, "API.hs"));
} }
supportingFiles.add(new SupportingFile("Core.mustache", sourceFolder + File.separator + apiPackage, "Core.hs")); supportingFiles.add(new SupportingFile("Core.mustache", modulePath, "Core.hs"));
supportingFiles.add(new SupportingFile("Model.mustache", sourceFolder + File.separator + apiPackage, "Model.hs")); supportingFiles.add(new SupportingFile("Model.mustache", modulePath, "Model.hs"));
supportingFiles.add(new SupportingFile("MimeTypes.mustache", sourceFolder + File.separator + apiPackage, "MimeTypes.hs")); supportingFiles.add(new SupportingFile("MimeTypes.mustache", modulePath, "MimeTypes.hs"));
// logger // logger
supportingFiles.add(new SupportingFile(useMonadLogger ? "LoggingMonadLogger.mustache" : "LoggingKatip.mustache", sourceFolder + File.separator + apiPackage, "Logging.hs")); supportingFiles.add(new SupportingFile(useMonadLogger ? "LoggingMonadLogger.mustache" : "LoggingKatip.mustache", modulePath, "Logging.hs"));
apiTemplateFiles.put("API.mustache", ".hs"); apiTemplateFiles.put("API.mustache", ".hs");
// modelTemplateFiles.put("Model.mustache", ".hs"); // modelTemplateFiles.put("Model.mustache", ".hs");
// lens // lens
if ((boolean)additionalProperties.get(PROP_GENERATE_LENSES)) { if ((boolean)additionalProperties.get(PROP_GENERATE_LENSES)) {
supportingFiles.add(new SupportingFile("ModelLens.mustache", sourceFolder + File.separator + apiPackage, "ModelLens.hs")); supportingFiles.add(new SupportingFile("ModelLens.mustache", modulePath, "ModelLens.hs"));
} }
additionalProperties.put("title", apiPackage); additionalProperties.put("cabalName", getStringProp(PROP_CABAL_PACKAGE));
additionalProperties.put("titleLower", firstLetterToLower(apiPackage)); additionalProperties.put("pathsName", getStringProp(PROP_CABAL_PACKAGE).replace('-','_'));
additionalProperties.put("package", cabalName); additionalProperties.put("requestType", getStringProp(PROP_REQUEST_TYPE));
additionalProperties.put("pathsName", pathsName); additionalProperties.put("configType", getStringProp(PROP_CONFIG_TYPE));
additionalProperties.put("requestType", apiPackage + "Request");
additionalProperties.put("configType", apiPackage + "Config");
additionalProperties.put("swaggerVersion", swagger.getSwagger()); additionalProperties.put("swaggerVersion", swagger.getSwagger());
super.preprocessSwagger(swagger); super.preprocessSwagger(swagger);
@ -1035,7 +1089,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
} }
@Override @Override
public String apiFileFolder() { public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar) + File.separator + "API"; return outputFolder + File.separator + this.modulePath + File.separator + "API";
} }
public String toTypeName(String prefix, String name) { public String toTypeName(String prefix, String name) {
name = escapeIdentifier(prefix, camelize(sanitizeName(name))); name = escapeIdentifier(prefix, camelize(sanitizeName(name)));

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.API.{{classname}} Module : {{baseModule}}.API.{{classname}}
-} -}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
@ -10,11 +10,11 @@ Module : {{title}}.API.{{classname}}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
module {{title}}.API.{{classname}} where module {{baseModule}}.API.{{classname}} where
import {{title}}.Core import {{baseModule}}.Core
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import {{title}}.Model as M import {{baseModule}}.Model as M
import qualified Data.Aeson as A import qualified Data.Aeson as A
import qualified Data.ByteString as B import qualified Data.ByteString as B

View File

@ -1,10 +1,10 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.API Module : {{baseModule}}.API
-} -}
module {{title}}.API module {{baseModule}}.API
( {{#apiInfo}}{{#apis}}module {{title}}.API.{{classname}} ( {{#apiInfo}}{{#apis}}module {{baseModule}}.API.{{classname}}
{{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}}) where {{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}}) where
{{#apiInfo}}{{#apis}} {{#apiInfo}}{{#apis}}
import {{title}}.API.{{classname}}{{/apis}}{{/apiInfo}} import {{baseModule}}.API.{{classname}}{{/apis}}{{/apiInfo}}

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Client Module : {{baseModule}}.Client
-} -}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
@ -13,11 +13,11 @@ Module : {{title}}.Client
{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE DeriveTraversable #-}
{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-}
module {{title}}.Client where module {{baseModule}}.Client where
import {{title}}.Core import {{baseModule}}.Core
import {{title}}.Logging import {{baseModule}}.Logging
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import qualified Control.Exception.Safe as E import qualified Control.Exception.Safe as E
import qualified Control.Monad.IO.Class as P import qualified Control.Monad.IO.Class as P

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Core Module : {{baseModule}}.Core
-} -}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
@ -16,10 +16,10 @@ Module : {{title}}.Core
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds #-}
module {{title}}.Core where module {{baseModule}}.Core where
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import {{title}}.Logging import {{baseModule}}.Logging
import qualified Control.Arrow as P (left) import qualified Control.Arrow as P (left)
import qualified Control.DeepSeq as NF import qualified Control.DeepSeq as NF
@ -86,14 +86,14 @@ instance P.Show {{configType}} where
-- --
-- configUserAgent: -- configUserAgent:
-- --
-- @"{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{artifactId}}}/{{{artifactVersion}}}{{/httpUserAgent}}"@ -- @"{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{cabalName}}}/{{{cabalVersion}}}{{/httpUserAgent}}"@
-- --
newConfig :: IO {{configType}} newConfig :: IO {{configType}}
newConfig = do newConfig = do
logCxt <- initLogContext logCxt <- initLogContext
return $ {{configType}} return $ {{configType}}
{ configHost = "{{{basePath}}}" { configHost = "{{{basePath}}}"
, configUserAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{artifactId}}}/{{{artifactVersion}}}{{/httpUserAgent}}" , configUserAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{cabalName}}}/{{{cabalVersion}}}{{/httpUserAgent}}"
, configLogExecWithContext = runDefaultLogExecWithContext , configLogExecWithContext = runDefaultLogExecWithContext
, configLogContext = logCxt , configLogContext = logCxt
, configAuthMethods = [] , configAuthMethods = []

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Logging Module : {{baseModule}}.Logging
Katip Logging functions Katip Logging functions
-} -}
@ -8,7 +8,7 @@ Katip Logging functions
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
module {{title}}.Logging where module {{baseModule}}.Logging where
import qualified Control.Exception.Safe as E import qualified Control.Exception.Safe as E
import qualified Control.Monad.IO.Class as P import qualified Control.Monad.IO.Class as P
@ -41,7 +41,7 @@ type LogLevel = LG.Severity
-- | the default log environment -- | the default log environment
initLogContext :: IO LogContext initLogContext :: IO LogContext
initLogContext = LG.initLogEnv "{{title}}" "dev" initLogContext = LG.initLogEnv "{{baseModule}}" "dev"
-- | Runs a Katip logging block with the Log environment -- | Runs a Katip logging block with the Log environment
runDefaultLogExecWithContext :: LogExecWithContext runDefaultLogExecWithContext :: LogExecWithContext

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Logging Module : {{baseModule}}.Logging
monad-logger Logging functions monad-logger Logging functions
-} -}
@ -8,7 +8,7 @@ monad-logger Logging functions
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
module {{title}}.Logging where module {{baseModule}}.Logging where
import qualified Control.Exception.Safe as E import qualified Control.Exception.Safe as E
import qualified Control.Monad.IO.Class as P import qualified Control.Monad.IO.Class as P
@ -81,7 +81,7 @@ nullLogger _ _ _ _ = return ()
_log :: (P.MonadIO m, LG.MonadLogger m) => Text -> LG.LogLevel -> Text -> m () _log :: (P.MonadIO m, LG.MonadLogger m) => Text -> LG.LogLevel -> Text -> m ()
_log src level msg = do _log src level msg = do
now <- P.liftIO (formatTimeLog <$> TI.getCurrentTime) now <- P.liftIO (formatTimeLog <$> TI.getCurrentTime)
LG.logOtherNS ("{{title}}." <> src) level ("[" <> now <> "] " <> msg) LG.logOtherNS ("{{baseModule}}." <> src) level ("[" <> now <> "] " <> msg)
where where
formatTimeLog = formatTimeLog =
T.pack . TI.formatTime TI.defaultTimeLocale "%Y-%m-%dT%H:%M:%S%Z" T.pack . TI.formatTime TI.defaultTimeLocale "%Y-%m-%dT%H:%M:%S%Z"

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.MimeTypes Module : {{baseModule}}.MimeTypes
-} -}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
@ -12,7 +12,7 @@ Module : {{title}}.MimeTypes
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-}
module {{title}}.MimeTypes where module {{baseModule}}.MimeTypes where
import qualified Control.Arrow as P (left) import qualified Control.Arrow as P (left)
import qualified Data.Aeson as A import qualified Data.Aeson as A

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Model Module : {{baseModule}}.Model
-} -}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
@ -17,10 +17,10 @@ Module : {{title}}.Model
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-}
module {{title}}.Model where module {{baseModule}}.Model where
import {{title}}.Core import {{baseModule}}.Core
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import Data.Aeson ((.:),(.:!),(.:?),(.=)) import Data.Aeson ((.:),(.:!),(.:?),(.=))

View File

@ -1,6 +1,6 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}}.Lens Module : {{baseModule}}.Lens
-} -}
{-# LANGUAGE KindSignatures #-} {-# LANGUAGE KindSignatures #-}
@ -9,7 +9,7 @@ Module : {{title}}.Lens
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-}
module {{title}}.ModelLens where module {{baseModule}}.ModelLens where
import qualified Data.Aeson as A import qualified Data.Aeson as A
import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy as BL
@ -23,8 +23,8 @@ import Data.Text (Text)
import Prelude (($), (.),(<$>),(<*>),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) import Prelude (($), (.),(<$>),(<*>),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
import qualified Prelude as P import qualified Prelude as P
import {{title}}.Model import {{baseModule}}.Model
import {{title}}.Core import {{baseModule}}.Core
{{#models}} {{#models}}
{{#model}} {{#model}}

View File

@ -1,6 +1,6 @@
## Swagger Auto-Generated [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) Bindings to `{{title}}` ## Swagger Auto-Generated [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) Bindings to `{{baseModule}}`
The library in `lib` provides auto-generated-from-Swagger [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) bindings to the {{title}} API. The library in `lib` provides auto-generated-from-Swagger [http-client](https://www.stackage.org/lts-9.0/package/http-client-0.5.7.0) bindings to the {{baseModule}} API.
Targeted swagger version: {{swaggerVersion}} Targeted swagger version: {{swaggerVersion}}
@ -58,9 +58,13 @@ These options allow some customization of the code generation process.
| OPTION | DESCRIPTION | DEFAULT | ACTUAL | | OPTION | DESCRIPTION | DEFAULT | ACTUAL |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- |
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | {{{x-allowNonUniqueOperationIds}}} |
| allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | {{{allowFromJsonNulls}}} | | allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | {{{allowFromJsonNulls}}} |
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | {{{x-allowNonUniqueOperationIds}}} |
| allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | {{{allowToJsonNulls}}} | | allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | {{{allowToJsonNulls}}} |
| 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}}} |
| configType | Set the name of the type used for configuration | | {{{configType}}} |
| dateFormat | format string used to parse/render a date | %Y-%m-%d | {{{dateFormat}}} | | 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}}} | | dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | {{{dateTimeFormat}}} |
| generateEnums | Generate specific datatypes for swagger enums | true | {{{generateEnums}}} | | generateEnums | Generate specific datatypes for swagger enums | true | {{{generateEnums}}} |
@ -69,6 +73,7 @@ These options allow some customization of the code generation process.
| generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | {{{generateModelConstructors}}} | | generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | {{{generateModelConstructors}}} |
| inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | false | {{{inlineMimeTypes}}} | | inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | false | {{{inlineMimeTypes}}} |
| modelDeriving | Additional classes to include in the deriving() clause of Models | | {{{modelDeriving}}} | | modelDeriving | Additional classes to include in the deriving() clause of Models | | {{{modelDeriving}}} |
| requestType | Set the name of the type used to generate requests | | {{{requestType}}} |
| strictFields | Add strictness annotations to all model fields | true | {{{x-strictFields}}} | | strictFields | Add strictness annotations to all model fields | true | {{{x-strictFields}}} |
| useMonadLogger | Use the monad-logger package to provide logging (if instead false, use the katip logging package) | false | {{{x-useMonadLogger}}} | | useMonadLogger | Use the monad-logger package to provide logging (if instead false, use the katip logging package) | false | {{{x-useMonadLogger}}} |
@ -106,13 +111,13 @@ This library is intended to be imported qualified.
| MODULE | NOTES | | MODULE | NOTES |
| ------------------- | --------------------------------------------------- | | ------------------- | --------------------------------------------------- |
| {{title}}.Client | use the "dispatch" functions to send requests | | {{baseModule}}.Client | use the "dispatch" functions to send requests |
| {{title}}.Core | core funcions, config and request types | | {{baseModule}}.Core | core funcions, config and request types |
| {{title}}.API | construct api requests | | {{baseModule}}.API | construct api requests |
| {{title}}.Model | describes api models | | {{baseModule}}.Model | describes api models |
| {{title}}.MimeTypes | encoding/decoding MIME types (content-types/accept) | | {{baseModule}}.MimeTypes | encoding/decoding MIME types (content-types/accept) |
| {{title}}.ModelLens | lenses for model fields | | {{baseModule}}.ModelLens | lenses for model fields |
| {{title}}.Logging | logging functions and utils | | {{baseModule}}.Logging | logging functions and utils |
### MimeTypes ### MimeTypes

View File

@ -1,22 +1,22 @@
{{>partial_header}} {{>partial_header}}
{-| {-|
Module : {{title}} Module : {{baseModule}}
-} -}
module {{title}} module {{baseModule}}
( {{^x-allowNonUniqueOperationIds}} module {{title}}.API ( {{^x-allowNonUniqueOperationIds}} module {{baseModule}}.API
,{{/x-allowNonUniqueOperationIds}} module {{title}}.Client ,{{/x-allowNonUniqueOperationIds}} module {{baseModule}}.Client
, module {{title}}.Core , module {{baseModule}}.Core
, module {{title}}.Logging , module {{baseModule}}.Logging
, module {{title}}.MimeTypes , module {{baseModule}}.MimeTypes
, module {{title}}.Model , module {{baseModule}}.Model
, module {{title}}.ModelLens , module {{baseModule}}.ModelLens
) where ) where
{{^x-allowNonUniqueOperationIds}}import {{title}}.API{{/x-allowNonUniqueOperationIds}} {{^x-allowNonUniqueOperationIds}}import {{baseModule}}.API{{/x-allowNonUniqueOperationIds}}
import {{title}}.Client import {{baseModule}}.Client
import {{title}}.Core import {{baseModule}}.Core
import {{title}}.Logging import {{baseModule}}.Logging
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import {{title}}.Model import {{baseModule}}.Model
import {{title}}.ModelLens import {{baseModule}}.ModelLens

View File

@ -1,8 +1,8 @@
name: {{package}} name: {{cabalPackage}}
version: 0.1.0.0 version: {{cabalVersion}}
synopsis: Auto-generated {{package}} API Client synopsis: Auto-generated {{cabalPackage}} API Client
description: . description: .
Client library for calling the {{package}} API based on http-client. Client library for calling the {{appName}} API based on http-client.
. .
host: {{host}} host: {{host}}
. .
@ -61,18 +61,18 @@ library
, unordered-containers , unordered-containers
, vector >=0.10.9 && <0.13 , vector >=0.10.9 && <0.13
, {{^x-useMonadLogger}}katip >=0.4 && < 0.6{{/x-useMonadLogger}}{{#x-useMonadLogger}}monad-logger >=0.3 && <0.4{{/x-useMonadLogger}} , {{^x-useMonadLogger}}katip >=0.4 && < 0.6{{/x-useMonadLogger}}{{#x-useMonadLogger}}monad-logger >=0.3 && <0.4{{/x-useMonadLogger}}
exposed-modules:
{{title}}{{^x-allowNonUniqueOperationIds}}
{{title}}.API{{/x-allowNonUniqueOperationIds}}{{#apiInfo}}{{#apis}}
{{title}}.API.{{classname}}{{/apis}}{{/apiInfo}}
{{title}}.Client
{{title}}.Core
{{title}}.Logging
{{title}}.MimeTypes
{{title}}.Model
{{title}}.ModelLens
other-modules: other-modules:
Paths_{{pathsName}} Paths_{{pathsName}}
exposed-modules:
{{baseModule}}{{^x-allowNonUniqueOperationIds}}
{{baseModule}}.API{{/x-allowNonUniqueOperationIds}}{{#apiInfo}}{{#apis}}
{{baseModule}}.API.{{classname}}{{/apis}}{{/apiInfo}}
{{baseModule}}.Client
{{baseModule}}.Core
{{baseModule}}.Logging
{{baseModule}}.MimeTypes
{{baseModule}}.Model
{{baseModule}}.ModelLens
default-language: Haskell2010 default-language: Haskell2010
test-suite tests test-suite tests
@ -82,7 +82,7 @@ test-suite tests
tests tests
ghc-options: -Wall -fno-warn-orphans ghc-options: -Wall -fno-warn-orphans
build-depends: build-depends:
{{package}} {{cabalPackage}}
, QuickCheck , QuickCheck
, aeson , aeson
, base >=4.7 && <5.0 , base >=4.7 && <5.0

View File

@ -2,8 +2,8 @@
module Instances where module Instances where
import {{title}}.Model import {{baseModule}}.Model
import {{title}}.Core import {{baseModule}}.Core
import qualified Data.Aeson as A import qualified Data.Aeson as A
import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString.Lazy as BL

View File

@ -15,7 +15,7 @@ import Test.QuickCheck
import Test.QuickCheck.Property import Test.QuickCheck.Property
import Test.Hspec.QuickCheck (prop) import Test.Hspec.QuickCheck (prop)
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
import ApproxEq import ApproxEq

View File

@ -12,8 +12,8 @@ import Test.Hspec.QuickCheck
import PropMime import PropMime
import Instances () import Instances ()
import {{title}}.Model import {{baseModule}}.Model
import {{title}}.MimeTypes import {{baseModule}}.MimeTypes
main :: IO () main :: IO ()
main = main =

View File

@ -24,10 +24,6 @@ public class HaskellHttpClientOptionsTest extends AbstractOptionsTest {
@Override @Override
protected void setExpectations() { protected void setExpectations() {
new Expectations(clientCodegen) {{ new Expectations(clientCodegen) {{
clientCodegen.setModelPackage(HaskellHttpClientOptionsProvider.MODEL_PACKAGE_VALUE);
times = 1;
clientCodegen.setApiPackage(HaskellHttpClientOptionsProvider.API_PACKAGE_VALUE);
times = 1;
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(HaskellHttpClientOptionsProvider.SORT_PARAMS_VALUE)); clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(HaskellHttpClientOptionsProvider.SORT_PARAMS_VALUE));
times = 1; times = 1;
clientCodegen.setAllowNonUniqueOperationIds(Boolean.valueOf(HaskellHttpClientOptionsProvider.ALLOW_NONUNIQUE_OPERATION_IDS)); clientCodegen.setAllowNonUniqueOperationIds(Boolean.valueOf(HaskellHttpClientOptionsProvider.ALLOW_NONUNIQUE_OPERATION_IDS));
@ -56,7 +52,16 @@ public class HaskellHttpClientOptionsTest extends AbstractOptionsTest {
times = 1; times = 1;
clientCodegen.setUseMonadLogger(Boolean.valueOf(HaskellHttpClientOptionsProvider.USE_MONAD_LOGGER)); clientCodegen.setUseMonadLogger(Boolean.valueOf(HaskellHttpClientOptionsProvider.USE_MONAD_LOGGER));
times = 1; times = 1;
clientCodegen.setCabalPackage(HaskellHttpClientOptionsProvider.CABAL_PACKAGE);
times = 1;
clientCodegen.setCabalVersion(HaskellHttpClientOptionsProvider.CABAL_VERSION);
times = 1;
clientCodegen.setBaseModule(HaskellHttpClientOptionsProvider.BASE_MODULE);
times = 1;
clientCodegen.setRequestType(HaskellHttpClientOptionsProvider.REQUEST_TYPE);
times = 1;
clientCodegen.setConfigType(HaskellHttpClientOptionsProvider.CONFIG_TYPE);
times = 1;
}}; }};
} }
} }

View File

@ -28,6 +28,12 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider {
public static final String INLINE_MIME_TYPES = "false"; public static final String INLINE_MIME_TYPES = "false";
public static final String USE_MONAD_LOGGER = "false"; public static final String USE_MONAD_LOGGER = "false";
public static final String CABAL_PACKAGE = "cabal-package";
public static final String CABAL_VERSION = "1.0.0.0";
public static final String BASE_MODULE = "Network.Module";
public static final String REQUEST_TYPE = "RequestType";
public static final String CONFIG_TYPE = "ConfigType";
@Override @Override
public String getLanguage() { public String getLanguage() {
return "haskell-http-client"; return "haskell-http-client";
@ -36,8 +42,7 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider {
@Override @Override
public Map<String, String> createOptions() { public Map<String, String> createOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>(); ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE) return builder
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE) .put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
@ -56,7 +61,11 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider {
.put(HaskellHttpClientCodegen.PROP_INLINE_MIME_TYPES, INLINE_MIME_TYPES) .put(HaskellHttpClientCodegen.PROP_INLINE_MIME_TYPES, INLINE_MIME_TYPES)
.put(HaskellHttpClientCodegen.PROP_STRICT_FIELDS, STRICT_FIELDS) .put(HaskellHttpClientCodegen.PROP_STRICT_FIELDS, STRICT_FIELDS)
.put(HaskellHttpClientCodegen.PROP_USE_MONAD_LOGGER, USE_MONAD_LOGGER) .put(HaskellHttpClientCodegen.PROP_USE_MONAD_LOGGER, USE_MONAD_LOGGER)
.put(HaskellHttpClientCodegen.PROP_CABAL_PACKAGE, CABAL_PACKAGE)
.put(HaskellHttpClientCodegen.PROP_CABAL_VERSION, CABAL_VERSION)
.put(HaskellHttpClientCodegen.PROP_BASE_MODULE, BASE_MODULE)
.put(HaskellHttpClientCodegen.PROP_REQUEST_TYPE, REQUEST_TYPE)
.put(HaskellHttpClientCodegen.PROP_CONFIG_TYPE, CONFIG_TYPE)
.build(); .build();
} }

View File

@ -1 +1 @@
2.3.0 2.4.0-SNAPSHOT

View File

@ -58,9 +58,13 @@ These options allow some customization of the code generation process.
| OPTION | DESCRIPTION | DEFAULT | ACTUAL | | OPTION | DESCRIPTION | DEFAULT | ACTUAL |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- |
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | false |
| allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | true | | allowFromJsonNulls | allow JSON Null during model decoding from JSON | true | true |
| allowNonUniqueOperationIds | allow *different* API modules to contain the same operationId. Each API must be imported qualified | false | false |
| allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | false | | allowToJsonNulls | allow emitting JSON Null during model encoding to JSON | false | false |
| baseModule | Set the base module namespace | | SwaggerPetstore |
| cabalPackage | Set the cabal package name, which consists of one or more alphanumeric words separated by hyphens | | swagger-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 |
| configType | Set the name of the type used for configuration | | SwaggerPetstoreConfig |
| dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d | | 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) | | | | dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | |
| generateEnums | Generate specific datatypes for swagger enums | true | true | | generateEnums | Generate specific datatypes for swagger enums | true | true |
@ -69,6 +73,7 @@ These options allow some customization of the code generation process.
| generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true | | generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true |
| inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | false | false | | inlineMimeTypes | Inline (hardcode) the content-type and accept parameters on operations, when there is only 1 option | false | false |
| modelDeriving | Additional classes to include in the deriving() clause of Models | | | | modelDeriving | Additional classes to include in the deriving() clause of Models | | |
| requestType | Set the name of the type used to generate requests | | SwaggerPetstoreRequest |
| strictFields | Add strictness annotations to all model fields | true | true | | strictFields | Add strictness annotations to all model fields | true | true |
| useMonadLogger | Use the monad-logger package to provide logging (if instead false, use the katip logging package) | false | false | | useMonadLogger | Use the monad-logger package to provide logging (if instead false, use the katip logging package) | false | false |

File diff suppressed because one or more lines are too long

View File

@ -2,4 +2,4 @@
window.onload = function () {pageLoad();}; window.onload = function () {pageLoad();};
//]]> //]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client</p></div><div id="content"><div id="description"><h1>swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client</h1><div class="doc"><p>. </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client</p></div><div id="content"><div id="description"><h1>swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client</h1><div class="doc"><p>.
Client library for calling the swagger-petstore API based on http-client.</p><p>host: petstore.swagger.io:80</p><p>base path: <a href="http://petstore.swagger.io:80/v2">http://petstore.swagger.io:80/v2</a></p><p>Swagger Petstore API version: 1.0.0</p><p>OpenAPI spec version: 2.0</p><p>OpenAPI-Specification: <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md">https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md</a></p></div></div><div id="module-list"><p class="caption">Signatures</p></div><div id="module-list"><p class="caption">Modules</p><ul><li><span class="module"><span id="control.n.1" class="collapser" onclick="toggleSection('n.1')">&nbsp;</span><a href="SwaggerPetstore.html">SwaggerPetstore</a></span><ul id="section.n.1" class="show"><li><span class="module"><span id="control.n.1.1" class="collapser" onclick="toggleSection('n.1.1')">&nbsp;</span><a href="SwaggerPetstore-API.html">SwaggerPetstore.API</a></span><ul id="section.n.1.1" class="show"><li><span class="module"><a href="SwaggerPetstore-API-AnotherFake.html">SwaggerPetstore.API.AnotherFake</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Fake.html">SwaggerPetstore.API.Fake</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-FakeClassnameTags123.html">SwaggerPetstore.API.FakeClassnameTags123</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Pet.html">SwaggerPetstore.API.Pet</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Store.html">SwaggerPetstore.API.Store</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-User.html">SwaggerPetstore.API.User</a></span></li></ul></li><li><span class="module"><a href="SwaggerPetstore-Client.html">SwaggerPetstore.Client</a></span></li><li><span class="module"><a href="SwaggerPetstore-Core.html">SwaggerPetstore.Core</a></span></li><li><span class="module"><a href="SwaggerPetstore-Logging.html">SwaggerPetstore.Logging</a></span></li><li><span class="module"><a href="SwaggerPetstore-MimeTypes.html">SwaggerPetstore.MimeTypes</a></span></li><li><span class="module"><a href="SwaggerPetstore-Model.html">SwaggerPetstore.Model</a></span></li><li><span class="module"><a href="SwaggerPetstore-ModelLens.html">SwaggerPetstore.ModelLens</a></span></li></ul></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.18.1</p></div></body></html> Client library for calling the Swagger Petstore API based on http-client.</p><p>host: petstore.swagger.io:80</p><p>base path: <a href="http://petstore.swagger.io:80/v2">http://petstore.swagger.io:80/v2</a></p><p>Swagger Petstore API version: 1.0.0</p><p>OpenAPI spec version: 2.0</p><p>OpenAPI-Specification: <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md">https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md</a></p></div></div><div id="module-list"><p class="caption">Signatures</p></div><div id="module-list"><p class="caption">Modules</p><ul><li><span class="module"><span id="control.n.1" class="collapser" onclick="toggleSection('n.1')">&nbsp;</span><a href="SwaggerPetstore.html">SwaggerPetstore</a></span><ul id="section.n.1" class="show"><li><span class="module"><span id="control.n.1.1" class="collapser" onclick="toggleSection('n.1.1')">&nbsp;</span><a href="SwaggerPetstore-API.html">SwaggerPetstore.API</a></span><ul id="section.n.1.1" class="show"><li><span class="module"><a href="SwaggerPetstore-API-AnotherFake.html">SwaggerPetstore.API.AnotherFake</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Fake.html">SwaggerPetstore.API.Fake</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-FakeClassnameTags123.html">SwaggerPetstore.API.FakeClassnameTags123</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Pet.html">SwaggerPetstore.API.Pet</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-Store.html">SwaggerPetstore.API.Store</a></span></li><li><span class="module"><a href="SwaggerPetstore-API-User.html">SwaggerPetstore.API.User</a></span></li></ul></li><li><span class="module"><a href="SwaggerPetstore-Client.html">SwaggerPetstore.Client</a></span></li><li><span class="module"><a href="SwaggerPetstore-Core.html">SwaggerPetstore.Core</a></span></li><li><span class="module"><a href="SwaggerPetstore-Logging.html">SwaggerPetstore.Logging</a></span></li><li><span class="module"><a href="SwaggerPetstore-MimeTypes.html">SwaggerPetstore.MimeTypes</a></span></li><li><span class="module"><a href="SwaggerPetstore-Model.html">SwaggerPetstore.Model</a></span></li><li><span class="module"><a href="SwaggerPetstore-ModelLens.html">SwaggerPetstore.ModelLens</a></span></li></ul></li></ul></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.18.1</p></div></body></html>

View File

@ -96,14 +96,14 @@ Module : SwaggerPetstore.Core
</span><a name="line-96"></a><span class="hs-comment">--</span><span> </span><a name="line-96"></a><span class="hs-comment">--</span><span>
</span><a name="line-97"></a><span class="hs-comment">-- configUserAgent:</span><span> </span><a name="line-97"></a><span class="hs-comment">-- configUserAgent:</span><span>
</span><a name="line-98"></a><span class="hs-comment">--</span><span> </span><a name="line-98"></a><span class="hs-comment">--</span><span>
</span><a name="line-99"></a><span class="hs-comment">-- @&quot;swagger-haskell-http-client/1.0.0&quot;@</span><span> </span><a name="line-99"></a><span class="hs-comment">-- @&quot;swagger-petstore/0.1.0.0&quot;@</span><span>
</span><a name="line-100"></a><span class="hs-comment">--</span><span> </span><a name="line-100"></a><span class="hs-comment">--</span><span>
</span><a name="line-101"></a><span class="hs-identifier">newConfig</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier hs-type">IO</span><span> </span><a href="SwaggerPetstore.Core.html#SwaggerPetstoreConfig"><span class="hs-identifier hs-type">SwaggerPetstoreConfig</span></a><span> </span><a name="line-101"></a><span class="hs-identifier">newConfig</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier hs-type">IO</span><span> </span><a href="SwaggerPetstore.Core.html#SwaggerPetstoreConfig"><span class="hs-identifier hs-type">SwaggerPetstoreConfig</span></a><span>
</span><a name="line-102"></a><a name="newConfig"><a href="SwaggerPetstore.Core.html#newConfig"><span class="hs-identifier">newConfig</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><a name="line-102"></a><a name="newConfig"><a href="SwaggerPetstore.Core.html#newConfig"><span class="hs-identifier">newConfig</span></a></a><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><a name="line-103"></a><span> </span><a name="local-6989586621679115241"><a href="#local-6989586621679115241"><span class="hs-identifier">logCxt</span></a></a><span> </span><span class="hs-glyph">&lt;-</span><span> </span><a href="SwaggerPetstore.Logging.html#initLogContext"><span class="hs-identifier hs-var">initLogContext</span></a><span> </span><a name="line-103"></a><span> </span><a name="local-6989586621679115241"><a href="#local-6989586621679115241"><span class="hs-identifier">logCxt</span></a></a><span> </span><span class="hs-glyph">&lt;-</span><span> </span><a href="SwaggerPetstore.Logging.html#initLogContext"><span class="hs-identifier hs-var">initLogContext</span></a><span>
</span><a name="line-104"></a><span> </span><span class="hs-identifier hs-var">return</span><span> </span><span class="hs-operator hs-var">$</span><span> </span><a href="SwaggerPetstore.Core.html#SwaggerPetstoreConfig"><span class="hs-identifier hs-var">SwaggerPetstoreConfig</span></a><span> </span><a name="line-104"></a><span> </span><span class="hs-identifier hs-var">return</span><span> </span><span class="hs-operator hs-var">$</span><span> </span><a href="SwaggerPetstore.Core.html#SwaggerPetstoreConfig"><span class="hs-identifier hs-var">SwaggerPetstoreConfig</span></a><span>
</span><a name="line-105"></a><span> </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">configHost</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-string">&quot;http://petstore.swagger.io:80/v2&quot;</span><span> </span><a name="line-105"></a><span> </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">configHost</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-string">&quot;http://petstore.swagger.io:80/v2&quot;</span><span>
</span><a name="line-106"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configUserAgent</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-string">&quot;swagger-haskell-http-client/1.0.0&quot;</span><span> </span><a name="line-106"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configUserAgent</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-string">&quot;swagger-petstore/0.1.0.0&quot;</span><span>
</span><a name="line-107"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configLogExecWithContext</span><span> </span><span class="hs-glyph">=</span><span> </span><a href="SwaggerPetstore.Logging.html#runDefaultLogExecWithContext"><span class="hs-identifier hs-var">runDefaultLogExecWithContext</span></a><span> </span><a name="line-107"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configLogExecWithContext</span><span> </span><span class="hs-glyph">=</span><span> </span><a href="SwaggerPetstore.Logging.html#runDefaultLogExecWithContext"><span class="hs-identifier hs-var">runDefaultLogExecWithContext</span></a><span>
</span><a name="line-108"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configLogContext</span><span> </span><span class="hs-glyph">=</span><span> </span><a href="#local-6989586621679115241"><span class="hs-identifier hs-var">logCxt</span></a><span> </span><a name="line-108"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configLogContext</span><span> </span><span class="hs-glyph">=</span><span> </span><a href="#local-6989586621679115241"><span class="hs-identifier hs-var">logCxt</span></a><span>
</span><a name="line-109"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configAuthMethods</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><a name="line-109"></a><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">configAuthMethods</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>

View File

@ -4,7 +4,7 @@
-- | Auto-generated swagger-petstore API Client -- | Auto-generated swagger-petstore API Client
-- --
-- . Client library for calling the swagger-petstore API based on -- . Client library for calling the Swagger Petstore API based on
-- http-client. -- http-client.
-- --
-- host: petstore.swagger.io:80 -- host: petstore.swagger.io:80
@ -296,7 +296,7 @@ SwaggerPetstoreConfig :: ByteString -> Text -> LogExecWithContext -> LogContext
-- configUserAgent: -- configUserAgent:
-- --
-- <pre> -- <pre>
-- "swagger-haskell-http-client/1.0.0" -- "swagger-petstore/0.1.0.0"
-- </pre> -- </pre>
newConfig :: IO SwaggerPetstoreConfig newConfig :: IO SwaggerPetstoreConfig

View File

@ -96,14 +96,14 @@ instance P.Show SwaggerPetstoreConfig where
-- --
-- configUserAgent: -- configUserAgent:
-- --
-- @"swagger-haskell-http-client/1.0.0"@ -- @"swagger-petstore/0.1.0.0"@
-- --
newConfig :: IO SwaggerPetstoreConfig newConfig :: IO SwaggerPetstoreConfig
newConfig = do newConfig = do
logCxt <- initLogContext logCxt <- initLogContext
return $ SwaggerPetstoreConfig return $ SwaggerPetstoreConfig
{ configHost = "http://petstore.swagger.io:80/v2" { configHost = "http://petstore.swagger.io:80/v2"
, configUserAgent = "swagger-haskell-http-client/1.0.0" , configUserAgent = "swagger-petstore/0.1.0.0"
, configLogExecWithContext = runDefaultLogExecWithContext , configLogExecWithContext = runDefaultLogExecWithContext
, configLogContext = logCxt , configLogContext = logCxt
, configAuthMethods = [] , configAuthMethods = []

View File

@ -2,7 +2,7 @@ name: swagger-petstore
version: 0.1.0.0 version: 0.1.0.0
synopsis: Auto-generated swagger-petstore API Client synopsis: Auto-generated swagger-petstore API Client
description: . description: .
Client library for calling the swagger-petstore API based on http-client. Client library for calling the Swagger Petstore API based on http-client.
. .
host: petstore.swagger.io:80 host: petstore.swagger.io:80
. .
@ -57,6 +57,8 @@ library
, unordered-containers , unordered-containers
, vector >=0.10.9 && <0.13 , vector >=0.10.9 && <0.13
, katip >=0.4 && < 0.6 , katip >=0.4 && < 0.6
other-modules:
Paths_swagger_petstore
exposed-modules: exposed-modules:
SwaggerPetstore SwaggerPetstore
SwaggerPetstore.API SwaggerPetstore.API
@ -72,8 +74,6 @@ library
SwaggerPetstore.MimeTypes SwaggerPetstore.MimeTypes
SwaggerPetstore.Model SwaggerPetstore.Model
SwaggerPetstore.ModelLens SwaggerPetstore.ModelLens
other-modules:
Paths_swagger_petstore
default-language: Haskell2010 default-language: Haskell2010
test-suite tests test-suite tests