From 1656c9b569126cfa0d5b97eb7c2e37b38dffdf93 Mon Sep 17 00:00:00 2001 From: Robin Palotai Date: Sun, 1 Feb 2026 20:25:18 +0100 Subject: [PATCH 1/4] Port change from abandoned path items PR #71 Original PR: https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator/pull/71 Taken over as-is, with minor cleanup and following some renames that happened in the meantime. Golden changes seems benign, but order changes due to Map use. Will clean those up and regen goldens, plus add some test case. --- .../OpenAPI/Generate/Internal/Operation.hs | 35 ++++++++++++++----- .../src/OpenAPI/Generate/Operation.hs | 8 +++-- .../src/OpenAPI/Generate/Types.hs | 2 +- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs b/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs index 319d7a9..003cd0a 100644 --- a/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs +++ b/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs @@ -77,8 +77,8 @@ data ParameterCardinality | MultipleParameters ParameterTypeDefinition -- | Generates the parameter type for an operation. See 'ParameterCardinality' for further information. -generateParameterTypeFromOperation :: Text -> OAT.OperationObject -> OAM.Generator ParameterCardinality -generateParameterTypeFromOperation operationName = getParametersFromOperationConcrete >=> generateParameterType operationName +generateParameterTypeFromOperation :: [OAT.Referencable OAT.ParameterObject] -> Text -> OAT.OperationObject -> OAM.Generator ParameterCardinality +generateParameterTypeFromOperation pathParams operationName = getParametersFromOperationConcrete pathParams >=> generateParameterType operationName generateParameterType :: Text -> [(OAT.ParameterObject, [Text])] -> OAM.Generator ParameterCardinality generateParameterType operationName parameters = OAM.nested "parameters" $ do @@ -152,12 +152,20 @@ getParameterLocationPrefix = ) . OAT.parameterObjectIn --- | Extracts all parameters of an operation --- --- Concrete objects are always added. References try to get resolved to a concrete object. --- If this fails, the parameter is skipped and a warning gets produced. -getParametersFromOperationConcrete :: OAT.OperationObject -> OAM.Generator [(OAT.ParameterObject, [Text])] -getParametersFromOperationConcrete = +-- | Override parameters defined at path level with parameters which are defined at operation level +overrideParameters :: [(OAT.ParameterObject, [Text])] -> [(OAT.ParameterObject, [Text])] -> [(OAT.ParameterObject, [Text])] +overrideParameters pathParams operationParams = + -- According to OpenAPI specification, the unique parameter is identified by a combination of name and location. + -- So, we are using (name, in') as key in these maps. + let mkParamsMap parameters = Map.fromList [((OAT.parameterObjectName (fst p), OAT.parameterObjectIn (fst p)), p) | p <- parameters] + pathParamsMap = mkParamsMap pathParams + operationParamsMap = mkParamsMap operationParams + -- prefer operation parameters + allParamsMap = Map.union operationParamsMap pathParamsMap + in Map.elems allParamsMap + +getConcreteParameters :: [OAT.Referencable OAT.ParameterObject] -> OAM.Generator [(OAT.ParameterObject, [Text])] +getConcreteParameters = OAM.nested "parameters" . fmap Maybe.catMaybes . mapM @@ -172,7 +180,16 @@ getParametersFromOperationConcrete = pure $ (,["components", "parameters", name]) <$> p ) . zip ([0 ..] :: [Int]) - . OAT.operationObjectParameters + +-- | Extracts all parameters of an operation +-- +-- Concrete objects are always added. References try to get resolved to a concrete object. +-- If this fails, the parameter is skipped and a warning gets produced. +getParametersFromOperationConcrete :: [OAT.Referencable OAT.ParameterObject] -> OAT.OperationObject -> OAM.Generator [(OAT.ParameterObject, [Text])] +getParametersFromOperationConcrete pathParameters operation = do + operationParameters <- getConcreteParameters $ OAT.operationObjectParameters operation + concretePathParameters <- getConcreteParameters pathParameters + pure $ overrideParameters concretePathParameters operationParameters getSchemaFromParameterObjectSchema :: OAT.ParameterObjectSchema -> OAM.Generator (Maybe OAS.Schema) getSchemaFromParameterObjectSchema (OAT.SimpleParameterObjectSchema OAT.SimpleParameterSchema {..}) = pure $ Just simpleParameterSchemaSchema diff --git a/openapi3-code-generator/src/OpenAPI/Generate/Operation.hs b/openapi3-code-generator/src/OpenAPI/Generate/Operation.hs index ef319b7..73ed6de 100644 --- a/openapi3-code-generator/src/OpenAPI/Generate/Operation.hs +++ b/openapi3-code-generator/src/OpenAPI/Generate/Operation.hs @@ -45,7 +45,7 @@ defineOperationsForPath mainModuleName requestPath pathItemObject = OAM.nested r operationsToGenerate <- OAM.getSetting OAO.settingOperationsToGenerate fmap (BF.bimap sequence Set.unions) . mapAndUnzipM - (uncurry (defineModuleForOperation mainModuleName requestPath)) + (uncurry (defineModuleForOperation mainModuleName requestPath (OAT.pathItemObjectParameters pathItemObject))) $ filterEmptyAndOmittedOperations operationsToGenerate [ ("GET", OAT.pathItemObjectGet pathItemObject), @@ -76,13 +76,15 @@ defineModuleForOperation :: -- | The path to the request (This is the key from the map of Operations) -- It may contain placeholder variables in the form of /my/{var}/path/ Text -> + -- | Path parameter definition + [OAT.Referencable OAT.ParameterObject] -> -- | HTTP Method (GET,POST,etc) Text -> -- | The Operation Object OAT.OperationObject -> -- | commented function definition and implementation OAM.Generator (Q Dep.ModuleDefinition, Dep.Models) -defineModuleForOperation mainModuleName requestPath method operation = OAM.nested method $ do +defineModuleForOperation mainModuleName requestPath pathParams method operation = OAM.nested method $ do operationIdName <- getOperationName requestPath method operation convertToCamelCase <- OAM.getSetting OAO.settingConvertToCamelCase let operationIdAsText = T.pack $ show operationIdName @@ -92,7 +94,7 @@ defineModuleForOperation mainModuleName requestPath method operation = OAM.neste (bodySchema, bodyPath) <- getBodySchemaFromOperation operation (responseTypeName, responseTransformerExp, responseBodyDefinitions, responseBodyDependencies) <- OAR.getResponseDefinitions operation appendToOperationName (bodyType, (bodyDefinition, bodyDependencies)) <- OAM.resetPath bodyPath $ getBodyType bodySchema appendToOperationName - parameterCardinality <- generateParameterTypeFromOperation operationIdAsText operation + parameterCardinality <- generateParameterTypeFromOperation pathParams operationIdAsText operation paramDescriptions <- (<> ["The request body to send" | not $ null bodyType]) <$> ( case parameterCardinality of diff --git a/openapi3-code-generator/src/OpenAPI/Generate/Types.hs b/openapi3-code-generator/src/OpenAPI/Generate/Types.hs index c84b56e..f69227a 100644 --- a/openapi3-code-generator/src/OpenAPI/Generate/Types.hs +++ b/openapi3-code-generator/src/OpenAPI/Generate/Types.hs @@ -343,7 +343,7 @@ data ParameterObjectLocation | HeaderParameterObjectLocation | PathParameterObjectLocation | CookieParameterObjectLocation - deriving (Show, Eq, Generic) + deriving (Show, Eq, Ord, Generic) instance FromJSON ParameterObjectLocation where parseJSON = withText "ParameterObjectLocation" $ \case From 4bdb1a3b97fcf5c6b6ada1b1850a71e3ae043938 Mon Sep 17 00:00:00 2001 From: Robin Palotai Date: Sun, 1 Feb 2026 23:16:00 +0100 Subject: [PATCH 2/4] Keep parameter order, regenerate goldens and tests (no change). --- .../src/OpenAPI/Generate/Internal/Operation.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs b/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs index 003cd0a..2693a66 100644 --- a/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs +++ b/openapi3-code-generator/src/OpenAPI/Generate/Internal/Operation.hs @@ -156,13 +156,17 @@ getParameterLocationPrefix = overrideParameters :: [(OAT.ParameterObject, [Text])] -> [(OAT.ParameterObject, [Text])] -> [(OAT.ParameterObject, [Text])] overrideParameters pathParams operationParams = -- According to OpenAPI specification, the unique parameter is identified by a combination of name and location. - -- So, we are using (name, in') as key in these maps. - let mkParamsMap parameters = Map.fromList [((OAT.parameterObjectName (fst p), OAT.parameterObjectIn (fst p)), p) | p <- parameters] - pathParamsMap = mkParamsMap pathParams - operationParamsMap = mkParamsMap operationParams - -- prefer operation parameters - allParamsMap = Map.union operationParamsMap pathParamsMap - in Map.elems allParamsMap + -- So, we are using (name, in') as key. + -- We emit all the path parameters that were not overridden, and then all the + -- operation parameters. (Note, we use lists to keep the original parameter + -- order for generating code). + let getKey :: (OAT.ParameterObject, [Text]) -> (Text, OAT.ParameterObjectLocation) + getKey p = + let po = fst p + in (OAT.parameterObjectName po, OAT.parameterObjectIn po) + opKeys = Set.fromList (map getKey operationParams) + pathParamsWithoutOverride = filter (\p -> Set.notMember (getKey p) opKeys) pathParams + in pathParamsWithoutOverride <> operationParams getConcreteParameters :: [OAT.Referencable OAT.ParameterObject] -> OAM.Generator [(OAT.ParameterObject, [Text])] getConcreteParameters = From 0642bdefe6746cac1f29564614aa5f80ec92b00a Mon Sep 17 00:00:00 2001 From: Robin Palotai Date: Sun, 1 Feb 2026 23:23:46 +0100 Subject: [PATCH 3/4] Add a param to golden schema that will be overridden. So no change in generated. --- specifications/z_complex_self_made_example.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/specifications/z_complex_self_made_example.yml b/specifications/z_complex_self_made_example.yml index dfeeb93..8b2a3b0 100644 --- a/specifications/z_complex_self_made_example.yml +++ b/specifications/z_complex_self_made_example.yml @@ -106,6 +106,13 @@ paths: schema: $ref: "#/components/schemas/Dog" /pet/multiparam/{status}: + parameters: + - name: status + in: path + description: Status in path from path params, will be overridden below. + required: true + schema: + type: string get: description: Operation with multiple parameters operationId: multiParam From 18d8e57510cb7884c17f4e17b0ef689991ffd0ec Mon Sep 17 00:00:00 2001 From: Robin Palotai Date: Sun, 1 Feb 2026 23:29:46 +0100 Subject: [PATCH 4/4] Add new path to golden that exercises taking path param from path parameters. --- .../z_complex_self_made_example.yml | 44 +++++ testing/golden-output/openapi.cabal | 1 + testing/golden-output/src/OpenAPI.hs | 2 + .../OpenAPI/Operations/MultiParamPathParam.hs | 184 ++++++++++++++++++ 4 files changed, 231 insertions(+) create mode 100755 testing/golden-output/src/OpenAPI/Operations/MultiParamPathParam.hs diff --git a/specifications/z_complex_self_made_example.yml b/specifications/z_complex_self_made_example.yml index 8b2a3b0..8d497f5 100644 --- a/specifications/z_complex_self_made_example.yml +++ b/specifications/z_complex_self_made_example.yml @@ -105,6 +105,50 @@ paths: application/json: schema: $ref: "#/components/schemas/Dog" + /pet/multiparam2/{status}: + parameters: + - name: status + in: path + description: Status in path (from path params) + required: true + schema: + type: integer + enum: + - 1 + - 3 + - 5 + get: + description: Operation with multiple parameters (some from path params) + operationId: multiParamPathParam + parameters: + - name: status + in: query + description: Status in query + required: true + schema: + type: string + enum: + - available + - pending + - sold + - name: filter + in: query + description: Filter the entries? + schema: + type: boolean + - name: referenceParameter + in: query + required: true + schema: + $ref: '#/components/schemas/Cat' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: "#/components/schemas/Dog" + /pet/multiparam/{status}: parameters: - name: status diff --git a/testing/golden-output/openapi.cabal b/testing/golden-output/openapi.cabal index 8aa500c..d3fe3cc 100755 --- a/testing/golden-output/openapi.cabal +++ b/testing/golden-output/openapi.cabal @@ -8,6 +8,7 @@ library exposed-modules: OpenAPI OpenAPI.Operations.MultiParam + OpenAPI.Operations.MultiParamPathParam OpenAPI.Operations.MultiParamWithFixedEnum OpenAPI.Operations.NoParam OpenAPI.Operations.SingleParam diff --git a/testing/golden-output/src/OpenAPI.hs b/testing/golden-output/src/OpenAPI.hs index 5b10b94..b6d8314 100755 --- a/testing/golden-output/src/OpenAPI.hs +++ b/testing/golden-output/src/OpenAPI.hs @@ -3,6 +3,7 @@ -- | The main module which exports all functionality. module OpenAPI ( module OpenAPI.Operations.MultiParam, + module OpenAPI.Operations.MultiParamPathParam, module OpenAPI.Operations.MultiParamWithFixedEnum, module OpenAPI.Operations.NoParam, module OpenAPI.Operations.SingleParam, @@ -28,6 +29,7 @@ module OpenAPI ( ) where import OpenAPI.Operations.MultiParam +import OpenAPI.Operations.MultiParamPathParam import OpenAPI.Operations.MultiParamWithFixedEnum import OpenAPI.Operations.NoParam import OpenAPI.Operations.SingleParam diff --git a/testing/golden-output/src/OpenAPI/Operations/MultiParamPathParam.hs b/testing/golden-output/src/OpenAPI/Operations/MultiParamPathParam.hs new file mode 100755 index 0000000..7f8c358 --- /dev/null +++ b/testing/golden-output/src/OpenAPI/Operations/MultiParamPathParam.hs @@ -0,0 +1,184 @@ +-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator. + +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ExplicitForAll #-} +{-# LANGUAGE MultiWayIf #-} + +-- | Contains the different functions to run the operation multiParamPathParam +module OpenAPI.Operations.MultiParamPathParam where + +import qualified Prelude as GHC.Integer.Type +import qualified Prelude as GHC.Maybe +import qualified Prelude as GHC.Internal.Maybe +import qualified Control.Monad.Fail +import qualified Control.Monad.Fail as GHC.Internal.Control.Monad.Fail +import qualified Control.Monad.Trans.Reader +import qualified Data.Aeson +import qualified Data.Aeson as Data.Aeson.Decoding +import qualified Data.Aeson as Data.Aeson.Encoding.Internal +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.Internal +import qualified Data.Aeson as Data.Aeson.Types.ToJSON +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.Either as GHC.Internal.Data.Either +import qualified Data.Foldable +import qualified Data.Foldable as GHC.Internal.Data.Foldable +import qualified Data.Functor +import qualified Data.Functor as GHC.Internal.Data.Functor +import qualified Data.Maybe +import qualified Data.Maybe as GHC.Internal.Data.Maybe +import qualified Data.Scientific +import qualified Data.Text +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 +import qualified GHC.Base +import qualified GHC.Base as GHC.Internal.Base +import qualified GHC.Classes +import qualified GHC.Int +import qualified GHC.Int as GHC.Internal.Int +import qualified GHC.Show +import qualified GHC.Show as GHC.Internal.Show +import qualified GHC.Types +import qualified Network.HTTP.Client +import qualified Network.HTTP.Client as Network.HTTP.Client.Request +import qualified Network.HTTP.Client as Network.HTTP.Client.Types +import qualified Network.HTTP.Simple +import qualified Network.HTTP.Types +import qualified Network.HTTP.Types as Network.HTTP.Types.Status +import qualified Network.HTTP.Types as Network.HTTP.Types.URI +import qualified OpenAPI.Common +import OpenAPI.Types + +-- | > GET /pet/multiparam2/{status} +-- +-- Operation with multiple parameters (some from path params) +multiParamPathParam :: forall m . OpenAPI.Common.MonadHTTP m => MultiParamPathParamParameters -- ^ Contains all available parameters of this operation (query and path parameters) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response MultiParamPathParamResponse) -- ^ Monadic computation which returns the result of the operation +multiParamPathParam parameters = GHC.Base.fmap (\response_0 -> GHC.Base.fmap (Data.Either.either MultiParamPathParamResponseError 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) -> MultiParamPathParamResponse200 Data.Functor.<$> (Data.Aeson.Decoding.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String + Dog) + | 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/multiparam2/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel (multiParamPathParamParametersPathStatus parameters))) GHC.Base.<> "")) [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryStatus parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "filter") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> multiParamPathParamParametersQueryFilter parameters) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "referenceParameter") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryReferenceParameter parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) +-- | Defines the object schema located at @paths.\/pet\/multiparam2\/{status}.GET.parameters@ in the specification. +-- +-- +data MultiParamPathParamParameters = MultiParamPathParamParameters { + -- | pathStatus: Represents the parameter named \'status\' + -- + -- Status in path (from path params) + multiParamPathParamParametersPathStatus :: MultiParamPathParamParametersPathStatus + -- | queryFilter: Represents the parameter named \'filter\' + -- + -- Filter the entries? + , multiParamPathParamParametersQueryFilter :: (GHC.Maybe.Maybe GHC.Types.Bool) + -- | queryReferenceParameter + , multiParamPathParamParametersQueryReferenceParameter :: Cat + -- | queryStatus: Represents the parameter named \'status\' + -- + -- Status in query + , multiParamPathParamParametersQueryStatus :: MultiParamPathParamParametersQueryStatus + } deriving (GHC.Show.Show + , GHC.Classes.Eq) +instance Data.Aeson.Types.ToJSON.ToJSON MultiParamPathParamParameters + where {toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (["pathStatus" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersPathStatus obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryFilter" Data.Aeson.Types.ToJSON..=)) (multiParamPathParamParametersQueryFilter obj) : ["queryReferenceParameter" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersQueryReferenceParameter obj] : ["queryStatus" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersQueryStatus obj] : GHC.Base.mempty)); + toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (["pathStatus" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersPathStatus obj] : Data.Maybe.maybe GHC.Base.mempty (GHC.Base.pure GHC.Base.. ("queryFilter" Data.Aeson.Types.ToJSON..=)) (multiParamPathParamParametersQueryFilter obj) : ["queryReferenceParameter" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersQueryReferenceParameter obj] : ["queryStatus" Data.Aeson.Types.ToJSON..= multiParamPathParamParametersQueryStatus obj] : GHC.Base.mempty)))} +instance Data.Aeson.Types.FromJSON.FromJSON MultiParamPathParamParameters + where {parseJSON = Data.Aeson.Types.FromJSON.withObject "MultiParamPathParamParameters" (\obj -> (((GHC.Base.pure MultiParamPathParamParameters GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "pathStatus")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:! "queryFilter")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryReferenceParameter")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "queryStatus"))} +-- | Create a new 'MultiParamPathParamParameters' with all required fields. +mkMultiParamPathParamParameters :: MultiParamPathParamParametersPathStatus -- ^ 'multiParamPathParamParametersPathStatus' + -> Cat -- ^ 'multiParamPathParamParametersQueryReferenceParameter' + -> MultiParamPathParamParametersQueryStatus -- ^ 'multiParamPathParamParametersQueryStatus' + -> MultiParamPathParamParameters +mkMultiParamPathParamParameters multiParamPathParamParametersPathStatus multiParamPathParamParametersQueryReferenceParameter multiParamPathParamParametersQueryStatus = MultiParamPathParamParameters{multiParamPathParamParametersPathStatus = multiParamPathParamParametersPathStatus, + multiParamPathParamParametersQueryFilter = GHC.Maybe.Nothing, + multiParamPathParamParametersQueryReferenceParameter = multiParamPathParamParametersQueryReferenceParameter, + multiParamPathParamParametersQueryStatus = multiParamPathParamParametersQueryStatus} +-- | Defines the enum schema located at @paths.\/pet\/multiparam2\/{status}.GET.parameters.properties.pathStatus@ in the specification. +-- +-- Represents the parameter named \'status\' +-- +-- Status in path (from path params) +data MultiParamPathParamParametersPathStatus = + MultiParamPathParamParametersPathStatusOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification. + | MultiParamPathParamParametersPathStatusTyped GHC.Types.Int -- ^ This constructor can be used to send values to the server which are not present in the specification yet. + | MultiParamPathParamParametersPathStatusEnum1 -- ^ Represents the JSON value @1@ + | MultiParamPathParamParametersPathStatusEnum3 -- ^ Represents the JSON value @3@ + | MultiParamPathParamParametersPathStatusEnum5 -- ^ Represents the JSON value @5@ + deriving (GHC.Show.Show, GHC.Classes.Eq) +instance Data.Aeson.Types.ToJSON.ToJSON MultiParamPathParamParametersPathStatus + where {toJSON (MultiParamPathParamParametersPathStatusOther val) = val; + toJSON (MultiParamPathParamParametersPathStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (MultiParamPathParamParametersPathStatusEnum1) = Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 1 0); + toJSON (MultiParamPathParamParametersPathStatusEnum3) = Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 3 0); + toJSON (MultiParamPathParamParametersPathStatusEnum5) = Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 5 0)} +instance Data.Aeson.Types.FromJSON.FromJSON MultiParamPathParamParametersPathStatus + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 1 0) -> MultiParamPathParamParametersPathStatusEnum1 + | val GHC.Classes.== Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 3 0) -> MultiParamPathParamParametersPathStatusEnum3 + | val GHC.Classes.== Data.Aeson.Types.Internal.Number (Data.Scientific.scientific 5 0) -> MultiParamPathParamParametersPathStatusEnum5 + | GHC.Base.otherwise -> MultiParamPathParamParametersPathStatusOther val)} +-- | Defines the enum schema located at @paths.\/pet\/multiparam2\/{status}.GET.parameters.properties.queryStatus@ in the specification. +-- +-- Represents the parameter named \'status\' +-- +-- Status in query +data MultiParamPathParamParametersQueryStatus = + MultiParamPathParamParametersQueryStatusOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification. + | MultiParamPathParamParametersQueryStatusTyped Data.Text.Internal.Text -- ^ This constructor can be used to send values to the server which are not present in the specification yet. + | MultiParamPathParamParametersQueryStatusEnumAvailable -- ^ Represents the JSON value @"available"@ + | MultiParamPathParamParametersQueryStatusEnumPending -- ^ Represents the JSON value @"pending"@ + | MultiParamPathParamParametersQueryStatusEnumSold -- ^ Represents the JSON value @"sold"@ + deriving (GHC.Show.Show, GHC.Classes.Eq) +instance Data.Aeson.Types.ToJSON.ToJSON MultiParamPathParamParametersQueryStatus + where {toJSON (MultiParamPathParamParametersQueryStatusOther val) = val; + toJSON (MultiParamPathParamParametersQueryStatusTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (MultiParamPathParamParametersQueryStatusEnumAvailable) = "available"; + toJSON (MultiParamPathParamParametersQueryStatusEnumPending) = "pending"; + toJSON (MultiParamPathParamParametersQueryStatusEnumSold) = "sold"} +instance Data.Aeson.Types.FromJSON.FromJSON MultiParamPathParamParametersQueryStatus + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "available" -> MultiParamPathParamParametersQueryStatusEnumAvailable + | val GHC.Classes.== "pending" -> MultiParamPathParamParametersQueryStatusEnumPending + | val GHC.Classes.== "sold" -> MultiParamPathParamParametersQueryStatusEnumSold + | GHC.Base.otherwise -> MultiParamPathParamParametersQueryStatusOther val)} +-- | Represents a response of the operation 'multiParamPathParam'. +-- +-- 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), 'MultiParamPathParamResponseError' is used. +data MultiParamPathParamResponse = + MultiParamPathParamResponseError GHC.Base.String -- ^ Means either no matching case available or a parse error + | MultiParamPathParamResponse200 Dog -- ^ successful operation + deriving (GHC.Show.Show, GHC.Classes.Eq) +-- | > GET /pet/multiparam2/{status} +-- +-- The same as 'multiParamPathParam' but accepts an explicit configuration. +multiParamPathParamWithConfiguration :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request + -> MultiParamPathParamParameters -- ^ Contains all available parameters of this operation (query and path parameters) + -> m (Network.HTTP.Client.Types.Response MultiParamPathParamResponse) -- ^ Monadic computation which returns the result of the operation +multiParamPathParamWithConfiguration config + parameters = GHC.Base.fmap (\response_2 -> GHC.Base.fmap (Data.Either.either MultiParamPathParamResponseError 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) -> MultiParamPathParamResponse200 Data.Functor.<$> (Data.Aeson.Decoding.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String + Dog) + | 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") ("/pet/multiparam2/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel (multiParamPathParamParametersPathStatus parameters))) GHC.Base.<> "")) [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryStatus parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "filter") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> multiParamPathParamParametersQueryFilter parameters) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "referenceParameter") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryReferenceParameter parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) +-- | > GET /pet/multiparam2/{status} +-- +-- The same as 'multiParamPathParam' but returns the raw 'Data.ByteString.ByteString'. +multiParamPathParamRaw :: forall m . OpenAPI.Common.MonadHTTP m => MultiParamPathParamParameters -- ^ Contains all available parameters of this operation (query and path parameters) + -> OpenAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +multiParamPathParamRaw parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/multiparam2/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel (multiParamPathParamParametersPathStatus parameters))) GHC.Base.<> "")) [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryStatus parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "filter") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> multiParamPathParamParametersQueryFilter parameters) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "referenceParameter") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryReferenceParameter parameters)) (Data.Text.Internal.pack "form") GHC.Types.False]) +-- | > GET /pet/multiparam2/{status} +-- +-- The same as 'multiParamPathParam' but accepts an explicit configuration and returns the raw 'Data.ByteString.ByteString'. +multiParamPathParamWithConfigurationRaw :: forall m . OpenAPI.Common.MonadHTTP m => OpenAPI.Common.Configuration -- ^ The configuration to use in the request + -> MultiParamPathParamParameters -- ^ Contains all available parameters of this operation (query and path parameters) + -> m (Network.HTTP.Client.Types.Response Data.ByteString.Internal.Type.ByteString) -- ^ Monadic computation which returns the result of the operation +multiParamPathParamWithConfigurationRaw config + parameters = GHC.Base.id (OpenAPI.Common.doCallWithConfiguration config (Data.Text.toUpper GHC.Base.$ Data.Text.Internal.pack "GET") ("/pet/multiparam2/" GHC.Base.<> (OpenAPI.Common.byteToText (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (OpenAPI.Common.textToByte GHC.Base.$ OpenAPI.Common.stringifyModel (multiParamPathParamParametersPathStatus parameters))) GHC.Base.<> "")) [OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "status") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryStatus parameters)) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "filter") (Data.Aeson.Types.ToJSON.toJSON Data.Functor.<$> multiParamPathParamParametersQueryFilter parameters) (Data.Text.Internal.pack "form") GHC.Types.False, + OpenAPI.Common.QueryParameter (Data.Text.Internal.pack "referenceParameter") (GHC.Maybe.Just GHC.Base.$ Data.Aeson.Types.ToJSON.toJSON (multiParamPathParamParametersQueryReferenceParameter parameters)) (Data.Text.Internal.pack "form") GHC.Types.False])