diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java index 4c12bf75e8f..26dac3f2048 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/HaskellHttpClientCodegen.java @@ -31,10 +31,9 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC // source folder where to write the files 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 defaultCabalVersion = "0.1.0.0"; + protected String modulePath = null; protected Boolean useMonadLogger = false; protected Boolean allowNonUniqueOperationIds = false; @@ -42,8 +41,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC // CLI PROPS 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_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_DATE_FORMAT = "dateFormat"; 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_INLINE_MIME_TYPES = "inlineMimeTypes"; 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_USE_MONAD_LOGGER = "useMonadLogger"; @@ -134,7 +138,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC outputFolder = "generated-code/haskell-http-client"; embeddedTemplateDir = templateDir = "haskell-http-client"; - //apiPackage = "API"; + apiPackage = "API"; //modelPackage = "Model"; // 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("stack.mustache", "", "stack.yaml")); supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs")); @@ -218,8 +219,14 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC importMapping.clear(); - 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.MODEL_PACKAGE, CodegenConstants.MODEL_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_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) { - if (StringUtils.isBlank(value)) { - additionalProperties.remove(PROP_DATETIME_FORMAT); - } else { - additionalProperties.put(PROP_DATETIME_FORMAT, value); - } - + setStringProp(PROP_DATETIME_FORMAT, value); } public void setDateFormat(String value) { - if (StringUtils.isBlank(value)) { - additionalProperties.remove(PROP_DATE_FORMAT); - } else { - additionalProperties.put(PROP_DATE_FORMAT, value); - } + setStringProp(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) { @@ -306,6 +324,18 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC 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 public void processOpts() { super.processOpts(); @@ -393,75 +423,99 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC 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 public void preprocessSwagger(Swagger swagger) { - // From the title, compute a reasonable name for the package and the API - String title = swagger.getInfo().getTitle(); + String baseTitle = swagger.getInfo().getTitle(); - // Drop any API suffix - if (title == null) { - title = "Swagger"; + if (baseTitle == null) { + baseTitle = "Swagger"; } else { - title = title.trim(); - if (title.toUpperCase().endsWith("API")) { - title = title.substring(0, title.length() - 3); + baseTitle = baseTitle.trim(); + // Drop any API suffix + if (baseTitle.toUpperCase().endsWith("API")) { + baseTitle = baseTitle.substring(0, baseTitle.length() - 3); } } - String[] words = title.split(" "); - - // The package name is made by appending the lowercased words of the title interspersed with dashes - List wordsLower = new ArrayList(); - for (String word : words) { - wordsLower.add(word.toLowerCase()); + if (!additionalProperties.containsKey(PROP_CABAL_PACKAGE)) { + List words = new ArrayList<>(); + for (String word : baseTitle.split(" ")) { + words.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 - List wordsCaps = new ArrayList(); - for (String word : words) { - wordsCaps.add(firstLetterToUpper(word)); + if (!additionalProperties.containsKey(PROP_BASE_MODULE)) { + List wordsCaps = new ArrayList(); + for (String word : baseTitle.split(" ")) { + 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 - 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")); // lib - supportingFiles.add(new SupportingFile("TopLevel.mustache", sourceFolder + File.separator, apiPackage + ".hs")); - supportingFiles.add(new SupportingFile("Client.mustache", sourceFolder + File.separator + apiPackage, "Client.hs")); + supportingFiles.add(new SupportingFile("TopLevel.mustache", topLevelPath, lastPath + ".hs")); + supportingFiles.add(new SupportingFile("Client.mustache", modulePath, "Client.hs")); 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("Model.mustache", sourceFolder + File.separator + apiPackage, "Model.hs")); - supportingFiles.add(new SupportingFile("MimeTypes.mustache", sourceFolder + File.separator + apiPackage, "MimeTypes.hs")); + supportingFiles.add(new SupportingFile("Core.mustache", modulePath, "Core.hs")); + supportingFiles.add(new SupportingFile("Model.mustache", modulePath, "Model.hs")); + supportingFiles.add(new SupportingFile("MimeTypes.mustache", modulePath, "MimeTypes.hs")); // 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"); // modelTemplateFiles.put("Model.mustache", ".hs"); // lens 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("titleLower", firstLetterToLower(apiPackage)); - additionalProperties.put("package", cabalName); - additionalProperties.put("pathsName", pathsName); - additionalProperties.put("requestType", apiPackage + "Request"); - additionalProperties.put("configType", apiPackage + "Config"); + additionalProperties.put("cabalName", getStringProp(PROP_CABAL_PACKAGE)); + additionalProperties.put("pathsName", getStringProp(PROP_CABAL_PACKAGE).replace('-','_')); + additionalProperties.put("requestType", getStringProp(PROP_REQUEST_TYPE)); + additionalProperties.put("configType", getStringProp(PROP_CONFIG_TYPE)); additionalProperties.put("swaggerVersion", swagger.getSwagger()); super.preprocessSwagger(swagger); @@ -1035,7 +1089,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC } @Override 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) { name = escapeIdentifier(prefix, camelize(sanitizeName(name))); diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache index 2048ac89fe2..43bba943fc1 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/API.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.API.{{classname}} +Module : {{baseModule}}.API.{{classname}} -} {-# LANGUAGE FlexibleContexts #-} @@ -10,11 +10,11 @@ Module : {{title}}.API.{{classname}} {-# LANGUAGE OverloadedStrings #-} {-# 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 {{title}}.MimeTypes -import {{title}}.Model as M +import {{baseModule}}.Core +import {{baseModule}}.MimeTypes +import {{baseModule}}.Model as M import qualified Data.Aeson as A import qualified Data.ByteString as B diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/APIS.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/APIS.mustache index 65d5d45ba67..59396f87f35 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/APIS.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/APIS.mustache @@ -1,10 +1,10 @@ {{>partial_header}} {-| -Module : {{title}}.API +Module : {{baseModule}}.API -} -module {{title}}.API - ( {{#apiInfo}}{{#apis}}module {{title}}.API.{{classname}} +module {{baseModule}}.API + ( {{#apiInfo}}{{#apis}}module {{baseModule}}.API.{{classname}} {{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}}) where {{#apiInfo}}{{#apis}} -import {{title}}.API.{{classname}}{{/apis}}{{/apiInfo}} \ No newline at end of file +import {{baseModule}}.API.{{classname}}{{/apis}}{{/apiInfo}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/Client.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/Client.mustache index 643b7425d3f..cd2c451a3a7 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/Client.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/Client.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Client +Module : {{baseModule}}.Client -} {-# LANGUAGE OverloadedStrings #-} @@ -13,11 +13,11 @@ Module : {{title}}.Client {-# LANGUAGE DeriveTraversable #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} -module {{title}}.Client where +module {{baseModule}}.Client where -import {{title}}.Core -import {{title}}.Logging -import {{title}}.MimeTypes +import {{baseModule}}.Core +import {{baseModule}}.Logging +import {{baseModule}}.MimeTypes import qualified Control.Exception.Safe as E import qualified Control.Monad.IO.Class as P diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/Core.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/Core.mustache index b40ec37d0d7..804efa892c4 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/Core.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/Core.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Core +Module : {{baseModule}}.Core -} {-# LANGUAGE DeriveDataTypeable #-} @@ -16,10 +16,10 @@ Module : {{title}}.Core {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds #-} -module {{title}}.Core where +module {{baseModule}}.Core where -import {{title}}.MimeTypes -import {{title}}.Logging +import {{baseModule}}.MimeTypes +import {{baseModule}}.Logging import qualified Control.Arrow as P (left) import qualified Control.DeepSeq as NF @@ -86,14 +86,14 @@ instance P.Show {{configType}} where -- -- configUserAgent: -- --- @"{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{artifactId}}}/{{{artifactVersion}}}{{/httpUserAgent}}"@ +-- @"{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{cabalName}}}/{{{cabalVersion}}}{{/httpUserAgent}}"@ -- newConfig :: IO {{configType}} newConfig = do logCxt <- initLogContext return $ {{configType}} { configHost = "{{{basePath}}}" - , configUserAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{artifactId}}}/{{{artifactVersion}}}{{/httpUserAgent}}" + , configUserAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}{{{cabalName}}}/{{{cabalVersion}}}{{/httpUserAgent}}" , configLogExecWithContext = runDefaultLogExecWithContext , configLogContext = logCxt , configAuthMethods = [] diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingKatip.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingKatip.mustache index e522435f8b3..f8e38319e37 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingKatip.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingKatip.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Logging +Module : {{baseModule}}.Logging Katip Logging functions -} @@ -8,7 +8,7 @@ Katip Logging functions {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -module {{title}}.Logging where +module {{baseModule}}.Logging where import qualified Control.Exception.Safe as E import qualified Control.Monad.IO.Class as P @@ -41,7 +41,7 @@ type LogLevel = LG.Severity -- | the default log environment initLogContext :: IO LogContext -initLogContext = LG.initLogEnv "{{title}}" "dev" +initLogContext = LG.initLogEnv "{{baseModule}}" "dev" -- | Runs a Katip logging block with the Log environment runDefaultLogExecWithContext :: LogExecWithContext diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingMonadLogger.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingMonadLogger.mustache index 7265d7472b2..e59cb64b8bb 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingMonadLogger.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/LoggingMonadLogger.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Logging +Module : {{baseModule}}.Logging monad-logger Logging functions -} @@ -8,7 +8,7 @@ monad-logger Logging functions {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -module {{title}}.Logging where +module {{baseModule}}.Logging where import qualified Control.Exception.Safe as E 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 src level msg = do now <- P.liftIO (formatTimeLog <$> TI.getCurrentTime) - LG.logOtherNS ("{{title}}." <> src) level ("[" <> now <> "] " <> msg) + LG.logOtherNS ("{{baseModule}}." <> src) level ("[" <> now <> "] " <> msg) where formatTimeLog = T.pack . TI.formatTime TI.defaultTimeLocale "%Y-%m-%dT%H:%M:%S%Z" diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/MimeTypes.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/MimeTypes.mustache index b0652932dc5..c1c83ec7120 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/MimeTypes.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/MimeTypes.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.MimeTypes +Module : {{baseModule}}.MimeTypes -} {-# LANGUAGE ConstraintKinds #-} @@ -12,7 +12,7 @@ Module : {{title}}.MimeTypes {-# LANGUAGE ScopedTypeVariables #-} {-# 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 Data.Aeson as A diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache index 5d249c1efb4..3c957a65949 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/Model.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Model +Module : {{baseModule}}.Model -} {-# LANGUAGE DeriveDataTypeable #-} @@ -17,10 +17,10 @@ Module : {{title}}.Model {-# LANGUAGE TypeFamilies #-} {-# 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 {{title}}.MimeTypes +import {{baseModule}}.Core +import {{baseModule}}.MimeTypes import Data.Aeson ((.:),(.:!),(.:?),(.=)) diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache index d15a4ba8336..c21d6af2b83 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/ModelLens.mustache @@ -1,6 +1,6 @@ {{>partial_header}} {-| -Module : {{title}}.Lens +Module : {{baseModule}}.Lens -} {-# LANGUAGE KindSignatures #-} @@ -9,7 +9,7 @@ Module : {{title}}.Lens {-# LANGUAGE RecordWildCards #-} {-# 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.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 qualified Prelude as P -import {{title}}.Model -import {{title}}.Core +import {{baseModule}}.Model +import {{baseModule}}.Core {{#models}} {{#model}} diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache index c25c548fe6d..68923d3569c 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/README.mustache @@ -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}} @@ -58,9 +58,13 @@ These options allow some customization of the code generation process. | 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}}} | +| 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}}} | +| 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}}} | | 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}}} | @@ -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}}} | | 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}}} | +| requestType | Set the name of the type used to generate requests | | {{{requestType}}} | | 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}}} | @@ -106,13 +111,13 @@ This library is intended to be imported qualified. | MODULE | NOTES | | ------------------- | --------------------------------------------------- | -| {{title}}.Client | use the "dispatch" functions to send requests | -| {{title}}.Core | core funcions, config and request types | -| {{title}}.API | construct api requests | -| {{title}}.Model | describes api models | -| {{title}}.MimeTypes | encoding/decoding MIME types (content-types/accept) | -| {{title}}.ModelLens | lenses for model fields | -| {{title}}.Logging | logging functions and utils | +| {{baseModule}}.Client | use the "dispatch" functions to send requests | +| {{baseModule}}.Core | core funcions, config and request types | +| {{baseModule}}.API | construct api requests | +| {{baseModule}}.Model | describes api models | +| {{baseModule}}.MimeTypes | encoding/decoding MIME types (content-types/accept) | +| {{baseModule}}.ModelLens | lenses for model fields | +| {{baseModule}}.Logging | logging functions and utils | ### MimeTypes diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/TopLevel.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/TopLevel.mustache index b3c2e3bdf93..94ba3dd62fe 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/TopLevel.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/TopLevel.mustache @@ -1,22 +1,22 @@ {{>partial_header}} {-| -Module : {{title}} +Module : {{baseModule}} -} -module {{title}} - ( {{^x-allowNonUniqueOperationIds}} module {{title}}.API - ,{{/x-allowNonUniqueOperationIds}} module {{title}}.Client - , module {{title}}.Core - , module {{title}}.Logging - , module {{title}}.MimeTypes - , module {{title}}.Model - , module {{title}}.ModelLens +module {{baseModule}} + ( {{^x-allowNonUniqueOperationIds}} module {{baseModule}}.API + ,{{/x-allowNonUniqueOperationIds}} module {{baseModule}}.Client + , module {{baseModule}}.Core + , module {{baseModule}}.Logging + , module {{baseModule}}.MimeTypes + , module {{baseModule}}.Model + , module {{baseModule}}.ModelLens ) where -{{^x-allowNonUniqueOperationIds}}import {{title}}.API{{/x-allowNonUniqueOperationIds}} -import {{title}}.Client -import {{title}}.Core -import {{title}}.Logging -import {{title}}.MimeTypes -import {{title}}.Model -import {{title}}.ModelLens \ No newline at end of file +{{^x-allowNonUniqueOperationIds}}import {{baseModule}}.API{{/x-allowNonUniqueOperationIds}} +import {{baseModule}}.Client +import {{baseModule}}.Core +import {{baseModule}}.Logging +import {{baseModule}}.MimeTypes +import {{baseModule}}.Model +import {{baseModule}}.ModelLens \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache index cb911bec7dd..3bffa485a03 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/haskell-http-client.cabal.mustache @@ -1,8 +1,8 @@ -name: {{package}} -version: 0.1.0.0 -synopsis: Auto-generated {{package}} API Client +name: {{cabalPackage}} +version: {{cabalVersion}} +synopsis: Auto-generated {{cabalPackage}} API Client 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}} . @@ -61,18 +61,18 @@ library , unordered-containers , 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}} - 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: 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 test-suite tests @@ -82,7 +82,7 @@ test-suite tests tests ghc-options: -Wall -fno-warn-orphans build-depends: - {{package}} + {{cabalPackage}} , QuickCheck , aeson , base >=4.7 && <5.0 diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache index afaaf140c98..985389ea54d 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Instances.mustache @@ -2,8 +2,8 @@ module Instances where -import {{title}}.Model -import {{title}}.Core +import {{baseModule}}.Model +import {{baseModule}}.Core import qualified Data.Aeson as A import qualified Data.ByteString.Lazy as BL diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/PropMime.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/PropMime.mustache index f672a4d3adf..726b8c606f1 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/PropMime.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/PropMime.mustache @@ -15,7 +15,7 @@ import Test.QuickCheck import Test.QuickCheck.Property import Test.Hspec.QuickCheck (prop) -import {{title}}.MimeTypes +import {{baseModule}}.MimeTypes import ApproxEq diff --git a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Test.mustache b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Test.mustache index cfa211d3ae7..36d3ef014dd 100644 --- a/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Test.mustache +++ b/modules/swagger-codegen/src/main/resources/haskell-http-client/tests/Test.mustache @@ -12,8 +12,8 @@ import Test.Hspec.QuickCheck import PropMime import Instances () -import {{title}}.Model -import {{title}}.MimeTypes +import {{baseModule}}.Model +import {{baseModule}}.MimeTypes main :: IO () main = diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java index 3f85fa388e9..eb912d59f07 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/haskellhttpclient/HaskellHttpClientOptionsTest.java @@ -24,10 +24,6 @@ public class HaskellHttpClientOptionsTest extends AbstractOptionsTest { @Override protected void setExpectations() { 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)); times = 1; clientCodegen.setAllowNonUniqueOperationIds(Boolean.valueOf(HaskellHttpClientOptionsProvider.ALLOW_NONUNIQUE_OPERATION_IDS)); @@ -56,7 +52,16 @@ public class HaskellHttpClientOptionsTest extends AbstractOptionsTest { times = 1; clientCodegen.setUseMonadLogger(Boolean.valueOf(HaskellHttpClientOptionsProvider.USE_MONAD_LOGGER)); 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; }}; } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java index 0700349477a..eac388e33d4 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/HaskellHttpClientOptionsProvider.java @@ -28,6 +28,12 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider { public static final String INLINE_MIME_TYPES = "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 public String getLanguage() { return "haskell-http-client"; @@ -36,8 +42,7 @@ public class HaskellHttpClientOptionsProvider implements OptionsProvider { @Override public Map createOptions() { ImmutableMap.Builder builder = new ImmutableMap.Builder(); - return builder.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE) - .put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE) + return builder .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_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_STRICT_FIELDS, STRICT_FIELDS) .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(); } diff --git a/samples/client/petstore/haskell-http-client/.swagger-codegen/VERSION b/samples/client/petstore/haskell-http-client/.swagger-codegen/VERSION index cc6612c36e0..855ff9501eb 100644 --- a/samples/client/petstore/haskell-http-client/.swagger-codegen/VERSION +++ b/samples/client/petstore/haskell-http-client/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.0 \ No newline at end of file +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/README.md b/samples/client/petstore/haskell-http-client/README.md index 85512a541f6..c7e6b2355fe 100644 --- a/samples/client/petstore/haskell-http-client/README.md +++ b/samples/client/petstore/haskell-http-client/README.md @@ -58,9 +58,13 @@ These options allow some customization of the code generation process. | 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 | +| 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 | +| 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 | | 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 | @@ -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 | | 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 | | | +| requestType | Set the name of the type used to generate requests | | SwaggerPetstoreRequest | | 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 | diff --git a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html index 47aace02858..adc3e741bf0 100644 --- a/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html +++ b/samples/client/petstore/haskell-http-client/docs/SwaggerPetstore-Core.html @@ -1,4 +1,4 @@ SwaggerPetstore.Core

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Core

Description

 

Synopsis

SwaggerPetstoreConfig

data SwaggerPetstoreConfig Source #

Constructors

SwaggerPetstoreConfig 

Fields

newConfig :: IO SwaggerPetstoreConfig Source #

constructs a default SwaggerPetstoreConfig

configHost:

http://petstore.swagger.io:80/v2

configUserAgent:

"swagger-haskell-http-client/1.0.0"

addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig Source #

updates config use AuthMethod on matching requests

withStdoutLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stdout logging

withStderrLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stderr logging

withNoLogging :: SwaggerPetstoreConfig -> SwaggerPetstoreConfig Source #

updates the config to disable logging

SwaggerPetstoreRequest

data SwaggerPetstoreRequest req contentType res accept Source #

Represents a request.

Type Variables:

  • req - request operation
  • contentType - MimeType associated with request body
  • res - response model
  • accept - MimeType associated with response body

Constructors

SwaggerPetstoreRequest 

Fields

Instances

Show (SwaggerPetstoreRequest req contentType res accept) Source # 

Methods

showsPrec :: Int -> SwaggerPetstoreRequest req contentType res accept -> ShowS #

show :: SwaggerPetstoreRequest req contentType res accept -> String #

showList :: [SwaggerPetstoreRequest req contentType res accept] -> ShowS #

rMethodL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) Method Source #

rMethod Lens

rUrlPathL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) [ByteString] Source #

rParamsL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) Params Source #

rParams Lens

rAuthTypesL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) [TypeRep] Source #

rParams Lens

HasBodyParam

class HasBodyParam req param where Source #

Designates the body parameter of a request

Methods

setBodyParam :: forall contentType res accept. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept Source #

Instances

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res accept -> User -> SwaggerPetstoreRequest UpdateUser contentType res accept Source #

HasBodyParam CreateUsersWithListInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUsersWithArrayInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res accept -> User -> SwaggerPetstoreRequest CreateUser contentType res accept Source #

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res accept -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res accept Source #

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res accept -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res accept Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res accept -> Pet -> SwaggerPetstoreRequest AddPet contentType res accept Source #

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res accept -> Client -> SwaggerPetstoreRequest TestClassname contentType res accept Source #

HasBodyParam TestInlineAdditionalProperties Value Source #

Body Param "param" - request body

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClientModel contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClientModel contentType res accept -> Client -> SwaggerPetstoreRequest TestClientModel contentType res accept Source #

HasBodyParam FakeOuterStringSerialize OuterString Source #

Body Param "body" - Input string as post body

HasBodyParam FakeOuterNumberSerialize OuterNumber Source #

Body Param "body" - Input number as post body

HasBodyParam FakeOuterCompositeSerialize OuterComposite Source #

Body Param "body" - Input composite as post body

HasBodyParam FakeOuterBooleanSerialize OuterBoolean Source #

Body Param "body" - Input boolean as post body

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestSpecialTags contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestSpecialTags contentType res accept -> Client -> SwaggerPetstoreRequest TestSpecialTags contentType res accept Source #

HasOptionalParam

class HasOptionalParam req param where Source #

Designates the optional parameters of a request

Minimal complete definition

applyOptionalParam | (-&-)

Methods

applyOptionalParam :: SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept Source #

Apply an optional parameter to a request

(-&-) :: SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept infixl 2 Source #

infix operator / alias for addOptionalParam

Instances

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

Methods

applyOptionalParam :: SwaggerPetstoreRequest UploadFile contentType res accept -> File -> SwaggerPetstoreRequest UploadFile contentType res accept Source #

(-&-) :: SwaggerPetstoreRequest UploadFile contentType res accept -> File -> SwaggerPetstoreRequest UploadFile contentType res accept Source #

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

HasOptionalParam UpdatePetWithForm StatusText Source #

Optional Param "status" - Updated status of the pet

HasOptionalParam UpdatePetWithForm Name2 Source #

Optional Param "name" - Updated name of the pet

HasOptionalParam DeletePet ApiKey Source # 

Methods

applyOptionalParam :: SwaggerPetstoreRequest DeletePet contentType res accept -> ApiKey -> SwaggerPetstoreRequest DeletePet contentType res accept Source #

(-&-) :: SwaggerPetstoreRequest DeletePet contentType res accept -> ApiKey -> SwaggerPetstoreRequest DeletePet contentType res accept Source #

HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

data Params Source #

Request Params

Instances

SwaggerPetstoreRequest Utils

_mkRequest Source #

Arguments

:: Method

Method

-> [ByteString]

Endpoint

-> SwaggerPetstoreRequest req contentType res accept

req: Request Type, res: Response Type

setHeader :: SwaggerPetstoreRequest req contentType res accept -> [Header] -> SwaggerPetstoreRequest req contentType res accept Source #

removeHeader :: SwaggerPetstoreRequest req contentType res accept -> [HeaderName] -> SwaggerPetstoreRequest req contentType res accept Source #

_setContentTypeHeader :: forall req contentType res accept. MimeType contentType => SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreRequest req contentType res accept Source #

_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreRequest req contentType res accept Source #

setQuery :: SwaggerPetstoreRequest req contentType res accept -> [QueryItem] -> SwaggerPetstoreRequest req contentType res accept Source #

addForm :: SwaggerPetstoreRequest req contentType res accept -> Form -> SwaggerPetstoreRequest req contentType res accept Source #

_addMultiFormPart :: SwaggerPetstoreRequest req contentType res accept -> Part -> SwaggerPetstoreRequest req contentType res accept Source #

_setBodyBS :: SwaggerPetstoreRequest req contentType res accept -> ByteString -> SwaggerPetstoreRequest req contentType res accept Source #

_setBodyLBS :: SwaggerPetstoreRequest req contentType res accept -> ByteString -> SwaggerPetstoreRequest req contentType res accept Source #

_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res accept -> Proxy authMethod -> SwaggerPetstoreRequest req contentType res accept Source #

Params Utils

Swagger CollectionFormat Utils

data CollectionFormat Source #

Determines the format of the array if type array is used.

Constructors

CommaSeparated

CSV format for multiple parameters.

SpaceSeparated

Also called SSV

TabSeparated

Also called TSV

PipeSeparated

`value1|value2|value2`

MultiParamArray

Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" (Query) or "formData" (Form)

_toColl :: Traversable f => CollectionFormat -> (f a -> [(b, ByteString)]) -> f [a] -> [(b, ByteString)] Source #

_toCollA :: (Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t ByteString)]) -> f (t [a]) -> [(b, t ByteString)] Source #

_toCollA' :: (Monoid c, Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] Source #

AuthMethods

class Typeable a => AuthMethod a where Source #

Provides a method to apply auth methods to requests

Minimal complete definition

applyAuthMethod

Methods

applyAuthMethod :: SwaggerPetstoreConfig -> a -> SwaggerPetstoreRequest req contentType res accept -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

data AnyAuthMethod Source #

An existential wrapper for any AuthMethod

Constructors

AuthMethod a => AnyAuthMethod a 

Instances

AuthMethod AnyAuthMethod Source # 

Methods

applyAuthMethod :: SwaggerPetstoreConfig -> AnyAuthMethod -> SwaggerPetstoreRequest req contentType res accept -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

_applyAuthMethods :: SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreConfig -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

apply all matching AuthMethods in config to request

Utils

_omitNulls :: [(Text, Value)] -> Value Source #

Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)

_toFormItem :: (ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) Source #

Encodes fields using WH.toQueryParam

_emptyToNothing :: Maybe String -> Maybe String Source #

Collapse (Just "") to Nothing

_memptyToNothing :: (Monoid a, Eq a) => Maybe a -> Maybe a Source #

Collapse (Just mempty) to Nothing

DateTime Formatting

newtype DateTime Source #

Constructors

DateTime 

Fields

Instances

Eq DateTime Source # 
Data DateTime Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DateTime -> c DateTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateTime #

toConstr :: DateTime -> Constr #

dataTypeOf :: DateTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DateTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateTime) #

gmapT :: (forall b. Data b => b -> b) -> DateTime -> DateTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> DateTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DateTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

Ord DateTime Source # 
Show DateTime Source # 
ToJSON DateTime Source # 
FromJSON DateTime Source # 
NFData DateTime Source # 

Methods

rnf :: DateTime -> () #

ToHttpApiData DateTime Source # 
FromHttpApiData DateTime Source # 
FormatTime DateTime Source # 
ParseTime DateTime Source # 
MimeRender MimeMultipartFormData DateTime Source # 

_readDateTime :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

_parseISO8601

_showDateTime :: (t ~ UTCTime, FormatTime t) => t -> String Source #

TI.formatISO8601Millis

_parseISO8601 :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

parse an ISO8601 date-time string

Date Formatting

newtype Date Source #

Constructors

Date 

Fields

Instances

Enum Date Source # 

Methods

succ :: Date -> Date #

pred :: Date -> Date #

toEnum :: Int -> Date #

fromEnum :: Date -> Int #

enumFrom :: Date -> [Date] #

enumFromThen :: Date -> Date -> [Date] #

enumFromTo :: Date -> Date -> [Date] #

enumFromThenTo :: Date -> Date -> Date -> [Date] #

Eq Date Source # 

Methods

(==) :: Date -> Date -> Bool #

(/=) :: Date -> Date -> Bool #

Data Date Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Date -> c Date #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Date #

toConstr :: Date -> Constr #

dataTypeOf :: Date -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Date) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Date) #

gmapT :: (forall b. Data b => b -> b) -> Date -> Date #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQ :: (forall d. Data d => d -> u) -> Date -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Date -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

Ord Date Source # 

Methods

compare :: Date -> Date -> Ordering #

(<) :: Date -> Date -> Bool #

(<=) :: Date -> Date -> Bool #

(>) :: Date -> Date -> Bool #

(>=) :: Date -> Date -> Bool #

max :: Date -> Date -> Date #

min :: Date -> Date -> Date #

Show Date Source # 

Methods

showsPrec :: Int -> Date -> ShowS #

show :: Date -> String #

showList :: [Date] -> ShowS #

Ix Date Source # 

Methods

range :: (Date, Date) -> [Date] #

index :: (Date, Date) -> Date -> Int #

unsafeIndex :: (Date, Date) -> Date -> Int

inRange :: (Date, Date) -> Date -> Bool #

rangeSize :: (Date, Date) -> Int #

unsafeRangeSize :: (Date, Date) -> Int

ToJSON Date Source # 
FromJSON Date Source # 
NFData Date Source # 

Methods

rnf :: Date -> () #

ToHttpApiData Date Source # 
FromHttpApiData Date Source # 
FormatTime Date Source # 
ParseTime Date Source # 

Methods

buildTime :: TimeLocale -> [(Char, String)] -> Maybe Date #

MimeRender MimeMultipartFormData Date Source # 

_readDate :: (ParseTime t, Monad m) => String -> m t Source #

TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"

_showDate :: FormatTime t => t -> String Source #

TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"

Byte/Binary Formatting

newtype ByteArray Source #

base64 encoded characters

Constructors

ByteArray 

Instances

Eq ByteArray Source # 
Data ByteArray Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteArray -> c ByteArray #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteArray #

toConstr :: ByteArray -> Constr #

dataTypeOf :: ByteArray -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ByteArray) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteArray) #

gmapT :: (forall b. Data b => b -> b) -> ByteArray -> ByteArray #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQ :: (forall d. Data d => d -> u) -> ByteArray -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteArray -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

Ord ByteArray Source # 
Show ByteArray Source # 
ToJSON ByteArray Source # 
FromJSON ByteArray Source # 
NFData ByteArray Source # 

Methods

rnf :: ByteArray -> () #

ToHttpApiData ByteArray Source # 
FromHttpApiData ByteArray Source # 
MimeRender MimeMultipartFormData ByteArray Source # 

_readByteArray :: Monad m => Text -> m ByteArray Source #

read base64 encoded characters

_showByteArray :: ByteArray -> Text Source #

show base64 encoded characters

newtype Binary Source #

any sequence of octets

Constructors

Binary 

Fields

Instances

Eq Binary Source # 

Methods

(==) :: Binary -> Binary -> Bool #

(/=) :: Binary -> Binary -> Bool #

Data Binary Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Binary -> c Binary #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Binary #

toConstr :: Binary -> Constr #

dataTypeOf :: Binary -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Binary) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binary) #

gmapT :: (forall b. Data b => b -> b) -> Binary -> Binary #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQ :: (forall d. Data d => d -> u) -> Binary -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Binary -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

Ord Binary Source # 
Show Binary Source # 
ToJSON Binary Source # 
FromJSON Binary Source # 
NFData Binary Source # 

Methods

rnf :: Binary -> () #

ToHttpApiData Binary Source # 
FromHttpApiData Binary Source # 
MimeRender MimeMultipartFormData Binary Source # 

Lens Type Aliases

type Lens_' s a = Lens_ s s a a Source #

type Lens_ s t a b = forall (f :: * -> *). Functor f => (a -> f b) -> s -> f t Source #

\ No newline at end of file +

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

Safe HaskellNone
LanguageHaskell2010

SwaggerPetstore.Core

Description

 

Synopsis

SwaggerPetstoreConfig

data SwaggerPetstoreConfig Source #

Constructors

SwaggerPetstoreConfig 

Fields

newConfig :: IO SwaggerPetstoreConfig Source #

constructs a default SwaggerPetstoreConfig

configHost:

http://petstore.swagger.io:80/v2

configUserAgent:

"swagger-petstore/0.1.0.0"

addAuthMethod :: AuthMethod auth => SwaggerPetstoreConfig -> auth -> SwaggerPetstoreConfig Source #

updates config use AuthMethod on matching requests

withStdoutLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stdout logging

withStderrLogging :: SwaggerPetstoreConfig -> IO SwaggerPetstoreConfig Source #

updates the config to use stderr logging

withNoLogging :: SwaggerPetstoreConfig -> SwaggerPetstoreConfig Source #

updates the config to disable logging

SwaggerPetstoreRequest

data SwaggerPetstoreRequest req contentType res accept Source #

Represents a request.

Type Variables:

  • req - request operation
  • contentType - MimeType associated with request body
  • res - response model
  • accept - MimeType associated with response body

Constructors

SwaggerPetstoreRequest 

Fields

Instances

Show (SwaggerPetstoreRequest req contentType res accept) Source # 

Methods

showsPrec :: Int -> SwaggerPetstoreRequest req contentType res accept -> ShowS #

show :: SwaggerPetstoreRequest req contentType res accept -> String #

showList :: [SwaggerPetstoreRequest req contentType res accept] -> ShowS #

rMethodL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) Method Source #

rMethod Lens

rUrlPathL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) [ByteString] Source #

rParamsL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) Params Source #

rParams Lens

rAuthTypesL :: Lens_' (SwaggerPetstoreRequest req contentType res accept) [TypeRep] Source #

rParams Lens

HasBodyParam

class HasBodyParam req param where Source #

Designates the body parameter of a request

Methods

setBodyParam :: forall contentType res accept. (Consumes req contentType, MimeRender contentType param) => SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept Source #

Instances

HasBodyParam UpdateUser User Source #

Body Param "body" - Updated user object

Methods

setBodyParam :: (Consumes UpdateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest UpdateUser contentType res accept -> User -> SwaggerPetstoreRequest UpdateUser contentType res accept Source #

HasBodyParam CreateUsersWithListInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUsersWithArrayInput Body Source #

Body Param "body" - List of user object

HasBodyParam CreateUser User Source #

Body Param "body" - Created user object

Methods

setBodyParam :: (Consumes CreateUser contentType, MimeRender contentType User) => SwaggerPetstoreRequest CreateUser contentType res accept -> User -> SwaggerPetstoreRequest CreateUser contentType res accept Source #

HasBodyParam PlaceOrder Order Source #

Body Param "body" - order placed for purchasing the pet

Methods

setBodyParam :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => SwaggerPetstoreRequest PlaceOrder contentType res accept -> Order -> SwaggerPetstoreRequest PlaceOrder contentType res accept Source #

HasBodyParam UpdatePet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes UpdatePet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest UpdatePet contentType res accept -> Pet -> SwaggerPetstoreRequest UpdatePet contentType res accept Source #

HasBodyParam AddPet Pet Source #

Body Param "body" - Pet object that needs to be added to the store

Methods

setBodyParam :: (Consumes AddPet contentType, MimeRender contentType Pet) => SwaggerPetstoreRequest AddPet contentType res accept -> Pet -> SwaggerPetstoreRequest AddPet contentType res accept Source #

HasBodyParam TestClassname Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClassname contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClassname contentType res accept -> Client -> SwaggerPetstoreRequest TestClassname contentType res accept Source #

HasBodyParam TestInlineAdditionalProperties Value Source #

Body Param "param" - request body

HasBodyParam TestClientModel Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestClientModel contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestClientModel contentType res accept -> Client -> SwaggerPetstoreRequest TestClientModel contentType res accept Source #

HasBodyParam FakeOuterStringSerialize OuterString Source #

Body Param "body" - Input string as post body

HasBodyParam FakeOuterNumberSerialize OuterNumber Source #

Body Param "body" - Input number as post body

HasBodyParam FakeOuterCompositeSerialize OuterComposite Source #

Body Param "body" - Input composite as post body

HasBodyParam FakeOuterBooleanSerialize OuterBoolean Source #

Body Param "body" - Input boolean as post body

HasBodyParam TestSpecialTags Client Source #

Body Param "body" - client model

Methods

setBodyParam :: (Consumes TestSpecialTags contentType, MimeRender contentType Client) => SwaggerPetstoreRequest TestSpecialTags contentType res accept -> Client -> SwaggerPetstoreRequest TestSpecialTags contentType res accept Source #

HasOptionalParam

class HasOptionalParam req param where Source #

Designates the optional parameters of a request

Minimal complete definition

applyOptionalParam | (-&-)

Methods

applyOptionalParam :: SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept Source #

Apply an optional parameter to a request

(-&-) :: SwaggerPetstoreRequest req contentType res accept -> param -> SwaggerPetstoreRequest req contentType res accept infixl 2 Source #

infix operator / alias for addOptionalParam

Instances

HasOptionalParam UploadFile File Source #

Optional Param "file" - file to upload

Methods

applyOptionalParam :: SwaggerPetstoreRequest UploadFile contentType res accept -> File -> SwaggerPetstoreRequest UploadFile contentType res accept Source #

(-&-) :: SwaggerPetstoreRequest UploadFile contentType res accept -> File -> SwaggerPetstoreRequest UploadFile contentType res accept Source #

HasOptionalParam UploadFile AdditionalMetadata Source #

Optional Param "additionalMetadata" - Additional data to pass to server

HasOptionalParam UpdatePetWithForm StatusText Source #

Optional Param "status" - Updated status of the pet

HasOptionalParam UpdatePetWithForm Name2 Source #

Optional Param "name" - Updated name of the pet

HasOptionalParam DeletePet ApiKey Source # 

Methods

applyOptionalParam :: SwaggerPetstoreRequest DeletePet contentType res accept -> ApiKey -> SwaggerPetstoreRequest DeletePet contentType res accept Source #

(-&-) :: SwaggerPetstoreRequest DeletePet contentType res accept -> ApiKey -> SwaggerPetstoreRequest DeletePet contentType res accept Source #

HasOptionalParam TestEnumParameters EnumQueryStringArray Source #

Optional Param "enum_query_string_array" - Query parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumQueryString Source #

Optional Param "enum_query_string" - Query parameter enum test (string)

HasOptionalParam TestEnumParameters EnumQueryInteger Source #

Optional Param "enum_query_integer" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumQueryDouble Source #

Optional Param "enum_query_double" - Query parameter enum test (double)

HasOptionalParam TestEnumParameters EnumHeaderStringArray Source #

Optional Param "enum_header_string_array" - Header parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumHeaderString Source #

Optional Param "enum_header_string" - Header parameter enum test (string)

HasOptionalParam TestEnumParameters EnumFormStringArray Source #

Optional Param "enum_form_string_array" - Form parameter enum test (string array)

HasOptionalParam TestEnumParameters EnumFormString Source #

Optional Param "enum_form_string" - Form parameter enum test (string)

HasOptionalParam TestEndpointParameters Password Source #

Optional Param "password" - None

HasOptionalParam TestEndpointParameters ParamString Source #

Optional Param "string" - None

HasOptionalParam TestEndpointParameters ParamInteger Source #

Optional Param "integer" - None

HasOptionalParam TestEndpointParameters ParamFloat Source #

Optional Param "float" - None

HasOptionalParam TestEndpointParameters ParamDateTime Source #

Optional Param "dateTime" - None

HasOptionalParam TestEndpointParameters ParamDate Source #

Optional Param "date" - None

HasOptionalParam TestEndpointParameters ParamBinary Source #

Optional Param "binary" - None

HasOptionalParam TestEndpointParameters Int64 Source #

Optional Param "int64" - None

HasOptionalParam TestEndpointParameters Int32 Source #

Optional Param "int32" - None

HasOptionalParam TestEndpointParameters Callback Source #

Optional Param "callback" - None

data Params Source #

Request Params

Instances

SwaggerPetstoreRequest Utils

_mkRequest Source #

Arguments

:: Method

Method

-> [ByteString]

Endpoint

-> SwaggerPetstoreRequest req contentType res accept

req: Request Type, res: Response Type

setHeader :: SwaggerPetstoreRequest req contentType res accept -> [Header] -> SwaggerPetstoreRequest req contentType res accept Source #

removeHeader :: SwaggerPetstoreRequest req contentType res accept -> [HeaderName] -> SwaggerPetstoreRequest req contentType res accept Source #

_setContentTypeHeader :: forall req contentType res accept. MimeType contentType => SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreRequest req contentType res accept Source #

_setAcceptHeader :: forall req contentType res accept. MimeType accept => SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreRequest req contentType res accept Source #

setQuery :: SwaggerPetstoreRequest req contentType res accept -> [QueryItem] -> SwaggerPetstoreRequest req contentType res accept Source #

addForm :: SwaggerPetstoreRequest req contentType res accept -> Form -> SwaggerPetstoreRequest req contentType res accept Source #

_addMultiFormPart :: SwaggerPetstoreRequest req contentType res accept -> Part -> SwaggerPetstoreRequest req contentType res accept Source #

_setBodyBS :: SwaggerPetstoreRequest req contentType res accept -> ByteString -> SwaggerPetstoreRequest req contentType res accept Source #

_setBodyLBS :: SwaggerPetstoreRequest req contentType res accept -> ByteString -> SwaggerPetstoreRequest req contentType res accept Source #

_hasAuthType :: AuthMethod authMethod => SwaggerPetstoreRequest req contentType res accept -> Proxy authMethod -> SwaggerPetstoreRequest req contentType res accept Source #

Params Utils

Swagger CollectionFormat Utils

data CollectionFormat Source #

Determines the format of the array if type array is used.

Constructors

CommaSeparated

CSV format for multiple parameters.

SpaceSeparated

Also called SSV

TabSeparated

Also called TSV

PipeSeparated

`value1|value2|value2`

MultiParamArray

Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" (Query) or "formData" (Form)

_toColl :: Traversable f => CollectionFormat -> (f a -> [(b, ByteString)]) -> f [a] -> [(b, ByteString)] Source #

_toCollA :: (Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t ByteString)]) -> f (t [a]) -> [(b, t ByteString)] Source #

_toCollA' :: (Monoid c, Traversable f, Traversable t, Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)] Source #

AuthMethods

class Typeable a => AuthMethod a where Source #

Provides a method to apply auth methods to requests

Minimal complete definition

applyAuthMethod

Methods

applyAuthMethod :: SwaggerPetstoreConfig -> a -> SwaggerPetstoreRequest req contentType res accept -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

data AnyAuthMethod Source #

An existential wrapper for any AuthMethod

Constructors

AuthMethod a => AnyAuthMethod a 

Instances

AuthMethod AnyAuthMethod Source # 

Methods

applyAuthMethod :: SwaggerPetstoreConfig -> AnyAuthMethod -> SwaggerPetstoreRequest req contentType res accept -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

_applyAuthMethods :: SwaggerPetstoreRequest req contentType res accept -> SwaggerPetstoreConfig -> IO (SwaggerPetstoreRequest req contentType res accept) Source #

apply all matching AuthMethods in config to request

Utils

_omitNulls :: [(Text, Value)] -> Value Source #

Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)

_toFormItem :: (ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) Source #

Encodes fields using WH.toQueryParam

_emptyToNothing :: Maybe String -> Maybe String Source #

Collapse (Just "") to Nothing

_memptyToNothing :: (Monoid a, Eq a) => Maybe a -> Maybe a Source #

Collapse (Just mempty) to Nothing

DateTime Formatting

newtype DateTime Source #

Constructors

DateTime 

Fields

Instances

Eq DateTime Source # 
Data DateTime Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DateTime -> c DateTime #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateTime #

toConstr :: DateTime -> Constr #

dataTypeOf :: DateTime -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c DateTime) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateTime) #

gmapT :: (forall b. Data b => b -> b) -> DateTime -> DateTime #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r #

gmapQ :: (forall d. Data d => d -> u) -> DateTime -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> DateTime -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime #

Ord DateTime Source # 
Show DateTime Source # 
ToJSON DateTime Source # 
FromJSON DateTime Source # 
NFData DateTime Source # 

Methods

rnf :: DateTime -> () #

ToHttpApiData DateTime Source # 
FromHttpApiData DateTime Source # 
FormatTime DateTime Source # 
ParseTime DateTime Source # 
MimeRender MimeMultipartFormData DateTime Source # 

_readDateTime :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

_parseISO8601

_showDateTime :: (t ~ UTCTime, FormatTime t) => t -> String Source #

TI.formatISO8601Millis

_parseISO8601 :: (ParseTime t, Monad m, Alternative m) => String -> m t Source #

parse an ISO8601 date-time string

Date Formatting

newtype Date Source #

Constructors

Date 

Fields

Instances

Enum Date Source # 

Methods

succ :: Date -> Date #

pred :: Date -> Date #

toEnum :: Int -> Date #

fromEnum :: Date -> Int #

enumFrom :: Date -> [Date] #

enumFromThen :: Date -> Date -> [Date] #

enumFromTo :: Date -> Date -> [Date] #

enumFromThenTo :: Date -> Date -> Date -> [Date] #

Eq Date Source # 

Methods

(==) :: Date -> Date -> Bool #

(/=) :: Date -> Date -> Bool #

Data Date Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Date -> c Date #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Date #

toConstr :: Date -> Constr #

dataTypeOf :: Date -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Date) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Date) #

gmapT :: (forall b. Data b => b -> b) -> Date -> Date #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r #

gmapQ :: (forall d. Data d => d -> u) -> Date -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Date -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date #

Ord Date Source # 

Methods

compare :: Date -> Date -> Ordering #

(<) :: Date -> Date -> Bool #

(<=) :: Date -> Date -> Bool #

(>) :: Date -> Date -> Bool #

(>=) :: Date -> Date -> Bool #

max :: Date -> Date -> Date #

min :: Date -> Date -> Date #

Show Date Source # 

Methods

showsPrec :: Int -> Date -> ShowS #

show :: Date -> String #

showList :: [Date] -> ShowS #

Ix Date Source # 

Methods

range :: (Date, Date) -> [Date] #

index :: (Date, Date) -> Date -> Int #

unsafeIndex :: (Date, Date) -> Date -> Int

inRange :: (Date, Date) -> Date -> Bool #

rangeSize :: (Date, Date) -> Int #

unsafeRangeSize :: (Date, Date) -> Int

ToJSON Date Source # 
FromJSON Date Source # 
NFData Date Source # 

Methods

rnf :: Date -> () #

ToHttpApiData Date Source # 
FromHttpApiData Date Source # 
FormatTime Date Source # 
ParseTime Date Source # 

Methods

buildTime :: TimeLocale -> [(Char, String)] -> Maybe Date #

MimeRender MimeMultipartFormData Date Source # 

_readDate :: (ParseTime t, Monad m) => String -> m t Source #

TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"

_showDate :: FormatTime t => t -> String Source #

TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"

Byte/Binary Formatting

newtype ByteArray Source #

base64 encoded characters

Constructors

ByteArray 

Instances

Eq ByteArray Source # 
Data ByteArray Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteArray -> c ByteArray #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteArray #

toConstr :: ByteArray -> Constr #

dataTypeOf :: ByteArray -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ByteArray) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteArray) #

gmapT :: (forall b. Data b => b -> b) -> ByteArray -> ByteArray #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteArray -> r #

gmapQ :: (forall d. Data d => d -> u) -> ByteArray -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteArray -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteArray -> m ByteArray #

Ord ByteArray Source # 
Show ByteArray Source # 
ToJSON ByteArray Source # 
FromJSON ByteArray Source # 
NFData ByteArray Source # 

Methods

rnf :: ByteArray -> () #

ToHttpApiData ByteArray Source # 
FromHttpApiData ByteArray Source # 
MimeRender MimeMultipartFormData ByteArray Source # 

_readByteArray :: Monad m => Text -> m ByteArray Source #

read base64 encoded characters

_showByteArray :: ByteArray -> Text Source #

show base64 encoded characters

newtype Binary Source #

any sequence of octets

Constructors

Binary 

Fields

Instances

Eq Binary Source # 

Methods

(==) :: Binary -> Binary -> Bool #

(/=) :: Binary -> Binary -> Bool #

Data Binary Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Binary -> c Binary #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Binary #

toConstr :: Binary -> Constr #

dataTypeOf :: Binary -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Binary) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binary) #

gmapT :: (forall b. Data b => b -> b) -> Binary -> Binary #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Binary -> r #

gmapQ :: (forall d. Data d => d -> u) -> Binary -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Binary -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Binary -> m Binary #

Ord Binary Source # 
Show Binary Source # 
ToJSON Binary Source # 
FromJSON Binary Source # 
NFData Binary Source # 

Methods

rnf :: Binary -> () #

ToHttpApiData Binary Source # 
FromHttpApiData Binary Source # 
MimeRender MimeMultipartFormData Binary Source # 

Lens Type Aliases

type Lens_' s a = Lens_ s s a a Source #

type Lens_ s t a b = forall (f :: * -> *). Functor f => (a -> f b) -> s -> f t Source #

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/index.html b/samples/client/petstore/haskell-http-client/docs/index.html index ab5f09e32df..85e97971fec 100644 --- a/samples/client/petstore/haskell-http-client/docs/index.html +++ b/samples/client/petstore/haskell-http-client/docs/index.html @@ -2,4 +2,4 @@ window.onload = function () {pageLoad();}; //]]>

swagger-petstore-0.1.0.0: Auto-generated swagger-petstore API Client

\ No newline at end of file +Client library for calling the Swagger Petstore API based on http-client.

host: petstore.swagger.io:80

base path: http://petstore.swagger.io:80/v2

Swagger Petstore API version: 1.0.0

OpenAPI spec version: 2.0

OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

Signatures

\ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html index 1e17ed4cbfc..c0221442fa7 100644 --- a/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html +++ b/samples/client/petstore/haskell-http-client/docs/src/SwaggerPetstore.Core.html @@ -96,14 +96,14 @@ Module : SwaggerPetstore.Core -- -- configUserAgent: -- --- @"swagger-haskell-http-client/1.0.0"@ +-- @"swagger-petstore/0.1.0.0"@ -- newConfig :: IO SwaggerPetstoreConfig newConfig = do logCxt <- initLogContext return $ SwaggerPetstoreConfig { configHost = "http://petstore.swagger.io:80/v2" - , configUserAgent = "swagger-haskell-http-client/1.0.0" + , configUserAgent = "swagger-petstore/0.1.0.0" , configLogExecWithContext = runDefaultLogExecWithContext , configLogContext = logCxt , configAuthMethods = [] diff --git a/samples/client/petstore/haskell-http-client/docs/swagger-petstore.txt b/samples/client/petstore/haskell-http-client/docs/swagger-petstore.txt index 36e2174b57d..4545461bbdd 100644 --- a/samples/client/petstore/haskell-http-client/docs/swagger-petstore.txt +++ b/samples/client/petstore/haskell-http-client/docs/swagger-petstore.txt @@ -4,7 +4,7 @@ -- | 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. -- -- host: petstore.swagger.io:80 @@ -296,7 +296,7 @@ SwaggerPetstoreConfig :: ByteString -> Text -> LogExecWithContext -> LogContext -- configUserAgent: -- --
---   "swagger-haskell-http-client/1.0.0"
+--   "swagger-petstore/0.1.0.0"
 --   
newConfig :: IO SwaggerPetstoreConfig diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs index 3e540481c55..3a2a3fe75c5 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs @@ -96,14 +96,14 @@ instance P.Show SwaggerPetstoreConfig where -- -- configUserAgent: -- --- @"swagger-haskell-http-client/1.0.0"@ +-- @"swagger-petstore/0.1.0.0"@ -- newConfig :: IO SwaggerPetstoreConfig newConfig = do logCxt <- initLogContext return $ SwaggerPetstoreConfig { configHost = "http://petstore.swagger.io:80/v2" - , configUserAgent = "swagger-haskell-http-client/1.0.0" + , configUserAgent = "swagger-petstore/0.1.0.0" , configLogExecWithContext = runDefaultLogExecWithContext , configLogContext = logCxt , configAuthMethods = [] diff --git a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal index dc7a34382b9..90480f56d0c 100644 --- a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal +++ b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal @@ -2,7 +2,7 @@ name: swagger-petstore version: 0.1.0.0 synopsis: Auto-generated swagger-petstore API Client 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 . @@ -57,6 +57,8 @@ library , unordered-containers , vector >=0.10.9 && <0.13 , katip >=0.4 && < 0.6 + other-modules: + Paths_swagger_petstore exposed-modules: SwaggerPetstore SwaggerPetstore.API @@ -72,8 +74,6 @@ library SwaggerPetstore.MimeTypes SwaggerPetstore.Model SwaggerPetstore.ModelLens - other-modules: - Paths_swagger_petstore default-language: Haskell2010 test-suite tests