From 9c28f6f0892213f5cd5109e36163b0a802140243 Mon Sep 17 00:00:00 2001 From: Joel Bach <6702422+joel-bach@users.noreply.github.com> Date: Sat, 30 Mar 2024 20:11:22 +0100 Subject: [PATCH] chore: update example code --- .github/workflows/build.yml | 1 + README.md | 17 +-- example-configuration.yml | 3 - example/generatedCode/default.nix | 14 +++ example/generatedCode/openapi.cabal | 0 example/generatedCode/src/OpenAPI.hs | 0 example/generatedCode/src/OpenAPI/Common.hs | 113 +++++++++--------- .../src/OpenAPI/Configuration.hs | 5 +- .../src/OpenAPI/Operations/AddPet.hs | 23 ++-- .../src/OpenAPI/Operations/CreateUser.hs | 23 ++-- .../Operations/CreateUsersWithArrayInput.hs | 23 ++-- .../Operations/CreateUsersWithListInput.hs | 23 ++-- .../src/OpenAPI/Operations/DeleteOrder.hs | 23 ++-- .../src/OpenAPI/Operations/DeletePet.hs | 23 ++-- .../src/OpenAPI/Operations/DeleteUser.hs | 23 ++-- .../OpenAPI/Operations/FindPetsByStatus.hs | 41 +++---- .../src/OpenAPI/Operations/FindPetsByTags.hs | 23 ++-- .../src/OpenAPI/Operations/GetInventory.hs | 23 ++-- .../src/OpenAPI/Operations/GetOrderById.hs | 23 ++-- .../src/OpenAPI/Operations/GetPetById.hs | 23 ++-- .../src/OpenAPI/Operations/GetUserByName.hs | 23 ++-- .../src/OpenAPI/Operations/LoginUser.hs | 37 +++--- .../src/OpenAPI/Operations/LogoutUser.hs | 23 ++-- .../src/OpenAPI/Operations/PlaceOrder.hs | 23 ++-- .../src/OpenAPI/Operations/UpdatePet.hs | 23 ++-- .../OpenAPI/Operations/UpdatePetWithForm.hs | 29 ++--- .../src/OpenAPI/Operations/UpdateUser.hs | 23 ++-- .../src/OpenAPI/Operations/UploadFile.hs | 23 ++-- .../src/OpenAPI/SecuritySchemes.hs | 2 +- .../generatedCode/src/OpenAPI/TypeAlias.hs | 6 +- example/generatedCode/src/OpenAPI/Types.hs | 0 .../src/OpenAPI/Types/ApiResponse.hs | 12 +- .../src/OpenAPI/Types/ApiResponse.hs-boot | 0 .../src/OpenAPI/Types/Category.hs | 12 +- .../src/OpenAPI/Types/Category.hs-boot | 0 .../generatedCode/src/OpenAPI/Types/Order.hs | 30 ++--- .../src/OpenAPI/Types/Order.hs-boot | 0 .../generatedCode/src/OpenAPI/Types/Pet.hs | 30 ++--- .../src/OpenAPI/Types/Pet.hs-boot | 0 .../generatedCode/src/OpenAPI/Types/Tag.hs | 12 +- .../src/OpenAPI/Types/Tag.hs-boot | 0 .../generatedCode/src/OpenAPI/Types/User.hs | 12 +- .../src/OpenAPI/Types/User.hs-boot | 0 example/generatedCode/stack.yaml | 2 +- example/petstore-running-example.cabal | 46 ------- example/src/Lib.hs | 8 +- flake.nix | 12 +- nix/tests.nix | 12 ++ .../petstore-running-example/src/Lib.hs | 2 +- .../petstore-running-example/test/Spec.hs | 9 +- ..._golden.sh => update_golden_and_example.sh | 7 ++ 51 files changed, 435 insertions(+), 430 deletions(-) delete mode 100644 example-configuration.yml create mode 100755 example/generatedCode/default.nix mode change 100644 => 100755 example/generatedCode/openapi.cabal mode change 100644 => 100755 example/generatedCode/src/OpenAPI.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Common.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Configuration.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/AddPet.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/CreateUser.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/CreateUsersWithArrayInput.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/CreateUsersWithListInput.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/DeleteOrder.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/DeletePet.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/DeleteUser.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/FindPetsByStatus.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/FindPetsByTags.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/GetInventory.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/GetOrderById.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/GetPetById.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/GetUserByName.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/LoginUser.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/LogoutUser.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/PlaceOrder.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/UpdatePet.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/UpdatePetWithForm.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/UpdateUser.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Operations/UploadFile.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/SecuritySchemes.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/TypeAlias.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/ApiResponse.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/ApiResponse.hs-boot mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Category.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Category.hs-boot mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Order.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Order.hs-boot mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Pet.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Pet.hs-boot mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Tag.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/Tag.hs-boot mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/User.hs mode change 100644 => 100755 example/generatedCode/src/OpenAPI/Types/User.hs-boot mode change 100644 => 100755 example/generatedCode/stack.yaml delete mode 100644 example/petstore-running-example.cabal rename update_golden.sh => update_golden_and_example.sh (52%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 521b666..9bf1897 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,7 @@ jobs: - .#checks.x86_64-linux.testSystem1 - .#checks.x86_64-linux.testSystem2 - .#checks.x86_64-linux.testSystem3 + - .#checks.x86_64-linux.testExample steps: - uses: actions/checkout@v2.5.0 - uses: cachix/install-nix-action@v20 diff --git a/README.md b/README.md index d753723..fd2efe1 100644 --- a/README.md +++ b/README.md @@ -72,22 +72,9 @@ The following features are not supported - `xml` ## Development -Re-generate the code found in the [example](./example/) directory if you made changes to the output generator. -You can do this using the [example-configuration.yml](./example-configuration.yml): -``` bash -openapi3-code-generator-exe --configuration example-configuration.yml -``` - -Also make sure that the tests there run fine: - -``` bash -cd example -stack test -``` - -Also adapt golden tests: +Make sure to update the example and the golden tests: ``` bash -./update_golden.sh +./update_golden_and_example.sh ``` diff --git a/example-configuration.yml b/example-configuration.yml deleted file mode 100644 index c9bb669..0000000 --- a/example-configuration.yml +++ /dev/null @@ -1,3 +0,0 @@ -specification: specifications/petstore.yaml -outputDir: example/generatedCode -force: true diff --git a/example/generatedCode/default.nix b/example/generatedCode/default.nix new file mode 100755 index 0000000..afca816 --- /dev/null +++ b/example/generatedCode/default.nix @@ -0,0 +1,14 @@ +{ mkDerivation, aeson, base, bytestring, ghc-prim, http-client +, http-conduit, http-types, lib, mtl, scientific, text, time +, transformers, unordered-containers, vector +}: +mkDerivation { + pname = "openapi"; + version = "0.1.0.0"; + src = ./.; + libraryHaskellDepends = [ + aeson base bytestring ghc-prim http-client http-conduit http-types + mtl scientific text time transformers unordered-containers vector + ]; + license = "unknown"; +} diff --git a/example/generatedCode/openapi.cabal b/example/generatedCode/openapi.cabal old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI.hs b/example/generatedCode/src/OpenAPI.hs old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Common.hs b/example/generatedCode/src/OpenAPI/Common.hs old mode 100644 new mode 100755 index 5fb8374..f3e27c9 --- a/example/generatedCode/src/OpenAPI/Common.hs +++ b/example/generatedCode/src/OpenAPI/Common.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} @@ -14,12 +15,13 @@ module OpenAPI.Common doBodyCallWithConfigurationM, runWithConfiguration, textToByte, + byteToText, stringifyModel, anonymousSecurityScheme, + jsonObjectToList, Configuration (..), SecurityScheme, MonadHTTP (..), - StringifyModel, JsonByteString (..), JsonDateTime (..), RequestBodyEncoding (..), @@ -35,25 +37,35 @@ import qualified Control.Monad.Reader as MR import qualified Control.Monad.Trans.Class as MT import qualified Data.Aeson as Aeson import qualified Data.Aeson.Encoding as Encoding +import Data.Aeson.Text (encodeToTextBuilder) import qualified Data.Bifunctor as BF -import qualified Data.ByteString.Char8 as B8 -import qualified Data.ByteString.Lazy.Char8 as LB8 -import qualified Data.HashMap.Strict as HMap +import qualified Data.ByteString as BS +import qualified Data.ByteString.Lazy as LBS import qualified Data.Maybe as Maybe import qualified Data.Scientific as Scientific import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as TE +import Data.Text.Encoding.Error (lenientDecode) +import Data.Text.Lazy (toStrict) +import Data.Text.Lazy.Builder (toLazyText) import qualified Data.Time.LocalTime as Time import qualified Data.Vector as Vector import qualified Network.HTTP.Client as HC import qualified Network.HTTP.Simple as HS import qualified Network.HTTP.Types as HT +#if MIN_VERSION_aeson(2,0,0) +import qualified Data.Aeson.Key as Key +import qualified Data.Aeson.KeyMap as KeyMap +#else +import qualified Data.HashMap.Strict as HMap +#endif + -- | Abstracts the usage of 'Network.HTTP.Simple.httpBS' away, -- so that it can be used for testing class Monad m => MonadHTTP m where - httpBS :: HS.Request -> m (HS.Response B8.ByteString) + httpBS :: HS.Request -> m (HS.Response BS.ByteString) -- | This instance is the default instance used for production code instance MonadHTTP IO where @@ -154,7 +166,7 @@ doCallWithConfiguration :: -- | Query parameters [QueryParameter] -> -- | The raw response from the server - m (HS.Response B8.ByteString) + m (HS.Response BS.ByteString) doCallWithConfiguration config method path queryParams = httpBS $ createBaseRequest config method path queryParams @@ -165,7 +177,7 @@ doCallWithConfigurationM :: Text -> Text -> [QueryParameter] -> - ClientT m (HS.Response B8.ByteString) + ClientT m (HS.Response BS.ByteString) doCallWithConfigurationM method path queryParams = do config <- MR.ask MT.lift $ doCallWithConfiguration config method path queryParams @@ -188,7 +200,7 @@ doBodyCallWithConfiguration :: -- | JSON or form data deepobjects RequestBodyEncoding -> -- | The raw response from the server - m (HS.Response B8.ByteString) + m (HS.Response BS.ByteString) doBodyCallWithConfiguration config method path queryParams Nothing _ = doCallWithConfiguration config method path queryParams doBodyCallWithConfiguration config method path queryParams (Just body) RequestBodyEncodingJSON = httpBS $ HS.setRequestMethod (textToByte method) $ HS.setRequestBodyJSON body baseRequest @@ -209,7 +221,7 @@ doBodyCallWithConfigurationM :: [QueryParameter] -> Maybe body -> RequestBodyEncoding -> - ClientT m (HS.Response B8.ByteString) + ClientT m (HS.Response BS.ByteString) doBodyCallWithConfigurationM method path queryParams body encoding = do config <- MR.ask MT.lift $ doBodyCallWithConfiguration config method path queryParams body encoding @@ -232,13 +244,13 @@ createBaseRequest config method path queryParams = HS.setRequestMethod (textToByte method) $ HS.setRequestQueryString query $ HS.setRequestPath - (B8.pack (T.unpack $ byteToText basePathModifier <> path)) + (textToByte $ basePathModifier <> path) baseRequest where baseRequest = parseURL $ configBaseURL config - basePath = HC.path baseRequest + basePath = byteToText $ HC.path baseRequest basePathModifier = - if basePath == B8.pack "/" && T.isPrefixOf "/" path + if basePath == "/" && T.isPrefixOf "/" path then "" else basePath -- filters all maybe @@ -249,17 +261,19 @@ createBaseRequest config method path queryParams = then HS.addRequestHeader HT.hUserAgent $ textToByte userAgent else id -serializeQueryParams :: [QueryParameter] -> [(B8.ByteString, B8.ByteString)] +serializeQueryParams :: [QueryParameter] -> [(BS.ByteString, BS.ByteString)] serializeQueryParams = (>>= serializeQueryParam) -serializeQueryParam :: QueryParameter -> [(B8.ByteString, B8.ByteString)] +serializeQueryParam :: QueryParameter -> [(BS.ByteString, BS.ByteString)] serializeQueryParam QueryParameter {..} = - let concatValues :: B8.ByteString -> [(Maybe Text, B8.ByteString)] -> [(Text, B8.ByteString)] + let concatValues :: BS.ByteString -> [(Maybe Text, BS.ByteString)] -> [(Text, BS.ByteString)] concatValues joinWith = if queryParamExplode then fmap (BF.first $ Maybe.fromMaybe queryParamName) else - pure . (queryParamName,) . B8.intercalate joinWith + pure + . (queryParamName,) + . BS.intercalate joinWith . fmap ( \case (Nothing, value) -> value @@ -277,29 +291,29 @@ serializeQueryParam QueryParameter {..} = ) $ jsonToFormDataFlat Nothing value -encodeStrict :: Aeson.ToJSON a => a -> B8.ByteString -encodeStrict = LB8.toStrict . Aeson.encode +encodeStrict :: Aeson.ToJSON a => a -> BS.ByteString +encodeStrict = LBS.toStrict . Aeson.encode -jsonToFormDataFlat :: Maybe Text -> Aeson.Value -> [(Maybe Text, B8.ByteString)] +jsonToFormDataFlat :: Maybe Text -> Aeson.Value -> [(Maybe Text, BS.ByteString)] jsonToFormDataFlat _ Aeson.Null = [] jsonToFormDataFlat name (Aeson.Number a) = [(name, encodeStrict a)] jsonToFormDataFlat name (Aeson.String a) = [(name, textToByte a)] jsonToFormDataFlat name (Aeson.Bool a) = [(name, encodeStrict a)] -jsonToFormDataFlat _ (Aeson.Object object) = HMap.toList object >>= uncurry jsonToFormDataFlat . BF.first Just +jsonToFormDataFlat _ (Aeson.Object object) = jsonObjectToList object >>= uncurry jsonToFormDataFlat . BF.first Just jsonToFormDataFlat name (Aeson.Array vector) = Vector.toList vector >>= jsonToFormDataFlat name -- | creates form data bytestring array -createFormData :: (Aeson.ToJSON a) => a -> [(B8.ByteString, B8.ByteString)] +createFormData :: (Aeson.ToJSON a) => a -> [(BS.ByteString, BS.ByteString)] createFormData body = let formData = jsonToFormData $ Aeson.toJSON body in fmap (BF.bimap textToByte textToByte) formData --- | Convert a 'B8.ByteString' to 'Text' -byteToText :: B8.ByteString -> Text -byteToText = TE.decodeUtf8 +-- | Convert a 'BS.ByteString' to 'Text' +byteToText :: BS.ByteString -> Text +byteToText = TE.decodeUtf8With lenientDecode --- | Convert 'Text' a to 'B8.ByteString' -textToByte :: Text -> B8.ByteString +-- | Convert 'Text' a to 'BS.ByteString' +textToByte :: Text -> BS.ByteString textToByte = TE.encodeUtf8 parseURL :: Text -> HS.Request @@ -320,43 +334,26 @@ jsonToFormDataPrefixed prefix (Aeson.Bool False) = [(prefix, "false")] jsonToFormDataPrefixed _ Aeson.Null = [] jsonToFormDataPrefixed prefix (Aeson.String a) = [(prefix, a)] jsonToFormDataPrefixed "" (Aeson.Object object) = - HMap.toList object >>= uncurry jsonToFormDataPrefixed + jsonObjectToList object >>= uncurry jsonToFormDataPrefixed jsonToFormDataPrefixed prefix (Aeson.Object object) = - HMap.toList object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y) + jsonObjectToList object >>= (\(x, y) -> jsonToFormDataPrefixed (prefix <> "[" <> x <> "]") y) jsonToFormDataPrefixed prefix (Aeson.Array vector) = Vector.toList vector >>= jsonToFormDataPrefixed (prefix <> "[]") --- | This type class makes the code generation for URL parameters easier as it allows to stringify a value +-- | This function makes the code generation for URL parameters easier as it allows to stringify a value -- -- The 'Show' class is not sufficient as strings should not be stringified with quotes. -class Show a => StringifyModel a where - -- | Stringifies a showable value - -- - -- >>> stringifyModel "Test" - -- "Test" - -- - -- >>> stringifyModel 123 - -- "123" - stringifyModel :: a -> String - -instance StringifyModel String where - -- stringifyModel :: String -> String - stringifyModel = id - -instance StringifyModel Text where - -- stringifyModel :: Text -> String - stringifyModel = T.unpack - -instance {-# OVERLAPS #-} Show a => StringifyModel a where - -- stringifyModel :: Show a => a -> String - stringifyModel = show - --- | Wraps a 'B8.ByteString' to implement 'Aeson.ToJSON' and 'Aeson.FromJSON' -newtype JsonByteString = JsonByteString B8.ByteString +stringifyModel :: Aeson.ToJSON a => a -> Text +stringifyModel x = case Aeson.toJSON x of + Aeson.String s -> s + v -> toStrict $ toLazyText $ encodeToTextBuilder v + +-- | Wraps a 'BS.ByteString' to implement 'Aeson.ToJSON' and 'Aeson.FromJSON' +newtype JsonByteString = JsonByteString BS.ByteString deriving (Show, Eq, Ord) instance Aeson.ToJSON JsonByteString where - toJSON (JsonByteString s) = Aeson.toJSON $ B8.unpack s + toJSON (JsonByteString s) = Aeson.toJSON $ byteToText s instance Aeson.FromJSON JsonByteString where parseJSON (Aeson.String s) = pure $ JsonByteString $ textToByte s @@ -391,3 +388,11 @@ instance Aeson.ToJSON a => Aeson.ToJSON (Nullable a) where instance Aeson.FromJSON a => Aeson.FromJSON (Nullable a) where parseJSON Aeson.Null = pure Null parseJSON x = NonNull <$> Aeson.parseJSON x + +#if MIN_VERSION_aeson(2,0,0) +jsonObjectToList :: KeyMap.KeyMap v -> [(Text, v)] +jsonObjectToList = fmap (BF.first Key.toText) . KeyMap.toList +#else +jsonObjectToList :: HMap.HashMap Text v -> [(Text, v)] +jsonObjectToList = HMap.toList +#endif diff --git a/example/generatedCode/src/OpenAPI/Configuration.hs b/example/generatedCode/src/OpenAPI/Configuration.hs old mode 100644 new mode 100755 index 254d27c..e220324 --- a/example/generatedCode/src/OpenAPI/Configuration.hs +++ b/example/generatedCode/src/OpenAPI/Configuration.hs @@ -6,16 +6,17 @@ module OpenAPI.Configuration where import qualified Data.Text +import qualified Data.Text as Data.Text.Internal import qualified GHC.Types import qualified OpenAPI.Common -- | The default url specified by the OpenAPI specification -- -- @https://petstore.swagger.io/v2@ -defaultURL = Data.Text.pack "https://petstore.swagger.io/v2" +defaultURL = Data.Text.Internal.pack "https://petstore.swagger.io/v2" -- | The default application name used in the @User-Agent@ header which is based on the @info.title@ field of the specification -- -- @Swagger Petstore@ -defaultApplicationName = Data.Text.pack "Swagger Petstore" +defaultApplicationName = Data.Text.Internal.pack "Swagger Petstore" -- | The default configuration containing the 'defaultURL' and no authorization defaultConfiguration = OpenAPI.Common.Configuration defaultURL OpenAPI.Common.anonymousSecurityScheme GHC.Types.True defaultApplicationName diff --git a/example/generatedCode/src/OpenAPI/Operations/AddPet.hs b/example/generatedCode/src/OpenAPI/Operations/AddPet.hs old mode 100644 new mode 100755 index ffdce3f..36f34ea --- a/example/generatedCode/src/OpenAPI/Operations/AddPet.hs +++ b/example/generatedCode/src/OpenAPI/Operations/AddPet.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -51,7 +52,7 @@ addPet :: forall m . OpenAPI.Common.MonadHTTP m => Pet -- ^ The request body to -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response AddPetResponse) -- ^ Monadic computation which returns the result of the operation addPet body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either AddPetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right AddPetResponse200 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right AddPetResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'addPet'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'AddPetResponseError' is used. @@ -69,18 +70,18 @@ addPetWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Comm addPetWithConfiguration config body = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either AddPetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right AddPetResponse200 | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right AddPetResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /pet -- --- The same as 'addPet' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'addPet' but returns the raw 'Data.ByteString.ByteString'. addPetRaw :: forall m . OpenAPI.Common.MonadHTTP m => Pet -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -addPetRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +addPetRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /pet -- --- The same as 'addPet' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'addPet' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. addPetWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Pet -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation addPetWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/CreateUser.hs b/example/generatedCode/src/OpenAPI/Operations/CreateUser.hs old mode 100644 new mode 100755 index 3a76068..d6f5aa9 --- a/example/generatedCode/src/OpenAPI/Operations/CreateUser.hs +++ b/example/generatedCode/src/OpenAPI/Operations/CreateUser.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -50,7 +51,7 @@ import OpenAPI.Types createUser :: forall m . OpenAPI.Common.MonadHTTP m => User -- ^ The request body to send -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response CreateUserResponse) -- ^ Monadic computation which returns the result of the operation createUser body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either CreateUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUserResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'createUser'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'CreateUserResponseError' is used. @@ -66,18 +67,18 @@ createUserWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI. -> m (Network.HTTP.Client.Types.Response CreateUserResponse) -- ^ Monadic computation which returns the result of the operation createUserWithConfiguration config body = GHC.Base.fmap (\response_1 -> GHC.Base.fmap (Data.Either.either CreateUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUserResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user -- --- The same as 'createUser' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUser' but returns the raw 'Data.ByteString.ByteString'. createUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => User -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -createUserRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +createUserRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user -- --- The same as 'createUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. createUserWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> User -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation createUserWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithArrayInput.hs b/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithArrayInput.hs old mode 100644 new mode 100755 index d7a9644..a6fd36f --- a/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithArrayInput.hs +++ b/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithArrayInput.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -50,7 +51,7 @@ import OpenAPI.Types createUsersWithArrayInput :: forall m . OpenAPI.Common.MonadHTTP m => [User] -- ^ The request body to send -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response CreateUsersWithArrayInputResponse) -- ^ Monadic computation which returns the result of the operation createUsersWithArrayInput body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either CreateUsersWithArrayInputResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUsersWithArrayInputResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithArray") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithArray" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'createUsersWithArrayInput'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'CreateUsersWithArrayInputResponseError' is used. @@ -66,18 +67,18 @@ createUsersWithArrayInputWithConfiguration :: forall m . OpenAPI.Common.MonadHTT -> m (Network.HTTP.Client.Types.Response CreateUsersWithArrayInputResponse) -- ^ Monadic computation which returns the result of the operation createUsersWithArrayInputWithConfiguration config body = GHC.Base.fmap (\response_1 -> GHC.Base.fmap (Data.Either.either CreateUsersWithArrayInputResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUsersWithArrayInputResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithArray") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithArray" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user/createWithArray -- --- The same as 'createUsersWithArrayInput' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUsersWithArrayInput' but returns the raw 'Data.ByteString.ByteString'. createUsersWithArrayInputRaw :: forall m . OpenAPI.Common.MonadHTTP m => [User] -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -createUsersWithArrayInputRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithArray") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +createUsersWithArrayInputRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithArray" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user/createWithArray -- --- The same as 'createUsersWithArrayInput' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUsersWithArrayInput' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. createUsersWithArrayInputWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> [User] -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation createUsersWithArrayInputWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithArray") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithArray" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithListInput.hs b/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithListInput.hs old mode 100644 new mode 100755 index 1358213..9416053 --- a/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithListInput.hs +++ b/example/generatedCode/src/OpenAPI/Operations/CreateUsersWithListInput.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -50,7 +51,7 @@ import OpenAPI.Types createUsersWithListInput :: forall m . OpenAPI.Common.MonadHTTP m => [User] -- ^ The request body to send -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response CreateUsersWithListInputResponse) -- ^ Monadic computation which returns the result of the operation createUsersWithListInput body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either CreateUsersWithListInputResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUsersWithListInputResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithList") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithList" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'createUsersWithListInput'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'CreateUsersWithListInputResponseError' is used. @@ -66,18 +67,18 @@ createUsersWithListInputWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP -> m (Network.HTTP.Client.Types.Response CreateUsersWithListInputResponse) -- ^ Monadic computation which returns the result of the operation createUsersWithListInputWithConfiguration config body = GHC.Base.fmap (\response_1 -> GHC.Base.fmap (Data.Either.either CreateUsersWithListInputResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right CreateUsersWithListInputResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithList") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithList" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user/createWithList -- --- The same as 'createUsersWithListInput' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUsersWithListInput' but returns the raw 'Data.ByteString.ByteString'. createUsersWithListInputRaw :: forall m . OpenAPI.Common.MonadHTTP m => [User] -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -createUsersWithListInputRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithList") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +createUsersWithListInputRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithList" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /user/createWithList -- --- The same as 'createUsersWithListInput' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'createUsersWithListInput' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. createUsersWithListInputWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> [User] -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation createUsersWithListInputWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/user/createWithList") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/user/createWithList" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/DeleteOrder.hs b/example/generatedCode/src/OpenAPI/Operations/DeleteOrder.hs old mode 100644 new mode 100755 index 15aee2b..6cdf8ce --- a/example/generatedCode/src/OpenAPI/Operations/DeleteOrder.hs +++ b/example/generatedCode/src/OpenAPI/Operations/DeleteOrder.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -51,7 +52,7 @@ deleteOrder :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ order -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response DeleteOrderResponse) -- ^ Monadic computation which returns the result of the operation deleteOrder orderId = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either DeleteOrderResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteOrderResponse400 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteOrderResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'deleteOrder'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'DeleteOrderResponseError' is used. @@ -69,18 +70,18 @@ deleteOrderWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI deleteOrderWithConfiguration config orderId = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either DeleteOrderResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteOrderResponse400 | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteOrderResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /store/order/{orderId} -- --- The same as 'deleteOrder' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deleteOrder' but returns the raw 'Data.ByteString.ByteString'. deleteOrderRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ orderId: ID of the order that needs to be deleted | Constraints: Minimum of 1.0 - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -deleteOrderRaw orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +deleteOrderRaw orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /store/order/{orderId} -- --- The same as 'deleteOrder' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deleteOrder' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. deleteOrderWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ orderId: ID of the order that needs to be deleted | Constraints: Minimum of 1.0 - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation deleteOrderWithConfigurationRaw config - orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/DeletePet.hs b/example/generatedCode/src/OpenAPI/Operations/DeletePet.hs old mode 100644 new mode 100755 index 6fbe1dc..2bd11a8 --- a/example/generatedCode/src/OpenAPI/Operations/DeletePet.hs +++ b/example/generatedCode/src/OpenAPI/Operations/DeletePet.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -51,7 +52,7 @@ deletePet :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response DeletePetResponse) -- ^ Monadic computation which returns the result of the operation deletePet petId = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either DeletePetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeletePetResponse400 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeletePetResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'deletePet'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'DeletePetResponseError' is used. @@ -69,18 +70,18 @@ deletePetWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.C deletePetWithConfiguration config petId = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either DeletePetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeletePetResponse400 | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeletePetResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /pet/{petId} -- --- The same as 'deletePet' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deletePet' but returns the raw 'Data.ByteString.ByteString'. deletePetRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: Pet id to delete - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -deletePetRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +deletePetRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /pet/{petId} -- --- The same as 'deletePet' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deletePet' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. deletePetWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ petId: Pet id to delete - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation deletePetWithConfigurationRaw config - petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/DeleteUser.hs b/example/generatedCode/src/OpenAPI/Operations/DeleteUser.hs old mode 100644 new mode 100755 index 4a97b85..ffd7e21 --- a/example/generatedCode/src/OpenAPI/Operations/DeleteUser.hs +++ b/example/generatedCode/src/OpenAPI/Operations/DeleteUser.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -51,7 +52,7 @@ deleteUser :: forall m . OpenAPI.Common.MonadHTTP m => Data.Text.Internal.Text - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response DeleteUserResponse) -- ^ Monadic computation which returns the result of the operation deleteUser username = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either DeleteUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteUserResponse400 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteUserResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'deleteUser'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'DeleteUserResponseError' is used. @@ -69,18 +70,18 @@ deleteUserWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI. deleteUserWithConfiguration config username = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either DeleteUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteUserResponse400 | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right DeleteUserResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /user/{username} -- --- The same as 'deleteUser' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deleteUser' but returns the raw 'Data.ByteString.ByteString'. deleteUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => Data.Text.Internal.Text -- ^ username: The name that needs to be deleted - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -deleteUserRaw username = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +deleteUserRaw username = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | > DELETE /user/{username} -- --- The same as 'deleteUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'deleteUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. deleteUserWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Data.Text.Internal.Text -- ^ username: The name that needs to be deleted - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation deleteUserWithConfigurationRaw config - username = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "DELETE") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + username = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "DELETE") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/FindPetsByStatus.hs b/example/generatedCode/src/OpenAPI/Operations/FindPetsByStatus.hs old mode 100644 new mode 100755 index a3dec01..b7f4da6 --- a/example/generatedCode/src/OpenAPI/Operations/FindPetsByStatus.hs +++ b/example/generatedCode/src/OpenAPI/Operations/FindPetsByStatus.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,7 +53,7 @@ findPetsByStatus :: forall m . OpenAPI.Common.MonadHTTP m => [FindPetsByStatusPa findPetsByStatus status = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either FindPetsByStatusResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> FindPetsByStatusResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ([Pet])) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right FindPetsByStatusResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByStatus") [OpenAPI.Common.QueryParameter (Data.Text.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.pack "form") GHC.Types.True]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByStatus" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | Defines the enum schema located at @paths.\/pet\/findByStatus.GET.parameters.[0].schema.items@ in the specification. -- -- @@ -64,16 +65,16 @@ data FindPetsByStatusParametersStatus = | FindPetsByStatusParametersStatusEnumSold -- ^ Represents the JSON value @"sold"@ deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON FindPetsByStatusParametersStatus - where toJSON (FindPetsByStatusParametersStatusOther val) = val - toJSON (FindPetsByStatusParametersStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val - toJSON (FindPetsByStatusParametersStatusEnumAvailable) = "available" - toJSON (FindPetsByStatusParametersStatusEnumPending) = "pending" - toJSON (FindPetsByStatusParametersStatusEnumSold) = "sold" + where {toJSON (FindPetsByStatusParametersStatusOther val) = val; + toJSON (FindPetsByStatusParametersStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (FindPetsByStatusParametersStatusEnumAvailable) = "available"; + toJSON (FindPetsByStatusParametersStatusEnumPending) = "pending"; + toJSON (FindPetsByStatusParametersStatusEnumSold) = "sold"} instance Data.Aeson.Types.FromJSON.FromJSON FindPetsByStatusParametersStatus - where parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> FindPetsByStatusParametersStatusEnumAvailable - | val GHC.Classes.== "pending" -> FindPetsByStatusParametersStatusEnumPending - | val GHC.Classes.== "sold" -> FindPetsByStatusParametersStatusEnumSold - | GHC.Base.otherwise -> FindPetsByStatusParametersStatusOther val) + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> FindPetsByStatusParametersStatusEnumAvailable + | val GHC.Classes.== "pending" -> FindPetsByStatusParametersStatusEnumPending + | val GHC.Classes.== "sold" -> FindPetsByStatusParametersStatusEnumSold + | GHC.Base.otherwise -> FindPetsByStatusParametersStatusOther val)} -- | Represents a response of the operation 'findPetsByStatus'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'FindPetsByStatusResponseError' is used. @@ -92,18 +93,18 @@ findPetsByStatusWithConfiguration config status = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either FindPetsByStatusResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> FindPetsByStatusResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ([Pet])) | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right FindPetsByStatusResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByStatus") [OpenAPI.Common.QueryParameter (Data.Text.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.pack "form") GHC.Types.True]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByStatus" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | > GET /pet/findByStatus -- --- The same as 'findPetsByStatus' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'findPetsByStatus' but returns the raw 'Data.ByteString.ByteString'. findPetsByStatusRaw :: forall m . OpenAPI.Common.MonadHTTP m => [FindPetsByStatusParametersStatus] -- ^ status: Status values that need to be considered for filter - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -findPetsByStatusRaw status = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByStatus") [OpenAPI.Common.QueryParameter (Data.Text.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.pack "form") GHC.Types.True]) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +findPetsByStatusRaw status = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByStatus" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | > GET /pet/findByStatus -- --- The same as 'findPetsByStatus' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'findPetsByStatus' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. findPetsByStatusWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> [FindPetsByStatusParametersStatus] -- ^ status: Status values that need to be considered for filter - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation findPetsByStatusWithConfigurationRaw config - status = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByStatus") [OpenAPI.Common.QueryParameter (Data.Text.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.pack "form") GHC.Types.True]) + status = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByStatus" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON status) (Data.Text.Internal.pack "form") GHC.Types.True]) diff --git a/example/generatedCode/src/OpenAPI/Operations/FindPetsByTags.hs b/example/generatedCode/src/OpenAPI/Operations/FindPetsByTags.hs old mode 100644 new mode 100755 index 9e2d0e2..9881630 --- a/example/generatedCode/src/OpenAPI/Operations/FindPetsByTags.hs +++ b/example/generatedCode/src/OpenAPI/Operations/FindPetsByTags.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,7 +53,7 @@ findPetsByTags :: forall m . OpenAPI.Common.MonadHTTP m => [Data.Text.Internal.T findPetsByTags tags = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either FindPetsByTagsResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> FindPetsByTagsResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ([Pet])) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right FindPetsByTagsResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByTags") [OpenAPI.Common.QueryParameter (Data.Text.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.pack "form") GHC.Types.True]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByTags" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | Represents a response of the operation 'findPetsByTags'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'FindPetsByTagsResponseError' is used. @@ -71,18 +72,18 @@ findPetsByTagsWithConfiguration config tags = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either FindPetsByTagsResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> FindPetsByTagsResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ([Pet])) | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right FindPetsByTagsResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByTags") [OpenAPI.Common.QueryParameter (Data.Text.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.pack "form") GHC.Types.True]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByTags" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | > GET /pet/findByTags -- --- The same as 'findPetsByTags' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'findPetsByTags' but returns the raw 'Data.ByteString.ByteString'. findPetsByTagsRaw :: forall m . OpenAPI.Common.MonadHTTP m => [Data.Text.Internal.Text] -- ^ tags: Tags to filter by - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -findPetsByTagsRaw tags = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByTags") [OpenAPI.Common.QueryParameter (Data.Text.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.pack "form") GHC.Types.True]) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +findPetsByTagsRaw tags = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByTags" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.Internal.pack "form") GHC.Types.True]) -- | > GET /pet/findByTags -- --- The same as 'findPetsByTags' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'findPetsByTags' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. findPetsByTagsWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> [Data.Text.Internal.Text] -- ^ tags: Tags to filter by - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation findPetsByTagsWithConfigurationRaw config - tags = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/pet/findByTags") [OpenAPI.Common.QueryParameter (Data.Text.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.pack "form") GHC.Types.True]) + tags = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/pet/findByTags" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "tags") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON tags) (Data.Text.Internal.pack "form") GHC.Types.True]) diff --git a/example/generatedCode/src/OpenAPI/Operations/GetInventory.hs b/example/generatedCode/src/OpenAPI/Operations/GetInventory.hs old mode 100644 new mode 100755 index 14967fe..84294fb --- a/example/generatedCode/src/OpenAPI/Operations/GetInventory.hs +++ b/example/generatedCode/src/OpenAPI/Operations/GetInventory.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -50,7 +51,7 @@ import OpenAPI.Types getInventory :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response GetInventoryResponse) -- ^ Monadic computation which returns the result of the operation getInventory = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either GetInventoryResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> GetInventoryResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Data.Aeson.Types.Internal.Object) - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/store/inventory") GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/store/inventory" GHC.Base.mempty) -- | Represents a response of the operation 'getInventory'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'GetInventoryResponseError' is used. @@ -65,15 +66,15 @@ getInventoryWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAP -> m (Network.HTTP.Client.Types.Response GetInventoryResponse) -- ^ Monadic computation which returns the result of the operation getInventoryWithConfiguration config = GHC.Base.fmap (\response_2 -> GHC.Base.fmap (Data.Either.either GetInventoryResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> GetInventoryResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Data.Aeson.Types.Internal.Object) - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/store/inventory") GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/store/inventory" GHC.Base.mempty) -- | > GET /store/inventory -- --- The same as 'getInventory' but returns the raw 'Data.ByteString.Char8.ByteString'. -getInventoryRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -getInventoryRaw = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/store/inventory") GHC.Base.mempty) +-- The same as 'getInventory' but returns the raw 'Data.ByteString.ByteString'. +getInventoryRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +getInventoryRaw = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/store/inventory" GHC.Base.mempty) -- | > GET /store/inventory -- --- The same as 'getInventory' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getInventory' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. getInventoryWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -getInventoryWithConfigurationRaw config = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/store/inventory") GHC.Base.mempty) + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +getInventoryWithConfigurationRaw config = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/store/inventory" GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/GetOrderById.hs b/example/generatedCode/src/OpenAPI/Operations/GetOrderById.hs old mode 100644 new mode 100755 index 52b37c4..f314ad2 --- a/example/generatedCode/src/OpenAPI/Operations/GetOrderById.hs +++ b/example/generatedCode/src/OpenAPI/Operations/GetOrderById.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -53,7 +54,7 @@ getOrderById orderId = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either. Order) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetOrderByIdResponse400 | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetOrderByIdResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'getOrderById'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'GetOrderByIdResponseError' is used. @@ -74,18 +75,18 @@ getOrderByIdWithConfiguration config Order) | (\status_6 -> Network.HTTP.Types.Status.statusCode status_6 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetOrderByIdResponse400 | (\status_7 -> Network.HTTP.Types.Status.statusCode status_7 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetOrderByIdResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /store/order/{orderId} -- --- The same as 'getOrderById' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getOrderById' but returns the raw 'Data.ByteString.ByteString'. getOrderByIdRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ orderId: ID of pet that needs to be fetched | Constraints: Maxium of 10.0, Minimum of 1.0 - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -getOrderByIdRaw orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +getOrderByIdRaw orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /store/order/{orderId} -- --- The same as 'getOrderById' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getOrderById' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. getOrderByIdWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ orderId: ID of pet that needs to be fetched | Constraints: Maxium of 10.0, Minimum of 1.0 - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation getOrderByIdWithConfigurationRaw config - orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/store/order/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.++ ""))) GHC.Base.mempty) + orderId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/store/order/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel orderId)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/GetPetById.hs b/example/generatedCode/src/OpenAPI/Operations/GetPetById.hs old mode 100644 new mode 100755 index 8e36401..df050fc --- a/example/generatedCode/src/OpenAPI/Operations/GetPetById.hs +++ b/example/generatedCode/src/OpenAPI/Operations/GetPetById.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -53,7 +54,7 @@ getPetById petId = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.eith Pet) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetPetByIdResponse400 | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetPetByIdResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'getPetById'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'GetPetByIdResponseError' is used. @@ -74,18 +75,18 @@ getPetByIdWithConfiguration config Pet) | (\status_6 -> Network.HTTP.Types.Status.statusCode status_6 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetPetByIdResponse400 | (\status_7 -> Network.HTTP.Types.Status.statusCode status_7 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetPetByIdResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /pet/{petId} -- --- The same as 'getPetById' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getPetById' but returns the raw 'Data.ByteString.ByteString'. getPetByIdRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: ID of pet to return - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -getPetByIdRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +getPetByIdRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /pet/{petId} -- --- The same as 'getPetById' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getPetById' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. getPetByIdWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ petId: ID of pet to return - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation getPetByIdWithConfigurationRaw config - petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty) + petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/GetUserByName.hs b/example/generatedCode/src/OpenAPI/Operations/GetUserByName.hs old mode 100644 new mode 100755 index f86e700..f8593ca --- a/example/generatedCode/src/OpenAPI/Operations/GetUserByName.hs +++ b/example/generatedCode/src/OpenAPI/Operations/GetUserByName.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -53,7 +54,7 @@ getUserByName username = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Eithe User) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetUserByNameResponse400 | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetUserByNameResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | Represents a response of the operation 'getUserByName'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'GetUserByNameResponseError' is used. @@ -74,18 +75,18 @@ getUserByNameWithConfiguration config User) | (\status_6 -> Network.HTTP.Types.Status.statusCode status_6 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetUserByNameResponse400 | (\status_7 -> Network.HTTP.Types.Status.statusCode status_7 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right GetUserByNameResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /user/{username} -- --- The same as 'getUserByName' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getUserByName' but returns the raw 'Data.ByteString.ByteString'. getUserByNameRaw :: forall m . OpenAPI.Common.MonadHTTP m => Data.Text.Internal.Text -- ^ username: The name that needs to be fetched. Use user1 for testing. - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -getUserByNameRaw username = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +getUserByNameRaw username = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) -- | > GET /user/{username} -- --- The same as 'getUserByName' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'getUserByName' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. getUserByNameWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Data.Text.Internal.Text -- ^ username: The name that needs to be fetched. Use user1 for testing. - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation getUserByNameWithConfigurationRaw config - username = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty) + username = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/LoginUser.hs b/example/generatedCode/src/OpenAPI/Operations/LoginUser.hs old mode 100644 new mode 100755 index edab0f5..830d6d1 --- a/example/generatedCode/src/OpenAPI/Operations/LoginUser.hs +++ b/example/generatedCode/src/OpenAPI/Operations/LoginUser.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,8 +53,8 @@ loginUser :: forall m . OpenAPI.Common.MonadHTTP m => LoginUserParameters -- ^ C loginUser parameters = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either LoginUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> LoginUserResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Data.Text.Internal.Text) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right LoginUserResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/login") [OpenAPI.Common.QueryParameter (Data.Text.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.pack "form") GHC.Types.False, - OpenAPI.Common.QueryParameter (Data.Text.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.pack "form") GHC.Types.False]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/login" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) -- | Defines the object schema located at @paths.\/user\/login.GET.parameters@ in the specification. -- -- @@ -69,10 +70,10 @@ data LoginUserParameters = LoginUserParameters { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON LoginUserParameters - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (["queryPassword" Data.Aeson.Types.ToJSON..= loginUserParametersQueryPassword obj] : ["queryUsername" Data.Aeson.Types.ToJSON..= loginUserParametersQueryUsername obj] : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (["queryPassword" Data.Aeson.Types.ToJSON..= loginUserParametersQueryPassword obj] : ["queryUsername" Data.Aeson.Types.ToJSON..= loginUserParametersQueryUsername obj] : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (["queryPassword" Data.Aeson.Types.ToJSON..= loginUserParametersQueryPassword obj] : ["queryUsername" Data.Aeson.Types.ToJSON..= loginUserParametersQueryUsername obj] : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (["queryPassword" Data.Aeson.Types.ToJSON..= loginUserParametersQueryPassword obj] : ["queryUsername" Data.Aeson.Types.ToJSON..= loginUserParametersQueryUsername obj] : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON LoginUserParameters - where parseJSON = Data.Aeson.Types.FromJSON.withObject "LoginUserParameters" (\obj -> (GHC.Base.pure LoginUserParameters GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryPassword")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryUsername")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "LoginUserParameters" (\obj -> (GHC.Base.pure LoginUserParameters GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryPassword")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryUsername"))} -- | Create a new 'LoginUserParameters' with all required fields. mkLoginUserParameters :: Data.Text.Internal.Text -- ^ 'loginUserParametersQueryPassword' -> Data.Text.Internal.Text -- ^ 'loginUserParametersQueryUsername' @@ -97,21 +98,21 @@ loginUserWithConfiguration config parameters = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either LoginUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> LoginUserResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Data.Text.Internal.Text) | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right LoginUserResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/login") [OpenAPI.Common.QueryParameter (Data.Text.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.pack "form") GHC.Types.False, - OpenAPI.Common.QueryParameter (Data.Text.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.pack "form") GHC.Types.False]) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/login" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) -- | > GET /user/login -- --- The same as 'loginUser' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'loginUser' but returns the raw 'Data.ByteString.ByteString'. loginUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => LoginUserParameters -- ^ Contains all available parameters of this operation (query and path parameters) - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -loginUserRaw parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/login") [OpenAPI.Common.QueryParameter (Data.Text.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.pack "form") GHC.Types.False, - OpenAPI.Common.QueryParameter (Data.Text.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.pack "form") GHC.Types.False]) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +loginUserRaw parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/login" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) -- | > GET /user/login -- --- The same as 'loginUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'loginUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. loginUserWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> LoginUserParameters -- ^ Contains all available parameters of this operation (query and path parameters) - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation loginUserWithConfigurationRaw config - parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/login") [OpenAPI.Common.QueryParameter (Data.Text.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.pack "form") GHC.Types.False, - OpenAPI.Common.QueryParameter (Data.Text.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.pack "form") GHC.Types.False]) + parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/login" [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "username") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryUsername parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "password") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (loginUserParametersQueryPassword parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) diff --git a/example/generatedCode/src/OpenAPI/Operations/LogoutUser.hs b/example/generatedCode/src/OpenAPI/Operations/LogoutUser.hs old mode 100644 new mode 100755 index b3b3038..b185c46 --- a/example/generatedCode/src/OpenAPI/Operations/LogoutUser.hs +++ b/example/generatedCode/src/OpenAPI/Operations/LogoutUser.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -49,7 +50,7 @@ import OpenAPI.Types -- logoutUser :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response LogoutUserResponse) -- ^ Monadic computation which returns the result of the operation logoutUser = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either LogoutUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right LogoutUserResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/logout") GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/logout" GHC.Base.mempty) -- | Represents a response of the operation 'logoutUser'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'LogoutUserResponseError' is used. @@ -63,15 +64,15 @@ data LogoutUserResponse = logoutUserWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> m (Network.HTTP.Client.Types.Response LogoutUserResponse) -- ^ Monadic computation which returns the result of the operation logoutUserWithConfiguration config = GHC.Base.fmap (\response_1 -> GHC.Base.fmap (Data.Either.either LogoutUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right LogoutUserResponseDefault - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/logout") GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_1) response_1) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/logout" GHC.Base.mempty) -- | > GET /user/logout -- --- The same as 'logoutUser' but returns the raw 'Data.ByteString.Char8.ByteString'. -logoutUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -logoutUserRaw = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/logout") GHC.Base.mempty) +-- The same as 'logoutUser' but returns the raw 'Data.ByteString.ByteString'. +logoutUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +logoutUserRaw = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/logout" GHC.Base.mempty) -- | > GET /user/logout -- --- The same as 'logoutUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'logoutUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. logoutUserWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -logoutUserWithConfigurationRaw config = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "GET") (Data.Text.pack "/user/logout") GHC.Base.mempty) + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +logoutUserWithConfigurationRaw config = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") "/user/logout" GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/Operations/PlaceOrder.hs b/example/generatedCode/src/OpenAPI/Operations/PlaceOrder.hs old mode 100644 new mode 100755 index 009ed14..dbfd82b --- a/example/generatedCode/src/OpenAPI/Operations/PlaceOrder.hs +++ b/example/generatedCode/src/OpenAPI/Operations/PlaceOrder.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,7 +53,7 @@ placeOrder :: forall m . OpenAPI.Common.MonadHTTP m => Order -- ^ The request bo placeOrder body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either PlaceOrderResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> PlaceOrderResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Order) | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right PlaceOrderResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/store/order") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/store/order" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'placeOrder'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'PlaceOrderResponseError' is used. @@ -71,18 +72,18 @@ placeOrderWithConfiguration config body = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either PlaceOrderResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> PlaceOrderResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Order) | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right PlaceOrderResponse400 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/store/order") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/store/order" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /store/order -- --- The same as 'placeOrder' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'placeOrder' but returns the raw 'Data.ByteString.ByteString'. placeOrderRaw :: forall m . OpenAPI.Common.MonadHTTP m => Order -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -placeOrderRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/store/order") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +placeOrderRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/store/order" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > POST /store/order -- --- The same as 'placeOrder' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'placeOrder' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. placeOrderWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Order -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation placeOrderWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack "/store/order") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") "/store/order" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/UpdatePet.hs b/example/generatedCode/src/OpenAPI/Operations/UpdatePet.hs old mode 100644 new mode 100755 index 0e21e00..68b67e4 --- a/example/generatedCode/src/OpenAPI/Operations/UpdatePet.hs +++ b/example/generatedCode/src/OpenAPI/Operations/UpdatePet.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,7 +53,7 @@ updatePet :: forall m . OpenAPI.Common.MonadHTTP m => Pet -- ^ The request body updatePet body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either UpdatePetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse400 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse404 | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'updatePet'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'UpdatePetResponseError' is used. @@ -72,18 +73,18 @@ updatePetWithConfiguration config body = GHC.Base.fmap (\response_4 -> GHC.Base.fmap (Data.Either.either UpdatePetResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse400 | (\status_6 -> Network.HTTP.Types.Status.statusCode status_6 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse404 | (\status_7 -> Network.HTTP.Types.Status.statusCode status_7 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_4) response_4) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > PUT /pet -- --- The same as 'updatePet' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updatePet' but returns the raw 'Data.ByteString.ByteString'. updatePetRaw :: forall m . OpenAPI.Common.MonadHTTP m => Pet -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -updatePetRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +updatePetRaw body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > PUT /pet -- --- The same as 'updatePet' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updatePet' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. updatePetWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Pet -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation updatePetWithConfigurationRaw config - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack "/pet") GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") "/pet" GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/UpdatePetWithForm.hs b/example/generatedCode/src/OpenAPI/Operations/UpdatePetWithForm.hs old mode 100644 new mode 100755 index ac39827..71fd334 --- a/example/generatedCode/src/OpenAPI/Operations/UpdatePetWithForm.hs +++ b/example/generatedCode/src/OpenAPI/Operations/UpdatePetWithForm.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -52,7 +53,7 @@ updatePetWithForm :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response UpdatePetWithFormResponse) -- ^ Monadic computation which returns the result of the operation updatePetWithForm petId body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either UpdatePetWithFormResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetWithFormResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) -- | Defines the object schema located at @paths.\/pet\/{petId}.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification. -- -- @@ -64,10 +65,10 @@ data UpdatePetWithFormRequestBody = UpdatePetWithFormRequestBody { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON UpdatePetWithFormRequestBody - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyStatus obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyStatus obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyStatus obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (updatePetWithFormRequestBodyStatus obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON UpdatePetWithFormRequestBody - where parseJSON = Data.Aeson.Types.FromJSON.withObject "UpdatePetWithFormRequestBody" (\obj -> (GHC.Base.pure UpdatePetWithFormRequestBody GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "UpdatePetWithFormRequestBody" (\obj -> (GHC.Base.pure UpdatePetWithFormRequestBody GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status"))} -- | Create a new 'UpdatePetWithFormRequestBody' with all required fields. mkUpdatePetWithFormRequestBody :: UpdatePetWithFormRequestBody mkUpdatePetWithFormRequestBody = UpdatePetWithFormRequestBody{updatePetWithFormRequestBodyName = GHC.Maybe.Nothing, @@ -89,22 +90,22 @@ updatePetWithFormWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => O updatePetWithFormWithConfiguration config petId body = GHC.Base.fmap (\response_2 -> GHC.Base.fmap (Data.Either.either UpdatePetWithFormResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 405) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdatePetWithFormResponse405 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) -- | > POST /pet/{petId} -- --- The same as 'updatePetWithForm' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updatePetWithForm' but returns the raw 'Data.ByteString.ByteString'. updatePetWithFormRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: ID of pet that needs to be updated -> GHC.Maybe.Maybe UpdatePetWithFormRequestBody -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation updatePetWithFormRaw petId - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) -- | > POST /pet/{petId} -- --- The same as 'updatePetWithForm' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updatePetWithForm' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. updatePetWithFormWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ petId: ID of pet that needs to be updated -> GHC.Maybe.Maybe UpdatePetWithFormRequestBody -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation updatePetWithFormWithConfigurationRaw config petId - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ ""))) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "")) GHC.Base.mempty body OpenAPI.Common.RequestBodyEncodingFormData) diff --git a/example/generatedCode/src/OpenAPI/Operations/UpdateUser.hs b/example/generatedCode/src/OpenAPI/Operations/UpdateUser.hs old mode 100644 new mode 100755 index a25aa2b..e74c97b --- a/example/generatedCode/src/OpenAPI/Operations/UpdateUser.hs +++ b/example/generatedCode/src/OpenAPI/Operations/UpdateUser.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -53,7 +54,7 @@ updateUser :: forall m . OpenAPI.Common.MonadHTTP m => Data.Text.Internal.Text - updateUser username body = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either UpdateUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdateUserResponse400 | (\status_2 -> Network.HTTP.Types.Status.statusCode status_2 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdateUserResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | Represents a response of the operation 'updateUser'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'UpdateUserResponseError' is used. @@ -73,22 +74,22 @@ updateUserWithConfiguration config username body = GHC.Base.fmap (\response_3 -> GHC.Base.fmap (Data.Either.either UpdateUserResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_4 -> Network.HTTP.Types.Status.statusCode status_4 GHC.Classes.== 400) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdateUserResponse400 | (\status_5 -> Network.HTTP.Types.Status.statusCode status_5 GHC.Classes.== 404) (Network.HTTP.Client.Types.responseStatus response) -> Data.Either.Right UpdateUserResponse404 - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_3) response_3) (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > PUT /user/{username} -- --- The same as 'updateUser' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updateUser' but returns the raw 'Data.ByteString.ByteString'. updateUserRaw :: forall m . OpenAPI.Common.MonadHTTP m => Data.Text.Internal.Text -- ^ username: name that need to be updated -> User -- ^ The request body to send - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation updateUserRaw username - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) -- | > PUT /user/{username} -- --- The same as 'updateUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'updateUser' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. updateUserWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> Data.Text.Internal.Text -- ^ username: name that need to be updated -> User -- ^ The request body to send - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation updateUserWithConfigurationRaw config username - body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "PUT") (Data.Text.pack ("/user/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.++ ""))) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) + body = GHC.Base.id (OpenAPI.Common.doBodyCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "PUT") ("/user/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel username)) GHC.Base.<> "")) GHC.Base.mempty (GHC.Maybe.Just body) OpenAPI.Common.RequestBodyEncodingJSON) diff --git a/example/generatedCode/src/OpenAPI/Operations/UploadFile.hs b/example/generatedCode/src/OpenAPI/Operations/UploadFile.hs old mode 100644 new mode 100755 index a64f740..33b28ac --- a/example/generatedCode/src/OpenAPI/Operations/UploadFile.hs +++ b/example/generatedCode/src/OpenAPI/Operations/UploadFile.hs @@ -17,15 +17,16 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.ByteString as Data.ByteString.Internal.Type import qualified Data.Either import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified Data.Vector @@ -51,7 +52,7 @@ uploadFile :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response UploadFileResponse) -- ^ Monadic computation which returns the result of the operation uploadFile petId = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either UploadFileResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> UploadFileResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ApiResponse) - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ "/uploadImage"))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_0) response_0) (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "/uploadImage")) GHC.Base.mempty) -- | Represents a response of the operation 'uploadFile'. -- -- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'UploadFileResponseError' is used. @@ -68,18 +69,18 @@ uploadFileWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI. uploadFileWithConfiguration config petId = GHC.Base.fmap (\response_2 -> GHC.Base.fmap (Data.Either.either UploadFileResponseError GHC.Base.id GHC.Base.. (\response body -> if | (\status_3 -> Network.HTTP.Types.Status.statusCode status_3 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> UploadFileResponse200 Data.Functor.<$> (Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String ApiResponse) - | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ "/uploadImage"))) GHC.Base.mempty) + | GHC.Base.otherwise -> Data.Either.Left "Missing default response type") response_2) response_2) (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "/uploadImage")) GHC.Base.mempty) -- | > POST /pet/{petId}/uploadImage -- --- The same as 'uploadFile' but returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'uploadFile' but returns the raw 'Data.ByteString.ByteString'. uploadFileRaw :: forall m . OpenAPI.Common.MonadHTTP m => GHC.Int.Int64 -- ^ petId: ID of pet to update - -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation -uploadFileRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ "/uploadImage"))) GHC.Base.mempty) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +uploadFileRaw petId = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "/uploadImage")) GHC.Base.mempty) -- | > POST /pet/{petId}/uploadImage -- --- The same as 'uploadFile' but accepts an explicit configuration and returns the raw 'Data.ByteString.Char8.ByteString'. +-- The same as 'uploadFile' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. uploadFileWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request -> GHC.Int.Int64 -- ^ petId: ID of pet to update - -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.ByteString) -- ^ Monadic computation which returns the result of the operation + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation uploadFileWithConfigurationRaw config - petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/pet/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.++ "/uploadImage"))) GHC.Base.mempty) + petId = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "POST") ("/pet/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel petId)) GHC.Base.<> "/uploadImage")) GHC.Base.mempty) diff --git a/example/generatedCode/src/OpenAPI/SecuritySchemes.hs b/example/generatedCode/src/OpenAPI/SecuritySchemes.hs old mode 100644 new mode 100755 index 5c525ea..c973138 --- a/example/generatedCode/src/OpenAPI/SecuritySchemes.hs +++ b/example/generatedCode/src/OpenAPI/SecuritySchemes.hs @@ -5,7 +5,7 @@ -- | Contains all supported security schemes defined in the specification module OpenAPI.SecuritySchemes where -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified GHC.Base import qualified GHC.Classes import qualified GHC.Show diff --git a/example/generatedCode/src/OpenAPI/TypeAlias.hs b/example/generatedCode/src/OpenAPI/TypeAlias.hs old mode 100644 new mode 100755 index d58600b..9a695d7 --- a/example/generatedCode/src/OpenAPI/TypeAlias.hs +++ b/example/generatedCode/src/OpenAPI/TypeAlias.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base diff --git a/example/generatedCode/src/OpenAPI/Types.hs b/example/generatedCode/src/OpenAPI/Types.hs old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs b/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs old mode 100644 new mode 100755 index 637a1bf..a95e275 --- a/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs +++ b/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -46,10 +46,10 @@ data ApiResponse = ApiResponse { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON ApiResponse - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("code" Data.Aeson.Types.ToJSON..=)) (apiResponseCode obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("message" Data.Aeson.Types.ToJSON..=)) (apiResponseMessage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("type" Data.Aeson.Types.ToJSON..=)) (apiResponseType obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("code" Data.Aeson.Types.ToJSON..=)) (apiResponseCode obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("message" Data.Aeson.Types.ToJSON..=)) (apiResponseMessage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("type" Data.Aeson.Types.ToJSON..=)) (apiResponseType obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("code" Data.Aeson.Types.ToJSON..=)) (apiResponseCode obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("message" Data.Aeson.Types.ToJSON..=)) (apiResponseMessage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("type" Data.Aeson.Types.ToJSON..=)) (apiResponseType obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("code" Data.Aeson.Types.ToJSON..=)) (apiResponseCode obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("message" Data.Aeson.Types.ToJSON..=)) (apiResponseMessage obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("type" Data.Aeson.Types.ToJSON..=)) (apiResponseType obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON ApiResponse - where parseJSON = Data.Aeson.Types.FromJSON.withObject "ApiResponse" (\obj -> ((GHC.Base.pure ApiResponse GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "code")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "message")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "type")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "ApiResponse" (\obj -> ((GHC.Base.pure ApiResponse GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "code")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "message")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "type"))} -- | Create a new 'ApiResponse' with all required fields. mkApiResponse :: ApiResponse mkApiResponse = ApiResponse{apiResponseCode = GHC.Maybe.Nothing, diff --git a/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs-boot b/example/generatedCode/src/OpenAPI/Types/ApiResponse.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/Category.hs b/example/generatedCode/src/OpenAPI/Types/Category.hs old mode 100644 new mode 100755 index 5203a5c..9d6b787 --- a/example/generatedCode/src/OpenAPI/Types/Category.hs +++ b/example/generatedCode/src/OpenAPI/Types/Category.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -44,10 +44,10 @@ data Category = Category { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON Category - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (categoryId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (categoryName obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (categoryId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (categoryName obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (categoryId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (categoryName obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (categoryId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (categoryName obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON Category - where parseJSON = Data.Aeson.Types.FromJSON.withObject "Category" (\obj -> (GHC.Base.pure Category GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "Category" (\obj -> (GHC.Base.pure Category GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name"))} -- | Create a new 'Category' with all required fields. mkCategory :: Category mkCategory = Category{categoryId = GHC.Maybe.Nothing, diff --git a/example/generatedCode/src/OpenAPI/Types/Category.hs-boot b/example/generatedCode/src/OpenAPI/Types/Category.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/Order.hs b/example/generatedCode/src/OpenAPI/Types/Order.hs old mode 100644 new mode 100755 index 13a8c69..25fcbe5 --- a/example/generatedCode/src/OpenAPI/Types/Order.hs +++ b/example/generatedCode/src/OpenAPI/Types/Order.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -52,10 +52,10 @@ data Order = Order { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON Order - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("complete" Data.Aeson.Types.ToJSON..=)) (orderComplete obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (orderId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("petId" Data.Aeson.Types.ToJSON..=)) (orderPetId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("quantity" Data.Aeson.Types.ToJSON..=)) (orderQuantity obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("shipDate" Data.Aeson.Types.ToJSON..=)) (orderShipDate obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (orderStatus obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("complete" Data.Aeson.Types.ToJSON..=)) (orderComplete obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (orderId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("petId" Data.Aeson.Types.ToJSON..=)) (orderPetId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("quantity" Data.Aeson.Types.ToJSON..=)) (orderQuantity obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("shipDate" Data.Aeson.Types.ToJSON..=)) (orderShipDate obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (orderStatus obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("complete" Data.Aeson.Types.ToJSON..=)) (orderComplete obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (orderId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("petId" Data.Aeson.Types.ToJSON..=)) (orderPetId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("quantity" Data.Aeson.Types.ToJSON..=)) (orderQuantity obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("shipDate" Data.Aeson.Types.ToJSON..=)) (orderShipDate obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (orderStatus obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("complete" Data.Aeson.Types.ToJSON..=)) (orderComplete obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (orderId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("petId" Data.Aeson.Types.ToJSON..=)) (orderPetId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("quantity" Data.Aeson.Types.ToJSON..=)) (orderQuantity obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("shipDate" Data.Aeson.Types.ToJSON..=)) (orderShipDate obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (orderStatus obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON Order - where parseJSON = Data.Aeson.Types.FromJSON.withObject "Order" (\obj -> (((((GHC.Base.pure Order GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "complete")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "petId")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "quantity")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "shipDate")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "Order" (\obj -> (((((GHC.Base.pure Order GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "complete")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "petId")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "quantity")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "shipDate")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status"))} -- | Create a new 'Order' with all required fields. mkOrder :: Order mkOrder = Order{orderComplete = GHC.Maybe.Nothing, @@ -75,13 +75,13 @@ data OrderStatus = | OrderStatusEnumDelivered -- ^ Represents the JSON value @"delivered"@ deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON OrderStatus - where toJSON (OrderStatusOther val) = val - toJSON (OrderStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val - toJSON (OrderStatusEnumPlaced) = "placed" - toJSON (OrderStatusEnumApproved) = "approved" - toJSON (OrderStatusEnumDelivered) = "delivered" + where {toJSON (OrderStatusOther val) = val; + toJSON (OrderStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (OrderStatusEnumPlaced) = "placed"; + toJSON (OrderStatusEnumApproved) = "approved"; + toJSON (OrderStatusEnumDelivered) = "delivered"} instance Data.Aeson.Types.FromJSON.FromJSON OrderStatus - where parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "placed" -> OrderStatusEnumPlaced - | val GHC.Classes.== "approved" -> OrderStatusEnumApproved - | val GHC.Classes.== "delivered" -> OrderStatusEnumDelivered - | GHC.Base.otherwise -> OrderStatusOther val) + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "placed" -> OrderStatusEnumPlaced + | val GHC.Classes.== "approved" -> OrderStatusEnumApproved + | val GHC.Classes.== "delivered" -> OrderStatusEnumDelivered + | GHC.Base.otherwise -> OrderStatusOther val)} diff --git a/example/generatedCode/src/OpenAPI/Types/Order.hs-boot b/example/generatedCode/src/OpenAPI/Types/Order.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/Pet.hs b/example/generatedCode/src/OpenAPI/Types/Pet.hs old mode 100644 new mode 100755 index 1dcef3a..2effc3c --- a/example/generatedCode/src/OpenAPI/Types/Pet.hs +++ b/example/generatedCode/src/OpenAPI/Types/Pet.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -54,10 +54,10 @@ data Pet = Pet { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON Pet - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("category" Data.Aeson.Types.ToJSON..=)) (petCategory obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (petId obj) : ["name" Data.Aeson.Types.ToJSON..= petName obj] : ["photoUrls" Data.Aeson.Types.ToJSON..= petPhotoUrls obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("status" Data.Aeson.Types.ToJSON..=)) (petStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("tags" Data.Aeson.Types.ToJSON..=)) (petTags obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON Pet - where parseJSON = Data.Aeson.Types.FromJSON.withObject "Pet" (\obj -> (((((GHC.Base.pure Pet GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "category")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "photoUrls")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "tags")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "Pet" (\obj -> (((((GHC.Base.pure Pet GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "category")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "photoUrls")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "status")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "tags"))} -- | Create a new 'Pet' with all required fields. mkPet :: Data.Text.Internal.Text -- ^ 'petName' -> [Data.Text.Internal.Text] -- ^ 'petPhotoUrls' @@ -79,13 +79,13 @@ data PetStatus = | PetStatusEnumSold -- ^ Represents the JSON value @"sold"@ deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON PetStatus - where toJSON (PetStatusOther val) = val - toJSON (PetStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val - toJSON (PetStatusEnumAvailable) = "available" - toJSON (PetStatusEnumPending) = "pending" - toJSON (PetStatusEnumSold) = "sold" + where {toJSON (PetStatusOther val) = val; + toJSON (PetStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (PetStatusEnumAvailable) = "available"; + toJSON (PetStatusEnumPending) = "pending"; + toJSON (PetStatusEnumSold) = "sold"} instance Data.Aeson.Types.FromJSON.FromJSON PetStatus - where parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> PetStatusEnumAvailable - | val GHC.Classes.== "pending" -> PetStatusEnumPending - | val GHC.Classes.== "sold" -> PetStatusEnumSold - | GHC.Base.otherwise -> PetStatusOther val) + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> PetStatusEnumAvailable + | val GHC.Classes.== "pending" -> PetStatusEnumPending + | val GHC.Classes.== "sold" -> PetStatusEnumSold + | GHC.Base.otherwise -> PetStatusOther val)} diff --git a/example/generatedCode/src/OpenAPI/Types/Pet.hs-boot b/example/generatedCode/src/OpenAPI/Types/Pet.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/Tag.hs b/example/generatedCode/src/OpenAPI/Types/Tag.hs old mode 100644 new mode 100755 index 7db984f..119d596 --- a/example/generatedCode/src/OpenAPI/Types/Tag.hs +++ b/example/generatedCode/src/OpenAPI/Types/Tag.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -44,10 +44,10 @@ data Tag = Tag { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON Tag - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (tagId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (tagName obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (tagId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (tagName obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (tagId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (tagName obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (tagId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("name" Data.Aeson.Types.ToJSON..=)) (tagName obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON Tag - where parseJSON = Data.Aeson.Types.FromJSON.withObject "Tag" (\obj -> (GHC.Base.pure Tag GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "Tag" (\obj -> (GHC.Base.pure Tag GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "name"))} -- | Create a new 'Tag' with all required fields. mkTag :: Tag mkTag = Tag{tagId = GHC.Maybe.Nothing, tagName = GHC.Maybe.Nothing} diff --git a/example/generatedCode/src/OpenAPI/Types/Tag.hs-boot b/example/generatedCode/src/OpenAPI/Types/Tag.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/src/OpenAPI/Types/User.hs b/example/generatedCode/src/OpenAPI/Types/User.hs old mode 100644 new mode 100755 index a1a1022..906cd13 --- a/example/generatedCode/src/OpenAPI/Types/User.hs +++ b/example/generatedCode/src/OpenAPI/Types/User.hs @@ -15,14 +15,14 @@ import qualified Data.Aeson as Data.Aeson.Types import qualified Data.Aeson as Data.Aeson.Types.FromJSON import qualified Data.Aeson as Data.Aeson.Types.ToJSON import qualified Data.Aeson as Data.Aeson.Types.Internal -import qualified Data.ByteString.Char8 -import qualified Data.ByteString.Char8 as Data.ByteString.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal import qualified Data.Foldable import qualified Data.Functor import qualified Data.Maybe import qualified Data.Scientific import qualified Data.Text -import qualified Data.Text.Internal +import qualified Data.Text as Data.Text.Internal import qualified Data.Time.Calendar as Data.Time.Calendar.Days import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime import qualified GHC.Base @@ -56,10 +56,10 @@ data User = User { } deriving (GHC.Show.Show , GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON User - where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("email" Data.Aeson.Types.ToJSON..=)) (userEmail obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("firstName" Data.Aeson.Types.ToJSON..=)) (userFirstName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (userId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("lastName" Data.Aeson.Types.ToJSON..=)) (userLastName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("password" Data.Aeson.Types.ToJSON..=)) (userPassword obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("phone" Data.Aeson.Types.ToJSON..=)) (userPhone obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("userStatus" Data.Aeson.Types.ToJSON..=)) (userUserStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("username" Data.Aeson.Types.ToJSON..=)) (userUsername obj) : GHC.Base.mempty)) - toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("email" Data.Aeson.Types.ToJSON..=)) (userEmail obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("firstName" Data.Aeson.Types.ToJSON..=)) (userFirstName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (userId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("lastName" Data.Aeson.Types.ToJSON..=)) (userLastName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("password" Data.Aeson.Types.ToJSON..=)) (userPassword obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("phone" Data.Aeson.Types.ToJSON..=)) (userPhone obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("userStatus" Data.Aeson.Types.ToJSON..=)) (userUserStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("username" Data.Aeson.Types.ToJSON..=)) (userUsername obj) : GHC.Base.mempty))) + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("email" Data.Aeson.Types.ToJSON..=)) (userEmail obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("firstName" Data.Aeson.Types.ToJSON..=)) (userFirstName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (userId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("lastName" Data.Aeson.Types.ToJSON..=)) (userLastName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("password" Data.Aeson.Types.ToJSON..=)) (userPassword obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("phone" Data.Aeson.Types.ToJSON..=)) (userPhone obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("userStatus" Data.Aeson.Types.ToJSON..=)) (userUserStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("username" Data.Aeson.Types.ToJSON..=)) (userUsername obj) : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("email" Data.Aeson.Types.ToJSON..=)) (userEmail obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("firstName" Data.Aeson.Types.ToJSON..=)) (userFirstName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("id" Data.Aeson.Types.ToJSON..=)) (userId obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("lastName" Data.Aeson.Types.ToJSON..=)) (userLastName obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("password" Data.Aeson.Types.ToJSON..=)) (userPassword obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("phone" Data.Aeson.Types.ToJSON..=)) (userPhone obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("userStatus" Data.Aeson.Types.ToJSON..=)) (userUserStatus obj) : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("username" Data.Aeson.Types.ToJSON..=)) (userUsername obj) : GHC.Base.mempty)))} instance Data.Aeson.Types.FromJSON.FromJSON User - where parseJSON = Data.Aeson.Types.FromJSON.withObject "User" (\obj -> (((((((GHC.Base.pure User GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "email")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "firstName")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "lastName")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "password")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "phone")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "userStatus")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "username")) + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "User" (\obj -> (((((((GHC.Base.pure User GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "email")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "firstName")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "id")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "lastName")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "password")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "phone")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "userStatus")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "username"))} -- | Create a new 'User' with all required fields. mkUser :: User mkUser = User{userEmail = GHC.Maybe.Nothing, diff --git a/example/generatedCode/src/OpenAPI/Types/User.hs-boot b/example/generatedCode/src/OpenAPI/Types/User.hs-boot old mode 100644 new mode 100755 diff --git a/example/generatedCode/stack.yaml b/example/generatedCode/stack.yaml old mode 100644 new mode 100755 index d76c250..3b675af --- a/example/generatedCode/stack.yaml +++ b/example/generatedCode/stack.yaml @@ -1,3 +1,3 @@ -resolver: lts-18.16 +resolver: lts-21.22 packages: - . diff --git a/example/petstore-running-example.cabal b/example/petstore-running-example.cabal deleted file mode 100644 index 50ddb3a..0000000 --- a/example/petstore-running-example.cabal +++ /dev/null @@ -1,46 +0,0 @@ -cabal-version: 1.12 - --- This file has been generated from package.yaml by hpack version 0.31.2. --- --- see: https://github.com/sol/hpack --- --- hash: 32b9cad0c80b60b3e8c6c0775e36a5133ea5d7b28613ca21ece6a9ad107d01d6 - -name: petstore-running-example -version: 0.1.0.0 -build-type: Simple - -library - exposed-modules: - Lib - other-modules: - Paths_petstore_running_example - hs-source-dirs: - src - build-depends: - aeson - , base >=4.7 && <5 - , bytestring - , http-client - , http-conduit - , openapi - default-language: Haskell2010 - -test-suite petstore-running-example-test - type: exitcode-stdio-1.0 - main-is: Spec.hs - other-modules: - Paths_petstore_running_example - hs-source-dirs: - test - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson - , base >=4.7 && <5 - , bytestring - , hspec - , http-client - , http-conduit - , openapi - , petstore-running-example - default-language: Haskell2010 diff --git a/example/src/Lib.hs b/example/src/Lib.hs index bd58067..22a3523 100644 --- a/example/src/Lib.hs +++ b/example/src/Lib.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} + module Lib where import Data.ByteString.Char8 @@ -23,6 +24,7 @@ runGetInventory :: MonadHTTP m => m (Response GetInventoryResponse) runGetInventory = runWithConfiguration defaultConfiguration getInventory runFindPetsByStatus :: MonadHTTP m => m (Response FindPetsByStatusResponse) -runFindPetsByStatus = runWithConfiguration - defaultConfiguration - (findPetsByStatus [FindPetsByStatusParametersStatusEnumPending]) +runFindPetsByStatus = + runWithConfiguration + defaultConfiguration + (findPetsByStatus [FindPetsByStatusParametersStatusEnumPending]) diff --git a/flake.nix b/flake.nix index 07d24ee..6cd8d8b 100644 --- a/flake.nix +++ b/flake.nix @@ -49,14 +49,16 @@ testSystem2 testSystem3 testGolden - testGoldenGenerate; + testGoldenGenerate + exampleGenerate + testExample; pre-commit = pre-commit-hooks.lib.${system}.run { src = ./.; hooks = { nixpkgs-fmt = { enable = true; excludes = [ - "example" + "example/generatedCode" "testing/golden-output" ".*/default.nix" ]; @@ -64,14 +66,14 @@ hlint = { enable = true; excludes = [ - "example" + "example/generatedCode" "testing/golden-output" ]; }; ormolu = { enable = true; excludes = [ - "example" + "example/generatedCode" "testing/golden-output" ]; }; @@ -79,7 +81,7 @@ cabal2nix = { enable = true; excludes = [ - "example" + "example/generatedCode" "testing/golden-output" ]; }; diff --git a/nix/tests.nix b/nix/tests.nix index 1b586e8..8ea2853 100644 --- a/nix/tests.nix +++ b/nix/tests.nix @@ -12,6 +12,7 @@ let }; }; goldenTestCode = generateCode { fileName = "z_complex_self_made_example.yml"; }; + exampleGeneratedCode = generateCode { fileName = "petstore.yaml"; }; codeForSpecsLevelOne = [ (generateCode { fileName = "google-payment.json"; }) (generateCode { fileName = "hetzner.json"; }) @@ -92,4 +93,15 @@ in cp -R ${goldenTestCode.path} $out ''; }; + exampleGenerate = pkgs.stdenv.mkDerivation { + name = "example-generate"; + buildCommand = '' + cp -R ${exampleGeneratedCode.path} $out + ''; + }; + testExample = + let + openapi = disableOptimization (disableLibraryProfiling (pkgs.haskellPackages.callCabal2nix "example-generated-compiled" ../example/generatedCode { })); + in + dontCheck (disableOptimization (disableLibraryProfiling (pkgs.haskellPackages.callCabal2nix "example-compiled" ../example { openapi = openapi; }))); } diff --git a/testing/level3/petstore-running-example/src/Lib.hs b/testing/level3/petstore-running-example/src/Lib.hs index f29b1ef..16d0cfe 100644 --- a/testing/level3/petstore-running-example/src/Lib.hs +++ b/testing/level3/petstore-running-example/src/Lib.hs @@ -42,4 +42,4 @@ runEchoPath :: MonadHTTP m => EchoPathParametersPath -> m (Response EchoPathResp runEchoPath = echoPathWithConfiguration defaultConfiguration runSendAndReceiveNullableAndOptional :: MonadHTTP m => Text -> NullableAndOptionalTest -> m (Response SendAndReceiveNullableAndOptionalResponse) -runSendAndReceiveNullableAndOptional mode body = sendAndReceiveNullableAndOptionalWithConfiguration defaultConfiguration mode body +runSendAndReceiveNullableAndOptional = sendAndReceiveNullableAndOptionalWithConfiguration defaultConfiguration diff --git a/testing/level3/petstore-running-example/test/Spec.hs b/testing/level3/petstore-running-example/test/Spec.hs index c77d322..84c2a2e 100644 --- a/testing/level3/petstore-running-example/test/Spec.hs +++ b/testing/level3/petstore-running-example/test/Spec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} import Control.Exception @@ -55,10 +56,12 @@ main = do response <- runEchoUserAgent getResponseBody response - `shouldSatisfy` ( \body -> case body of + `shouldSatisfy` ( \case EchoUserAgentResponse200 text -> - "XYZ" `T.isInfixOf` text - && "openapi3-code-generator" `T.isInfixOf` text + "XYZ" + `T.isInfixOf` text + && "openapi3-code-generator" + `T.isInfixOf` text _ -> False ) diff --git a/update_golden.sh b/update_golden_and_example.sh similarity index 52% rename from update_golden.sh rename to update_golden_and_example.sh index 7c93c6a..9984fdd 100755 --- a/update_golden.sh +++ b/update_golden_and_example.sh @@ -5,3 +5,10 @@ rm -rf testing/golden-output mkdir -p testing/golden-output cp -R result/* testing/golden-output chmod -R 764 testing/golden-output + + +nix build .\#checks.x86_64-linux.exampleGenerate +rm -rf example/generatedCode +mkdir -p example/generatedCode +cp -R result/* example/generatedCode +chmod -R 764 example/generatedCode