forked from loafle/openapi-generator-original
Regenerate samples (#367)
This commit is contained in:
committed by
William Cheng
parent
bbd2afdd0a
commit
059a3efe46
@@ -0,0 +1,31 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore
|
||||
-}
|
||||
|
||||
module OpenAPIPetstore
|
||||
( module OpenAPIPetstore.API
|
||||
, module OpenAPIPetstore.Client
|
||||
, module OpenAPIPetstore.Core
|
||||
, module OpenAPIPetstore.Logging
|
||||
, module OpenAPIPetstore.MimeTypes
|
||||
, module OpenAPIPetstore.Model
|
||||
, module OpenAPIPetstore.ModelLens
|
||||
) where
|
||||
|
||||
import OpenAPIPetstore.API
|
||||
import OpenAPIPetstore.Client
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.Logging
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model
|
||||
import OpenAPIPetstore.ModelLens
|
||||
@@ -0,0 +1,29 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API
|
||||
-}
|
||||
|
||||
module OpenAPIPetstore.API
|
||||
( module OpenAPIPetstore.API.AnotherFake
|
||||
, module OpenAPIPetstore.API.Fake
|
||||
, module OpenAPIPetstore.API.FakeClassnameTags123
|
||||
, module OpenAPIPetstore.API.Pet
|
||||
, module OpenAPIPetstore.API.Store
|
||||
, module OpenAPIPetstore.API.User
|
||||
) where
|
||||
|
||||
import OpenAPIPetstore.API.AnotherFake
|
||||
import OpenAPIPetstore.API.Fake
|
||||
import OpenAPIPetstore.API.FakeClassnameTags123
|
||||
import OpenAPIPetstore.API.Pet
|
||||
import OpenAPIPetstore.API.Store
|
||||
import OpenAPIPetstore.API.User
|
||||
@@ -0,0 +1,86 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.AnotherFake
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.AnotherFake where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** AnotherFake
|
||||
|
||||
-- *** testSpecialTags
|
||||
|
||||
-- | @PATCH \/another-fake\/dummy@
|
||||
--
|
||||
-- To test special tags
|
||||
--
|
||||
-- To test special tags
|
||||
--
|
||||
testSpecialTags
|
||||
:: (Consumes TestSpecialTags MimeJSON, MimeRender MimeJSON Client)
|
||||
=> Client -- ^ "client" - client model
|
||||
-> OpenAPIPetstoreRequest TestSpecialTags MimeJSON Client MimeJSON
|
||||
testSpecialTags client =
|
||||
_mkRequest "PATCH" ["/another-fake/dummy"]
|
||||
`setBodyParam` client
|
||||
|
||||
data TestSpecialTags
|
||||
|
||||
-- | /Body Param/ "Client" - client model
|
||||
instance HasBodyParam TestSpecialTags Client
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes TestSpecialTags MimeJSON
|
||||
|
||||
-- | @application/json@
|
||||
instance Produces TestSpecialTags MimeJSON
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.Fake
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.Fake where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** Fake
|
||||
|
||||
-- *** fakeOuterBooleanSerialize
|
||||
|
||||
-- | @POST \/fake\/outer\/boolean@
|
||||
--
|
||||
-- Test serialization of outer boolean types
|
||||
--
|
||||
fakeOuterBooleanSerialize
|
||||
:: (Consumes FakeOuterBooleanSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterBooleanSerialize contentType Bool accept
|
||||
fakeOuterBooleanSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/boolean"]
|
||||
|
||||
data FakeOuterBooleanSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input boolean as post body
|
||||
instance HasBodyParam FakeOuterBooleanSerialize BodyBool
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype
|
||||
|
||||
|
||||
-- *** fakeOuterCompositeSerialize
|
||||
|
||||
-- | @POST \/fake\/outer\/composite@
|
||||
--
|
||||
-- Test serialization of object with outer number type
|
||||
--
|
||||
fakeOuterCompositeSerialize
|
||||
:: (Consumes FakeOuterCompositeSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite accept
|
||||
fakeOuterCompositeSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/composite"]
|
||||
|
||||
data FakeOuterCompositeSerialize
|
||||
|
||||
-- | /Body Param/ "OuterComposite" - Input composite as post body
|
||||
instance HasBodyParam FakeOuterCompositeSerialize OuterComposite
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype
|
||||
|
||||
|
||||
-- *** fakeOuterNumberSerialize
|
||||
|
||||
-- | @POST \/fake\/outer\/number@
|
||||
--
|
||||
-- Test serialization of outer number types
|
||||
--
|
||||
fakeOuterNumberSerialize
|
||||
:: (Consumes FakeOuterNumberSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterNumberSerialize contentType Double accept
|
||||
fakeOuterNumberSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/number"]
|
||||
|
||||
data FakeOuterNumberSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input number as post body
|
||||
instance HasBodyParam FakeOuterNumberSerialize Body
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterNumberSerialize mtype
|
||||
|
||||
|
||||
-- *** fakeOuterStringSerialize
|
||||
|
||||
-- | @POST \/fake\/outer\/string@
|
||||
--
|
||||
-- Test serialization of outer string types
|
||||
--
|
||||
fakeOuterStringSerialize
|
||||
:: (Consumes FakeOuterStringSerialize contentType)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> OpenAPIPetstoreRequest FakeOuterStringSerialize contentType Text accept
|
||||
fakeOuterStringSerialize _ _ =
|
||||
_mkRequest "POST" ["/fake/outer/string"]
|
||||
|
||||
data FakeOuterStringSerialize
|
||||
|
||||
-- | /Body Param/ "body" - Input string as post body
|
||||
instance HasBodyParam FakeOuterStringSerialize BodyText
|
||||
|
||||
-- | @*/*@
|
||||
instance MimeType mtype => Produces FakeOuterStringSerialize mtype
|
||||
|
||||
|
||||
-- *** testBodyWithQueryParams
|
||||
|
||||
-- | @PUT \/fake\/body-with-query-params@
|
||||
--
|
||||
testBodyWithQueryParams
|
||||
:: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User)
|
||||
=> User -- ^ "user"
|
||||
-> Query -- ^ "query"
|
||||
-> OpenAPIPetstoreRequest TestBodyWithQueryParams MimeJSON NoContent MimeNoContent
|
||||
testBodyWithQueryParams user (Query query) =
|
||||
_mkRequest "PUT" ["/fake/body-with-query-params"]
|
||||
`setBodyParam` user
|
||||
`setQuery` toQuery ("query", Just query)
|
||||
|
||||
data TestBodyWithQueryParams
|
||||
instance HasBodyParam TestBodyWithQueryParams User
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes TestBodyWithQueryParams MimeJSON
|
||||
|
||||
instance Produces TestBodyWithQueryParams MimeNoContent
|
||||
|
||||
|
||||
-- *** testClientModel
|
||||
|
||||
-- | @PATCH \/fake@
|
||||
--
|
||||
-- To test \"client\" model
|
||||
--
|
||||
-- To test \"client\" model
|
||||
--
|
||||
testClientModel
|
||||
:: (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client)
|
||||
=> Client -- ^ "client" - client model
|
||||
-> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON
|
||||
testClientModel client =
|
||||
_mkRequest "PATCH" ["/fake"]
|
||||
`setBodyParam` client
|
||||
|
||||
data TestClientModel
|
||||
|
||||
-- | /Body Param/ "Client" - client model
|
||||
instance HasBodyParam TestClientModel Client
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes TestClientModel MimeJSON
|
||||
|
||||
-- | @application/json@
|
||||
instance Produces TestClientModel MimeJSON
|
||||
|
||||
|
||||
-- *** testEndpointParameters
|
||||
|
||||
-- | @POST \/fake@
|
||||
--
|
||||
-- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
--
|
||||
-- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
--
|
||||
-- AuthMethod: 'AuthBasicHttpBasicTest'
|
||||
--
|
||||
testEndpointParameters
|
||||
:: (Consumes TestEndpointParameters MimeFormUrlEncoded)
|
||||
=> Number -- ^ "number" - None
|
||||
-> ParamDouble -- ^ "double" - None
|
||||
-> PatternWithoutDelimiter -- ^ "patternWithoutDelimiter" - None
|
||||
-> Byte -- ^ "byte" - None
|
||||
-> OpenAPIPetstoreRequest TestEndpointParameters MimeFormUrlEncoded NoContent MimeNoContent
|
||||
testEndpointParameters (Number number) (ParamDouble double) (PatternWithoutDelimiter patternWithoutDelimiter) (Byte byte) =
|
||||
_mkRequest "POST" ["/fake"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthBasicHttpBasicTest)
|
||||
`addForm` toForm ("number", number)
|
||||
`addForm` toForm ("double", double)
|
||||
`addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter)
|
||||
`addForm` toForm ("byte", byte)
|
||||
|
||||
data TestEndpointParameters
|
||||
|
||||
-- | /Optional Param/ "integer" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamInteger where
|
||||
applyOptionalParam req (ParamInteger xs) =
|
||||
req `addForm` toForm ("integer", xs)
|
||||
|
||||
-- | /Optional Param/ "int32" - None
|
||||
instance HasOptionalParam TestEndpointParameters Int32 where
|
||||
applyOptionalParam req (Int32 xs) =
|
||||
req `addForm` toForm ("int32", xs)
|
||||
|
||||
-- | /Optional Param/ "int64" - None
|
||||
instance HasOptionalParam TestEndpointParameters Int64 where
|
||||
applyOptionalParam req (Int64 xs) =
|
||||
req `addForm` toForm ("int64", xs)
|
||||
|
||||
-- | /Optional Param/ "float" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamFloat where
|
||||
applyOptionalParam req (ParamFloat xs) =
|
||||
req `addForm` toForm ("float", xs)
|
||||
|
||||
-- | /Optional Param/ "string" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamString where
|
||||
applyOptionalParam req (ParamString xs) =
|
||||
req `addForm` toForm ("string", xs)
|
||||
|
||||
-- | /Optional Param/ "binary" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamBinary where
|
||||
applyOptionalParam req (ParamBinary xs) =
|
||||
req `_addMultiFormPart` NH.partFileSource "binary" xs
|
||||
|
||||
-- | /Optional Param/ "date" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamDate where
|
||||
applyOptionalParam req (ParamDate xs) =
|
||||
req `addForm` toForm ("date", xs)
|
||||
|
||||
-- | /Optional Param/ "dateTime" - None
|
||||
instance HasOptionalParam TestEndpointParameters ParamDateTime where
|
||||
applyOptionalParam req (ParamDateTime xs) =
|
||||
req `addForm` toForm ("dateTime", xs)
|
||||
|
||||
-- | /Optional Param/ "password" - None
|
||||
instance HasOptionalParam TestEndpointParameters Password where
|
||||
applyOptionalParam req (Password xs) =
|
||||
req `addForm` toForm ("password", xs)
|
||||
|
||||
-- | /Optional Param/ "callback" - None
|
||||
instance HasOptionalParam TestEndpointParameters Callback where
|
||||
applyOptionalParam req (Callback xs) =
|
||||
req `addForm` toForm ("callback", xs)
|
||||
|
||||
-- | @application/x-www-form-urlencoded@
|
||||
instance Consumes TestEndpointParameters MimeFormUrlEncoded
|
||||
|
||||
instance Produces TestEndpointParameters MimeNoContent
|
||||
|
||||
|
||||
-- *** testEnumParameters
|
||||
|
||||
-- | @GET \/fake@
|
||||
--
|
||||
-- To test enum parameters
|
||||
--
|
||||
-- To test enum parameters
|
||||
--
|
||||
testEnumParameters
|
||||
:: (Consumes TestEnumParameters MimeFormUrlEncoded)
|
||||
=> OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent
|
||||
testEnumParameters =
|
||||
_mkRequest "GET" ["/fake"]
|
||||
|
||||
data TestEnumParameters
|
||||
|
||||
-- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array)
|
||||
instance HasOptionalParam TestEnumParameters EnumFormStringArray where
|
||||
applyOptionalParam req (EnumFormStringArray xs) =
|
||||
req `addForm` toFormColl CommaSeparated ("enum_form_string_array", xs)
|
||||
|
||||
-- | /Optional Param/ "enum_form_string" - Form parameter enum test (string)
|
||||
instance HasOptionalParam TestEnumParameters EnumFormString where
|
||||
applyOptionalParam req (EnumFormString xs) =
|
||||
req `addForm` toForm ("enum_form_string", xs)
|
||||
|
||||
-- | /Optional Param/ "enum_header_string_array" - Header parameter enum test (string array)
|
||||
instance HasOptionalParam TestEnumParameters EnumHeaderStringArray where
|
||||
applyOptionalParam req (EnumHeaderStringArray xs) =
|
||||
req `setHeader` toHeaderColl CommaSeparated ("enum_header_string_array", xs)
|
||||
|
||||
-- | /Optional Param/ "enum_header_string" - Header parameter enum test (string)
|
||||
instance HasOptionalParam TestEnumParameters EnumHeaderString where
|
||||
applyOptionalParam req (EnumHeaderString xs) =
|
||||
req `setHeader` toHeader ("enum_header_string", xs)
|
||||
|
||||
-- | /Optional Param/ "enum_query_string_array" - Query parameter enum test (string array)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryStringArray where
|
||||
applyOptionalParam req (EnumQueryStringArray xs) =
|
||||
req `setQuery` toQueryColl CommaSeparated ("enum_query_string_array", Just xs)
|
||||
|
||||
-- | /Optional Param/ "enum_query_string" - Query parameter enum test (string)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryString where
|
||||
applyOptionalParam req (EnumQueryString xs) =
|
||||
req `setQuery` toQuery ("enum_query_string", Just xs)
|
||||
|
||||
-- | /Optional Param/ "enum_query_integer" - Query parameter enum test (double)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryInteger where
|
||||
applyOptionalParam req (EnumQueryInteger xs) =
|
||||
req `setQuery` toQuery ("enum_query_integer", Just xs)
|
||||
|
||||
-- | /Optional Param/ "enum_query_double" - Query parameter enum test (double)
|
||||
instance HasOptionalParam TestEnumParameters EnumQueryDouble where
|
||||
applyOptionalParam req (EnumQueryDouble xs) =
|
||||
req `setQuery` toQuery ("enum_query_double", Just xs)
|
||||
|
||||
-- | @application/x-www-form-urlencoded@
|
||||
instance Consumes TestEnumParameters MimeFormUrlEncoded
|
||||
|
||||
instance Produces TestEnumParameters MimeNoContent
|
||||
|
||||
|
||||
-- *** testInlineAdditionalProperties
|
||||
|
||||
-- | @POST \/fake\/inline-additionalProperties@
|
||||
--
|
||||
-- test inline additionalProperties
|
||||
--
|
||||
testInlineAdditionalProperties
|
||||
:: (Consumes TestInlineAdditionalProperties MimeJSON, MimeRender MimeJSON RequestBody)
|
||||
=> RequestBody -- ^ "requestBody" - request body
|
||||
-> OpenAPIPetstoreRequest TestInlineAdditionalProperties MimeJSON NoContent MimeNoContent
|
||||
testInlineAdditionalProperties requestBody =
|
||||
_mkRequest "POST" ["/fake/inline-additionalProperties"]
|
||||
`setBodyParam` requestBody
|
||||
|
||||
data TestInlineAdditionalProperties
|
||||
|
||||
-- | /Body Param/ "request_body" - request body
|
||||
instance HasBodyParam TestInlineAdditionalProperties RequestBody
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes TestInlineAdditionalProperties MimeJSON
|
||||
|
||||
instance Produces TestInlineAdditionalProperties MimeNoContent
|
||||
|
||||
|
||||
-- *** testJsonFormData
|
||||
|
||||
-- | @GET \/fake\/jsonFormData@
|
||||
--
|
||||
-- test json serialization of form data
|
||||
--
|
||||
testJsonFormData
|
||||
:: (Consumes TestJsonFormData MimeFormUrlEncoded)
|
||||
=> Param -- ^ "param" - field1
|
||||
-> Param2 -- ^ "param2" - field2
|
||||
-> OpenAPIPetstoreRequest TestJsonFormData MimeFormUrlEncoded NoContent MimeNoContent
|
||||
testJsonFormData (Param param) (Param2 param2) =
|
||||
_mkRequest "GET" ["/fake/jsonFormData"]
|
||||
`addForm` toForm ("param", param)
|
||||
`addForm` toForm ("param2", param2)
|
||||
|
||||
data TestJsonFormData
|
||||
|
||||
-- | @application/x-www-form-urlencoded@
|
||||
instance Consumes TestJsonFormData MimeFormUrlEncoded
|
||||
|
||||
instance Produces TestJsonFormData MimeNoContent
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.FakeClassnameTags123
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.FakeClassnameTags123 where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** FakeClassnameTags123
|
||||
|
||||
-- *** testClassname
|
||||
|
||||
-- | @PATCH \/fake_classname_test@
|
||||
--
|
||||
-- To test class name in snake case
|
||||
--
|
||||
-- To test class name in snake case
|
||||
--
|
||||
-- AuthMethod: 'AuthApiKeyApiKeyQuery'
|
||||
--
|
||||
testClassname
|
||||
:: (Consumes TestClassname MimeJSON, MimeRender MimeJSON Client)
|
||||
=> Client -- ^ "client" - client model
|
||||
-> OpenAPIPetstoreRequest TestClassname MimeJSON Client MimeJSON
|
||||
testClassname client =
|
||||
_mkRequest "PATCH" ["/fake_classname_test"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery)
|
||||
`setBodyParam` client
|
||||
|
||||
data TestClassname
|
||||
|
||||
-- | /Body Param/ "Client" - client model
|
||||
instance HasBodyParam TestClassname Client
|
||||
|
||||
-- | @application/json@
|
||||
instance Consumes TestClassname MimeJSON
|
||||
|
||||
-- | @application/json@
|
||||
instance Produces TestClassname MimeJSON
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.Pet
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.Pet where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** Pet
|
||||
|
||||
-- *** addPet
|
||||
|
||||
-- | @POST \/pet@
|
||||
--
|
||||
-- Add a new pet to the store
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
addPet
|
||||
:: (Consumes AddPet contentType, MimeRender contentType Pet)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Pet -- ^ "pet" - Pet object that needs to be added to the store
|
||||
-> OpenAPIPetstoreRequest AddPet contentType NoContent MimeNoContent
|
||||
addPet _ pet =
|
||||
_mkRequest "POST" ["/pet"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
`setBodyParam` pet
|
||||
|
||||
data AddPet
|
||||
|
||||
-- | /Body Param/ "Pet" - Pet object that needs to be added to the store
|
||||
instance HasBodyParam AddPet Pet
|
||||
|
||||
-- | @application/xml@
|
||||
instance Consumes AddPet MimeXML
|
||||
-- | @application/json@
|
||||
instance Consumes AddPet MimeJSON
|
||||
|
||||
instance Produces AddPet MimeNoContent
|
||||
|
||||
|
||||
-- *** deletePet
|
||||
|
||||
-- | @DELETE \/pet\/{petId}@
|
||||
--
|
||||
-- Deletes a pet
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
deletePet
|
||||
:: PetId -- ^ "petId" - Pet id to delete
|
||||
-> OpenAPIPetstoreRequest DeletePet MimeNoContent NoContent MimeNoContent
|
||||
deletePet (PetId petId) =
|
||||
_mkRequest "DELETE" ["/pet/",toPath petId]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
|
||||
data DeletePet
|
||||
instance HasOptionalParam DeletePet ApiKey where
|
||||
applyOptionalParam req (ApiKey xs) =
|
||||
req `setHeader` toHeader ("api_key", xs)
|
||||
|
||||
instance Produces DeletePet MimeNoContent
|
||||
|
||||
|
||||
-- *** findPetsByStatus
|
||||
|
||||
-- | @GET \/pet\/findByStatus@
|
||||
--
|
||||
-- Finds Pets by status
|
||||
--
|
||||
-- Multiple status values can be provided with comma separated strings
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
findPetsByStatus
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> Status -- ^ "status" - Status values that need to be considered for filter
|
||||
-> OpenAPIPetstoreRequest FindPetsByStatus MimeNoContent [Pet] accept
|
||||
findPetsByStatus _ (Status status) =
|
||||
_mkRequest "GET" ["/pet/findByStatus"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
`setQuery` toQueryColl CommaSeparated ("status", Just status)
|
||||
|
||||
data FindPetsByStatus
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces FindPetsByStatus MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces FindPetsByStatus MimeJSON
|
||||
|
||||
|
||||
-- *** findPetsByTags
|
||||
|
||||
-- | @GET \/pet\/findByTags@
|
||||
--
|
||||
-- Finds Pets by tags
|
||||
--
|
||||
-- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
findPetsByTags
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> Tags -- ^ "tags" - Tags to filter by
|
||||
-> OpenAPIPetstoreRequest FindPetsByTags MimeNoContent [Pet] accept
|
||||
findPetsByTags _ (Tags tags) =
|
||||
_mkRequest "GET" ["/pet/findByTags"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
`setQuery` toQueryColl CommaSeparated ("tags", Just tags)
|
||||
|
||||
{-# DEPRECATED findPetsByTags "" #-}
|
||||
|
||||
data FindPetsByTags
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces FindPetsByTags MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces FindPetsByTags MimeJSON
|
||||
|
||||
|
||||
-- *** getPetById
|
||||
|
||||
-- | @GET \/pet\/{petId}@
|
||||
--
|
||||
-- Find pet by ID
|
||||
--
|
||||
-- Returns a single pet
|
||||
--
|
||||
-- AuthMethod: 'AuthApiKeyApiKey'
|
||||
--
|
||||
getPetById
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> PetId -- ^ "petId" - ID of pet to return
|
||||
-> OpenAPIPetstoreRequest GetPetById MimeNoContent Pet accept
|
||||
getPetById _ (PetId petId) =
|
||||
_mkRequest "GET" ["/pet/",toPath petId]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey)
|
||||
|
||||
data GetPetById
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces GetPetById MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces GetPetById MimeJSON
|
||||
|
||||
|
||||
-- *** updatePet
|
||||
|
||||
-- | @PUT \/pet@
|
||||
--
|
||||
-- Update an existing pet
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
updatePet
|
||||
:: (Consumes UpdatePet contentType, MimeRender contentType Pet)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Pet -- ^ "pet" - Pet object that needs to be added to the store
|
||||
-> OpenAPIPetstoreRequest UpdatePet contentType NoContent MimeNoContent
|
||||
updatePet _ pet =
|
||||
_mkRequest "PUT" ["/pet"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
`setBodyParam` pet
|
||||
|
||||
data UpdatePet
|
||||
|
||||
-- | /Body Param/ "Pet" - Pet object that needs to be added to the store
|
||||
instance HasBodyParam UpdatePet Pet
|
||||
|
||||
-- | @application/xml@
|
||||
instance Consumes UpdatePet MimeXML
|
||||
-- | @application/json@
|
||||
instance Consumes UpdatePet MimeJSON
|
||||
|
||||
instance Produces UpdatePet MimeNoContent
|
||||
|
||||
|
||||
-- *** updatePetWithForm
|
||||
|
||||
-- | @POST \/pet\/{petId}@
|
||||
--
|
||||
-- Updates a pet in the store with form data
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
updatePetWithForm
|
||||
:: (Consumes UpdatePetWithForm MimeFormUrlEncoded)
|
||||
=> PetId -- ^ "petId" - ID of pet that needs to be updated
|
||||
-> OpenAPIPetstoreRequest UpdatePetWithForm MimeFormUrlEncoded NoContent MimeNoContent
|
||||
updatePetWithForm (PetId petId) =
|
||||
_mkRequest "POST" ["/pet/",toPath petId]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
|
||||
data UpdatePetWithForm
|
||||
|
||||
-- | /Optional Param/ "name" - Updated name of the pet
|
||||
instance HasOptionalParam UpdatePetWithForm Name2 where
|
||||
applyOptionalParam req (Name2 xs) =
|
||||
req `addForm` toForm ("name", xs)
|
||||
|
||||
-- | /Optional Param/ "status" - Updated status of the pet
|
||||
instance HasOptionalParam UpdatePetWithForm StatusText where
|
||||
applyOptionalParam req (StatusText xs) =
|
||||
req `addForm` toForm ("status", xs)
|
||||
|
||||
-- | @application/x-www-form-urlencoded@
|
||||
instance Consumes UpdatePetWithForm MimeFormUrlEncoded
|
||||
|
||||
instance Produces UpdatePetWithForm MimeNoContent
|
||||
|
||||
|
||||
-- *** uploadFile
|
||||
|
||||
-- | @POST \/pet\/{petId}\/uploadImage@
|
||||
--
|
||||
-- uploads an image
|
||||
--
|
||||
-- AuthMethod: 'AuthOAuthPetstoreAuth'
|
||||
--
|
||||
uploadFile
|
||||
:: (Consumes UploadFile MimeMultipartFormData)
|
||||
=> PetId -- ^ "petId" - ID of pet to update
|
||||
-> OpenAPIPetstoreRequest UploadFile MimeMultipartFormData ApiResponse MimeJSON
|
||||
uploadFile (PetId petId) =
|
||||
_mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth)
|
||||
|
||||
data UploadFile
|
||||
|
||||
-- | /Optional Param/ "additionalMetadata" - Additional data to pass to server
|
||||
instance HasOptionalParam UploadFile AdditionalMetadata where
|
||||
applyOptionalParam req (AdditionalMetadata xs) =
|
||||
req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs)
|
||||
|
||||
-- | /Optional Param/ "file" - file to upload
|
||||
instance HasOptionalParam UploadFile File where
|
||||
applyOptionalParam req (File xs) =
|
||||
req `_addMultiFormPart` NH.partFileSource "file" xs
|
||||
|
||||
-- | @multipart/form-data@
|
||||
instance Consumes UploadFile MimeMultipartFormData
|
||||
|
||||
-- | @application/json@
|
||||
instance Produces UploadFile MimeJSON
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.Store
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.Store where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** Store
|
||||
|
||||
-- *** deleteOrder
|
||||
|
||||
-- | @DELETE \/store\/order\/{order_id}@
|
||||
--
|
||||
-- Delete purchase order by ID
|
||||
--
|
||||
-- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
--
|
||||
deleteOrder
|
||||
:: OrderIdText -- ^ "orderId" - ID of the order that needs to be deleted
|
||||
-> OpenAPIPetstoreRequest DeleteOrder MimeNoContent NoContent MimeNoContent
|
||||
deleteOrder (OrderIdText orderId) =
|
||||
_mkRequest "DELETE" ["/store/order/",toPath orderId]
|
||||
|
||||
data DeleteOrder
|
||||
|
||||
instance Produces DeleteOrder MimeNoContent
|
||||
|
||||
|
||||
-- *** getInventory
|
||||
|
||||
-- | @GET \/store\/inventory@
|
||||
--
|
||||
-- Returns pet inventories by status
|
||||
--
|
||||
-- Returns a map of status codes to quantities
|
||||
--
|
||||
-- AuthMethod: 'AuthApiKeyApiKey'
|
||||
--
|
||||
getInventory
|
||||
:: OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON
|
||||
getInventory =
|
||||
_mkRequest "GET" ["/store/inventory"]
|
||||
`_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey)
|
||||
|
||||
data GetInventory
|
||||
|
||||
-- | @application/json@
|
||||
instance Produces GetInventory MimeJSON
|
||||
|
||||
|
||||
-- *** getOrderById
|
||||
|
||||
-- | @GET \/store\/order\/{order_id}@
|
||||
--
|
||||
-- Find purchase order by ID
|
||||
--
|
||||
-- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
--
|
||||
getOrderById
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> OrderId -- ^ "orderId" - ID of pet that needs to be fetched
|
||||
-> OpenAPIPetstoreRequest GetOrderById MimeNoContent Order accept
|
||||
getOrderById _ (OrderId orderId) =
|
||||
_mkRequest "GET" ["/store/order/",toPath orderId]
|
||||
|
||||
data GetOrderById
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces GetOrderById MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces GetOrderById MimeJSON
|
||||
|
||||
|
||||
-- *** placeOrder
|
||||
|
||||
-- | @POST \/store\/order@
|
||||
--
|
||||
-- Place an order for a pet
|
||||
--
|
||||
placeOrder
|
||||
:: (Consumes PlaceOrder contentType, MimeRender contentType Order)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> Accept accept -- ^ request accept ('MimeType')
|
||||
-> Order -- ^ "order" - order placed for purchasing the pet
|
||||
-> OpenAPIPetstoreRequest PlaceOrder contentType Order accept
|
||||
placeOrder _ _ order =
|
||||
_mkRequest "POST" ["/store/order"]
|
||||
`setBodyParam` order
|
||||
|
||||
data PlaceOrder
|
||||
|
||||
-- | /Body Param/ "Order" - order placed for purchasing the pet
|
||||
instance HasBodyParam PlaceOrder Order
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces PlaceOrder MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces PlaceOrder MimeJSON
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.API.User
|
||||
-}
|
||||
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MonoLocalBinds #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.API.User where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Model as M
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Typeable, TypeRep, typeOf, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import qualified Data.Text.Lazy.Encoding as TL
|
||||
import qualified Data.Time as TI
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Base ((<|>))
|
||||
|
||||
import Prelude ((==),(/=),($), (.),(<$>),(<*>),(>>=),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * Operations
|
||||
|
||||
|
||||
-- ** User
|
||||
|
||||
-- *** createUser
|
||||
|
||||
-- | @POST \/user@
|
||||
--
|
||||
-- Create user
|
||||
--
|
||||
-- This can only be done by the logged in user.
|
||||
--
|
||||
createUser
|
||||
:: (Consumes CreateUser contentType, MimeRender contentType User)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User -- ^ "user" - Created user object
|
||||
-> OpenAPIPetstoreRequest CreateUser contentType NoContent MimeNoContent
|
||||
createUser _ user =
|
||||
_mkRequest "POST" ["/user"]
|
||||
`setBodyParam` user
|
||||
|
||||
data CreateUser
|
||||
|
||||
-- | /Body Param/ "User" - Created user object
|
||||
instance HasBodyParam CreateUser User
|
||||
|
||||
instance Produces CreateUser MimeNoContent
|
||||
|
||||
|
||||
-- *** createUsersWithArrayInput
|
||||
|
||||
-- | @POST \/user\/createWithArray@
|
||||
--
|
||||
-- Creates list of users with given input array
|
||||
--
|
||||
createUsersWithArrayInput
|
||||
:: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithArrayInput contentType NoContent MimeNoContent
|
||||
createUsersWithArrayInput _ user =
|
||||
_mkRequest "POST" ["/user/createWithArray"]
|
||||
`setBodyParam` user
|
||||
|
||||
data CreateUsersWithArrayInput
|
||||
|
||||
-- | /Body Param/ "User" - List of user object
|
||||
instance HasBodyParam CreateUsersWithArrayInput User2
|
||||
|
||||
instance Produces CreateUsersWithArrayInput MimeNoContent
|
||||
|
||||
|
||||
-- *** createUsersWithListInput
|
||||
|
||||
-- | @POST \/user\/createWithList@
|
||||
--
|
||||
-- Creates list of users with given input array
|
||||
--
|
||||
createUsersWithListInput
|
||||
:: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User2 -- ^ "user" - List of user object
|
||||
-> OpenAPIPetstoreRequest CreateUsersWithListInput contentType NoContent MimeNoContent
|
||||
createUsersWithListInput _ user =
|
||||
_mkRequest "POST" ["/user/createWithList"]
|
||||
`setBodyParam` user
|
||||
|
||||
data CreateUsersWithListInput
|
||||
|
||||
-- | /Body Param/ "User" - List of user object
|
||||
instance HasBodyParam CreateUsersWithListInput User2
|
||||
|
||||
instance Produces CreateUsersWithListInput MimeNoContent
|
||||
|
||||
|
||||
-- *** deleteUser
|
||||
|
||||
-- | @DELETE \/user\/{username}@
|
||||
--
|
||||
-- Delete user
|
||||
--
|
||||
-- This can only be done by the logged in user.
|
||||
--
|
||||
deleteUser
|
||||
:: Username -- ^ "username" - The name that needs to be deleted
|
||||
-> OpenAPIPetstoreRequest DeleteUser MimeNoContent NoContent MimeNoContent
|
||||
deleteUser (Username username) =
|
||||
_mkRequest "DELETE" ["/user/",toPath username]
|
||||
|
||||
data DeleteUser
|
||||
|
||||
instance Produces DeleteUser MimeNoContent
|
||||
|
||||
|
||||
-- *** getUserByName
|
||||
|
||||
-- | @GET \/user\/{username}@
|
||||
--
|
||||
-- Get user by user name
|
||||
--
|
||||
getUserByName
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> Username -- ^ "username" - The name that needs to be fetched. Use user1 for testing.
|
||||
-> OpenAPIPetstoreRequest GetUserByName MimeNoContent User accept
|
||||
getUserByName _ (Username username) =
|
||||
_mkRequest "GET" ["/user/",toPath username]
|
||||
|
||||
data GetUserByName
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces GetUserByName MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces GetUserByName MimeJSON
|
||||
|
||||
|
||||
-- *** loginUser
|
||||
|
||||
-- | @GET \/user\/login@
|
||||
--
|
||||
-- Logs user into the system
|
||||
--
|
||||
loginUser
|
||||
:: Accept accept -- ^ request accept ('MimeType')
|
||||
-> Username -- ^ "username" - The user name for login
|
||||
-> Password -- ^ "password" - The password for login in clear text
|
||||
-> OpenAPIPetstoreRequest LoginUser MimeNoContent Text accept
|
||||
loginUser _ (Username username) (Password password) =
|
||||
_mkRequest "GET" ["/user/login"]
|
||||
`setQuery` toQuery ("username", Just username)
|
||||
`setQuery` toQuery ("password", Just password)
|
||||
|
||||
data LoginUser
|
||||
|
||||
-- | @application/xml@
|
||||
instance Produces LoginUser MimeXML
|
||||
-- | @application/json@
|
||||
instance Produces LoginUser MimeJSON
|
||||
|
||||
|
||||
-- *** logoutUser
|
||||
|
||||
-- | @GET \/user\/logout@
|
||||
--
|
||||
-- Logs out current logged in user session
|
||||
--
|
||||
logoutUser
|
||||
:: OpenAPIPetstoreRequest LogoutUser MimeNoContent NoContent MimeNoContent
|
||||
logoutUser =
|
||||
_mkRequest "GET" ["/user/logout"]
|
||||
|
||||
data LogoutUser
|
||||
|
||||
instance Produces LogoutUser MimeNoContent
|
||||
|
||||
|
||||
-- *** updateUser
|
||||
|
||||
-- | @PUT \/user\/{username}@
|
||||
--
|
||||
-- Updated user
|
||||
--
|
||||
-- This can only be done by the logged in user.
|
||||
--
|
||||
updateUser
|
||||
:: (Consumes UpdateUser contentType, MimeRender contentType User)
|
||||
=> ContentType contentType -- ^ request content-type ('MimeType')
|
||||
-> User -- ^ "user" - Updated user object
|
||||
-> Username -- ^ "username" - name that need to be deleted
|
||||
-> OpenAPIPetstoreRequest UpdateUser contentType NoContent MimeNoContent
|
||||
updateUser _ user (Username username) =
|
||||
_mkRequest "PUT" ["/user/",toPath username]
|
||||
`setBodyParam` user
|
||||
|
||||
data UpdateUser
|
||||
|
||||
-- | /Body Param/ "User" - Updated user object
|
||||
instance HasBodyParam UpdateUser User
|
||||
|
||||
instance Produces UpdateUser MimeNoContent
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.Client
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE DeriveFoldable #-}
|
||||
{-# LANGUAGE DeriveTraversable #-}
|
||||
{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.Client where
|
||||
|
||||
import OpenAPIPetstore.Core
|
||||
import OpenAPIPetstore.Logging
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
|
||||
import qualified Control.Exception.Safe as E
|
||||
import qualified Control.Monad.IO.Class as P
|
||||
import qualified Control.Monad as P
|
||||
import qualified Data.Aeson.Types as A
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BCL
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Network.HTTP.Client as NH
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Data.Function ((&))
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Text (Text)
|
||||
import GHC.Exts (IsString(..))
|
||||
|
||||
-- * Dispatch
|
||||
|
||||
-- ** Lbs
|
||||
|
||||
-- | send a request returning the raw http response
|
||||
dispatchLbs
|
||||
:: (Produces req accept, MimeType contentType)
|
||||
=> NH.Manager -- ^ http-client Connection manager
|
||||
-> OpenAPIPetstoreConfig -- ^ config
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ request
|
||||
-> IO (NH.Response BCL.ByteString) -- ^ response
|
||||
dispatchLbs manager config request = do
|
||||
initReq <- _toInitRequest config request
|
||||
dispatchInitUnsafe manager config initReq
|
||||
|
||||
-- ** Mime
|
||||
|
||||
-- | pair of decoded http body and http response
|
||||
data MimeResult res =
|
||||
MimeResult { mimeResult :: Either MimeError res -- ^ decoded http body
|
||||
, mimeResultResponse :: NH.Response BCL.ByteString -- ^ http response
|
||||
}
|
||||
deriving (Show, Functor, Foldable, Traversable)
|
||||
|
||||
-- | pair of unrender/parser error and http response
|
||||
data MimeError =
|
||||
MimeError {
|
||||
mimeError :: String -- ^ unrender/parser error
|
||||
, mimeErrorResponse :: NH.Response BCL.ByteString -- ^ http response
|
||||
} deriving (Eq, Show)
|
||||
|
||||
-- | send a request returning the 'MimeResult'
|
||||
dispatchMime
|
||||
:: forall req contentType res accept. (Produces req accept, MimeUnrender accept res, MimeType contentType)
|
||||
=> NH.Manager -- ^ http-client Connection manager
|
||||
-> OpenAPIPetstoreConfig -- ^ config
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ request
|
||||
-> IO (MimeResult res) -- ^ response
|
||||
dispatchMime manager config request = do
|
||||
httpResponse <- dispatchLbs manager config request
|
||||
let statusCode = NH.statusCode . NH.responseStatus $ httpResponse
|
||||
parsedResult <-
|
||||
runConfigLogWithExceptions "Client" config $
|
||||
do if (statusCode >= 400 && statusCode < 600)
|
||||
then do
|
||||
let s = "error statusCode: " ++ show statusCode
|
||||
_log "Client" levelError (T.pack s)
|
||||
pure (Left (MimeError s httpResponse))
|
||||
else case mimeUnrender (P.Proxy :: P.Proxy accept) (NH.responseBody httpResponse) of
|
||||
Left s -> do
|
||||
_log "Client" levelError (T.pack s)
|
||||
pure (Left (MimeError s httpResponse))
|
||||
Right r -> pure (Right r)
|
||||
return (MimeResult parsedResult httpResponse)
|
||||
|
||||
-- | like 'dispatchMime', but only returns the decoded http body
|
||||
dispatchMime'
|
||||
:: (Produces req accept, MimeUnrender accept res, MimeType contentType)
|
||||
=> NH.Manager -- ^ http-client Connection manager
|
||||
-> OpenAPIPetstoreConfig -- ^ config
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ request
|
||||
-> IO (Either MimeError res) -- ^ response
|
||||
dispatchMime' manager config request = do
|
||||
MimeResult parsedResult _ <- dispatchMime manager config request
|
||||
return parsedResult
|
||||
|
||||
-- ** Unsafe
|
||||
|
||||
-- | like 'dispatchReqLbs', but does not validate the operation is a 'Producer' of the "accept" 'MimeType'. (Useful if the server's response is undocumented)
|
||||
dispatchLbsUnsafe
|
||||
:: (MimeType accept, MimeType contentType)
|
||||
=> NH.Manager -- ^ http-client Connection manager
|
||||
-> OpenAPIPetstoreConfig -- ^ config
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ request
|
||||
-> IO (NH.Response BCL.ByteString) -- ^ response
|
||||
dispatchLbsUnsafe manager config request = do
|
||||
initReq <- _toInitRequest config request
|
||||
dispatchInitUnsafe manager config initReq
|
||||
|
||||
-- | dispatch an InitRequest
|
||||
dispatchInitUnsafe
|
||||
:: NH.Manager -- ^ http-client Connection manager
|
||||
-> OpenAPIPetstoreConfig -- ^ config
|
||||
-> InitRequest req contentType res accept -- ^ init request
|
||||
-> IO (NH.Response BCL.ByteString) -- ^ response
|
||||
dispatchInitUnsafe manager config (InitRequest req) = do
|
||||
runConfigLogWithExceptions src config $
|
||||
do _log src levelInfo requestLogMsg
|
||||
_log src levelDebug requestDbgLogMsg
|
||||
res <- P.liftIO $ NH.httpLbs req manager
|
||||
_log src levelInfo (responseLogMsg res)
|
||||
_log src levelDebug ((T.pack . show) res)
|
||||
return res
|
||||
where
|
||||
src = "Client"
|
||||
endpoint =
|
||||
T.pack $
|
||||
BC.unpack $
|
||||
NH.method req <> " " <> NH.host req <> NH.path req <> NH.queryString req
|
||||
requestLogMsg = "REQ:" <> endpoint
|
||||
requestDbgLogMsg =
|
||||
"Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <>
|
||||
(case NH.requestBody req of
|
||||
NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs)
|
||||
_ -> "<RequestBody>")
|
||||
responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus
|
||||
responseLogMsg res =
|
||||
"RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")"
|
||||
|
||||
-- * InitRequest
|
||||
|
||||
-- | wraps an http-client 'Request' with request/response type parameters
|
||||
newtype InitRequest req contentType res accept = InitRequest
|
||||
{ unInitRequest :: NH.Request
|
||||
} deriving (Show)
|
||||
|
||||
-- | Build an http-client 'Request' record from the supplied config and request
|
||||
_toInitRequest
|
||||
:: (MimeType accept, MimeType contentType)
|
||||
=> OpenAPIPetstoreConfig -- ^ config
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ request
|
||||
-> IO (InitRequest req contentType res accept) -- ^ initialized request
|
||||
_toInitRequest config req0 =
|
||||
runConfigLogWithExceptions "Client" config $ do
|
||||
parsedReq <- P.liftIO $ NH.parseRequest $ BCL.unpack $ BCL.append (configHost config) (BCL.concat (rUrlPath req0))
|
||||
req1 <- P.liftIO $ _applyAuthMethods req0 config
|
||||
P.when
|
||||
(configValidateAuthMethods config && (not . null . rAuthTypes) req1)
|
||||
(E.throw $ AuthMethodException $ "AuthMethod not configured: " <> (show . head . rAuthTypes) req1)
|
||||
let req2 = req1 & _setContentTypeHeader & _setAcceptHeader
|
||||
reqHeaders = ("User-Agent", WH.toHeader (configUserAgent config)) : paramsHeaders (rParams req2)
|
||||
reqQuery = NH.renderQuery True (paramsQuery (rParams req2))
|
||||
pReq = parsedReq { NH.method = (rMethod req2)
|
||||
, NH.requestHeaders = reqHeaders
|
||||
, NH.queryString = reqQuery
|
||||
}
|
||||
outReq <- case paramsBody (rParams req2) of
|
||||
ParamBodyNone -> pure (pReq { NH.requestBody = mempty })
|
||||
ParamBodyB bs -> pure (pReq { NH.requestBody = NH.RequestBodyBS bs })
|
||||
ParamBodyBL bl -> pure (pReq { NH.requestBody = NH.RequestBodyLBS bl })
|
||||
ParamBodyFormUrlEncoded form -> pure (pReq { NH.requestBody = NH.RequestBodyLBS (WH.urlEncodeForm form) })
|
||||
ParamBodyMultipartFormData parts -> NH.formDataBody parts pReq
|
||||
|
||||
pure (InitRequest outReq)
|
||||
|
||||
-- | modify the underlying Request
|
||||
modifyInitRequest :: InitRequest req contentType res accept -> (NH.Request -> NH.Request) -> InitRequest req contentType res accept
|
||||
modifyInitRequest (InitRequest req) f = InitRequest (f req)
|
||||
|
||||
-- | modify the underlying Request (monadic)
|
||||
modifyInitRequestM :: Monad m => InitRequest req contentType res accept -> (NH.Request -> m NH.Request) -> m (InitRequest req contentType res accept)
|
||||
modifyInitRequestM (InitRequest req) f = fmap InitRequest (f req)
|
||||
|
||||
-- ** Logging
|
||||
|
||||
-- | Run a block using the configured logger instance
|
||||
runConfigLog
|
||||
:: P.MonadIO m
|
||||
=> OpenAPIPetstoreConfig -> LogExec m
|
||||
runConfigLog config = configLogExecWithContext config (configLogContext config)
|
||||
|
||||
-- | Run a block using the configured logger instance (logs exceptions)
|
||||
runConfigLogWithExceptions
|
||||
:: (E.MonadCatch m, P.MonadIO m)
|
||||
=> T.Text -> OpenAPIPetstoreConfig -> LogExec m
|
||||
runConfigLogWithExceptions src config = runConfigLog config . logExceptions src
|
||||
@@ -0,0 +1,544 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.Core
|
||||
-}
|
||||
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# LANGUAGE ExistentialQuantification #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds #-}
|
||||
|
||||
module OpenAPIPetstore.Core where
|
||||
|
||||
import OpenAPIPetstore.MimeTypes
|
||||
import OpenAPIPetstore.Logging
|
||||
|
||||
import qualified Control.Arrow as P (left)
|
||||
import qualified Control.DeepSeq as NF
|
||||
import qualified Control.Exception.Safe as E
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Base64.Lazy as BL64
|
||||
import qualified Data.ByteString.Builder as BB
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BCL
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
import qualified Data.Data as P (Data, Typeable, TypeRep, typeRep)
|
||||
import qualified Data.Foldable as P
|
||||
import qualified Data.Ix as P
|
||||
import qualified Data.Maybe as P
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Time as TI
|
||||
import qualified Data.Time.ISO8601 as TI
|
||||
import qualified GHC.Base as P (Alternative)
|
||||
import qualified Lens.Micro as L
|
||||
import qualified Network.HTTP.Client.MultipartFormData as NH
|
||||
import qualified Network.HTTP.Types as NH
|
||||
import qualified Prelude as P
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
import qualified Text.Printf as T
|
||||
|
||||
import Control.Applicative ((<|>))
|
||||
import Control.Applicative (Alternative)
|
||||
import Data.Function ((&))
|
||||
import Data.Foldable(foldlM)
|
||||
import Data.Monoid ((<>))
|
||||
import Data.Text (Text)
|
||||
import Prelude (($), (.), (<$>), (<*>), Maybe(..), Bool(..), Char, String, fmap, mempty, pure, return, show, IO, Monad, Functor)
|
||||
|
||||
-- * OpenAPIPetstoreConfig
|
||||
|
||||
-- |
|
||||
data OpenAPIPetstoreConfig = OpenAPIPetstoreConfig
|
||||
{ configHost :: BCL.ByteString -- ^ host supplied in the Request
|
||||
, configUserAgent :: Text -- ^ user-agent supplied in the Request
|
||||
, configLogExecWithContext :: LogExecWithContext -- ^ Run a block using a Logger instance
|
||||
, configLogContext :: LogContext -- ^ Configures the logger
|
||||
, configAuthMethods :: [AnyAuthMethod] -- ^ List of configured auth methods
|
||||
, configValidateAuthMethods :: Bool -- ^ throw exceptions if auth methods are not configured
|
||||
}
|
||||
|
||||
-- | display the config
|
||||
instance P.Show OpenAPIPetstoreConfig where
|
||||
show c =
|
||||
T.printf
|
||||
"{ configHost = %v, configUserAgent = %v, ..}"
|
||||
(show (configHost c))
|
||||
(show (configUserAgent c))
|
||||
|
||||
-- | constructs a default OpenAPIPetstoreConfig
|
||||
--
|
||||
-- configHost:
|
||||
--
|
||||
-- @http://petstore.swagger.io:80/v2@
|
||||
--
|
||||
-- configUserAgent:
|
||||
--
|
||||
-- @"openapi-petstore/0.1.0.0"@
|
||||
--
|
||||
newConfig :: IO OpenAPIPetstoreConfig
|
||||
newConfig = do
|
||||
logCxt <- initLogContext
|
||||
return $ OpenAPIPetstoreConfig
|
||||
{ configHost = "http://petstore.swagger.io:80/v2"
|
||||
, configUserAgent = "openapi-petstore/0.1.0.0"
|
||||
, configLogExecWithContext = runDefaultLogExecWithContext
|
||||
, configLogContext = logCxt
|
||||
, configAuthMethods = []
|
||||
, configValidateAuthMethods = True
|
||||
}
|
||||
|
||||
-- | updates config use AuthMethod on matching requests
|
||||
addAuthMethod :: AuthMethod auth => OpenAPIPetstoreConfig -> auth -> OpenAPIPetstoreConfig
|
||||
addAuthMethod config@OpenAPIPetstoreConfig {configAuthMethods = as} a =
|
||||
config { configAuthMethods = AnyAuthMethod a : as}
|
||||
|
||||
-- | updates the config to use stdout logging
|
||||
withStdoutLogging :: OpenAPIPetstoreConfig -> IO OpenAPIPetstoreConfig
|
||||
withStdoutLogging p = do
|
||||
logCxt <- stdoutLoggingContext (configLogContext p)
|
||||
return $ p { configLogExecWithContext = stdoutLoggingExec, configLogContext = logCxt }
|
||||
|
||||
-- | updates the config to use stderr logging
|
||||
withStderrLogging :: OpenAPIPetstoreConfig -> IO OpenAPIPetstoreConfig
|
||||
withStderrLogging p = do
|
||||
logCxt <- stderrLoggingContext (configLogContext p)
|
||||
return $ p { configLogExecWithContext = stderrLoggingExec, configLogContext = logCxt }
|
||||
|
||||
-- | updates the config to disable logging
|
||||
withNoLogging :: OpenAPIPetstoreConfig -> OpenAPIPetstoreConfig
|
||||
withNoLogging p = p { configLogExecWithContext = runNullLogExec}
|
||||
|
||||
-- * OpenAPIPetstoreRequest
|
||||
|
||||
-- | Represents a request.
|
||||
--
|
||||
-- Type Variables:
|
||||
--
|
||||
-- * req - request operation
|
||||
-- * contentType - 'MimeType' associated with request body
|
||||
-- * res - response model
|
||||
-- * accept - 'MimeType' associated with response body
|
||||
data OpenAPIPetstoreRequest req contentType res accept = OpenAPIPetstoreRequest
|
||||
{ rMethod :: NH.Method -- ^ Method of OpenAPIPetstoreRequest
|
||||
, rUrlPath :: [BCL.ByteString] -- ^ Endpoint of OpenAPIPetstoreRequest
|
||||
, rParams :: Params -- ^ params of OpenAPIPetstoreRequest
|
||||
, rAuthTypes :: [P.TypeRep] -- ^ types of auth methods
|
||||
}
|
||||
deriving (P.Show)
|
||||
|
||||
-- | 'rMethod' Lens
|
||||
rMethodL :: Lens_' (OpenAPIPetstoreRequest req contentType res accept) NH.Method
|
||||
rMethodL f OpenAPIPetstoreRequest{..} = (\rMethod -> OpenAPIPetstoreRequest { rMethod, ..} ) <$> f rMethod
|
||||
{-# INLINE rMethodL #-}
|
||||
|
||||
-- | 'rUrlPath' Lens
|
||||
rUrlPathL :: Lens_' (OpenAPIPetstoreRequest req contentType res accept) [BCL.ByteString]
|
||||
rUrlPathL f OpenAPIPetstoreRequest{..} = (\rUrlPath -> OpenAPIPetstoreRequest { rUrlPath, ..} ) <$> f rUrlPath
|
||||
{-# INLINE rUrlPathL #-}
|
||||
|
||||
-- | 'rParams' Lens
|
||||
rParamsL :: Lens_' (OpenAPIPetstoreRequest req contentType res accept) Params
|
||||
rParamsL f OpenAPIPetstoreRequest{..} = (\rParams -> OpenAPIPetstoreRequest { rParams, ..} ) <$> f rParams
|
||||
{-# INLINE rParamsL #-}
|
||||
|
||||
-- | 'rParams' Lens
|
||||
rAuthTypesL :: Lens_' (OpenAPIPetstoreRequest req contentType res accept) [P.TypeRep]
|
||||
rAuthTypesL f OpenAPIPetstoreRequest{..} = (\rAuthTypes -> OpenAPIPetstoreRequest { rAuthTypes, ..} ) <$> f rAuthTypes
|
||||
{-# INLINE rAuthTypesL #-}
|
||||
|
||||
-- * HasBodyParam
|
||||
|
||||
-- | Designates the body parameter of a request
|
||||
class HasBodyParam req param where
|
||||
setBodyParam :: forall contentType res accept. (Consumes req contentType, MimeRender contentType param) => OpenAPIPetstoreRequest req contentType res accept -> param -> OpenAPIPetstoreRequest req contentType res accept
|
||||
setBodyParam req xs =
|
||||
req `_setBodyLBS` mimeRender (P.Proxy :: P.Proxy contentType) xs & _setContentTypeHeader
|
||||
|
||||
-- * HasOptionalParam
|
||||
|
||||
-- | Designates the optional parameters of a request
|
||||
class HasOptionalParam req param where
|
||||
{-# MINIMAL applyOptionalParam | (-&-) #-}
|
||||
|
||||
-- | Apply an optional parameter to a request
|
||||
applyOptionalParam :: OpenAPIPetstoreRequest req contentType res accept -> param -> OpenAPIPetstoreRequest req contentType res accept
|
||||
applyOptionalParam = (-&-)
|
||||
{-# INLINE applyOptionalParam #-}
|
||||
|
||||
-- | infix operator \/ alias for 'addOptionalParam'
|
||||
(-&-) :: OpenAPIPetstoreRequest req contentType res accept -> param -> OpenAPIPetstoreRequest req contentType res accept
|
||||
(-&-) = applyOptionalParam
|
||||
{-# INLINE (-&-) #-}
|
||||
|
||||
infixl 2 -&-
|
||||
|
||||
-- | Request Params
|
||||
data Params = Params
|
||||
{ paramsQuery :: NH.Query
|
||||
, paramsHeaders :: NH.RequestHeaders
|
||||
, paramsBody :: ParamBody
|
||||
}
|
||||
deriving (P.Show)
|
||||
|
||||
-- | 'paramsQuery' Lens
|
||||
paramsQueryL :: Lens_' Params NH.Query
|
||||
paramsQueryL f Params{..} = (\paramsQuery -> Params { paramsQuery, ..} ) <$> f paramsQuery
|
||||
{-# INLINE paramsQueryL #-}
|
||||
|
||||
-- | 'paramsHeaders' Lens
|
||||
paramsHeadersL :: Lens_' Params NH.RequestHeaders
|
||||
paramsHeadersL f Params{..} = (\paramsHeaders -> Params { paramsHeaders, ..} ) <$> f paramsHeaders
|
||||
{-# INLINE paramsHeadersL #-}
|
||||
|
||||
-- | 'paramsBody' Lens
|
||||
paramsBodyL :: Lens_' Params ParamBody
|
||||
paramsBodyL f Params{..} = (\paramsBody -> Params { paramsBody, ..} ) <$> f paramsBody
|
||||
{-# INLINE paramsBodyL #-}
|
||||
|
||||
-- | Request Body
|
||||
data ParamBody
|
||||
= ParamBodyNone
|
||||
| ParamBodyB B.ByteString
|
||||
| ParamBodyBL BL.ByteString
|
||||
| ParamBodyFormUrlEncoded WH.Form
|
||||
| ParamBodyMultipartFormData [NH.Part]
|
||||
deriving (P.Show)
|
||||
|
||||
-- ** OpenAPIPetstoreRequest Utils
|
||||
|
||||
_mkRequest :: NH.Method -- ^ Method
|
||||
-> [BCL.ByteString] -- ^ Endpoint
|
||||
-> OpenAPIPetstoreRequest req contentType res accept -- ^ req: Request Type, res: Response Type
|
||||
_mkRequest m u = OpenAPIPetstoreRequest m u _mkParams []
|
||||
|
||||
_mkParams :: Params
|
||||
_mkParams = Params [] [] ParamBodyNone
|
||||
|
||||
setHeader :: OpenAPIPetstoreRequest req contentType res accept -> [NH.Header] -> OpenAPIPetstoreRequest req contentType res accept
|
||||
setHeader req header =
|
||||
req `removeHeader` P.fmap P.fst header &
|
||||
L.over (rParamsL . paramsHeadersL) (header P.++)
|
||||
|
||||
removeHeader :: OpenAPIPetstoreRequest req contentType res accept -> [NH.HeaderName] -> OpenAPIPetstoreRequest req contentType res accept
|
||||
removeHeader req header =
|
||||
req &
|
||||
L.over
|
||||
(rParamsL . paramsHeadersL)
|
||||
(P.filter (\h -> cifst h `P.notElem` P.fmap CI.mk header))
|
||||
where
|
||||
cifst = CI.mk . P.fst
|
||||
|
||||
|
||||
_setContentTypeHeader :: forall req contentType res accept. MimeType contentType => OpenAPIPetstoreRequest req contentType res accept -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_setContentTypeHeader req =
|
||||
case mimeType (P.Proxy :: P.Proxy contentType) of
|
||||
Just m -> req `setHeader` [("content-type", BC.pack $ P.show m)]
|
||||
Nothing -> req `removeHeader` ["content-type"]
|
||||
|
||||
_setAcceptHeader :: forall req contentType res accept. MimeType accept => OpenAPIPetstoreRequest req contentType res accept -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_setAcceptHeader req =
|
||||
case mimeType (P.Proxy :: P.Proxy accept) of
|
||||
Just m -> req `setHeader` [("accept", BC.pack $ P.show m)]
|
||||
Nothing -> req `removeHeader` ["accept"]
|
||||
|
||||
setQuery :: OpenAPIPetstoreRequest req contentType res accept -> [NH.QueryItem] -> OpenAPIPetstoreRequest req contentType res accept
|
||||
setQuery req query =
|
||||
req &
|
||||
L.over
|
||||
(rParamsL . paramsQueryL)
|
||||
((query P.++) . P.filter (\q -> cifst q `P.notElem` P.fmap cifst query))
|
||||
where
|
||||
cifst = CI.mk . P.fst
|
||||
|
||||
addForm :: OpenAPIPetstoreRequest req contentType res accept -> WH.Form -> OpenAPIPetstoreRequest req contentType res accept
|
||||
addForm req newform =
|
||||
let form = case paramsBody (rParams req) of
|
||||
ParamBodyFormUrlEncoded _form -> _form
|
||||
_ -> mempty
|
||||
in req & L.set (rParamsL . paramsBodyL) (ParamBodyFormUrlEncoded (newform <> form))
|
||||
|
||||
_addMultiFormPart :: OpenAPIPetstoreRequest req contentType res accept -> NH.Part -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_addMultiFormPart req newpart =
|
||||
let parts = case paramsBody (rParams req) of
|
||||
ParamBodyMultipartFormData _parts -> _parts
|
||||
_ -> []
|
||||
in req & L.set (rParamsL . paramsBodyL) (ParamBodyMultipartFormData (newpart : parts))
|
||||
|
||||
_setBodyBS :: OpenAPIPetstoreRequest req contentType res accept -> B.ByteString -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_setBodyBS req body =
|
||||
req & L.set (rParamsL . paramsBodyL) (ParamBodyB body)
|
||||
|
||||
_setBodyLBS :: OpenAPIPetstoreRequest req contentType res accept -> BL.ByteString -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_setBodyLBS req body =
|
||||
req & L.set (rParamsL . paramsBodyL) (ParamBodyBL body)
|
||||
|
||||
_hasAuthType :: AuthMethod authMethod => OpenAPIPetstoreRequest req contentType res accept -> P.Proxy authMethod -> OpenAPIPetstoreRequest req contentType res accept
|
||||
_hasAuthType req proxy =
|
||||
req & L.over rAuthTypesL (P.typeRep proxy :)
|
||||
|
||||
-- ** Params Utils
|
||||
|
||||
toPath
|
||||
:: WH.ToHttpApiData a
|
||||
=> a -> BCL.ByteString
|
||||
toPath = BB.toLazyByteString . WH.toEncodedUrlPiece
|
||||
|
||||
toHeader :: WH.ToHttpApiData a => (NH.HeaderName, a) -> [NH.Header]
|
||||
toHeader x = [fmap WH.toHeader x]
|
||||
|
||||
toForm :: WH.ToHttpApiData v => (BC.ByteString, v) -> WH.Form
|
||||
toForm (k,v) = WH.toForm [(BC.unpack k,v)]
|
||||
|
||||
toQuery :: WH.ToHttpApiData a => (BC.ByteString, Maybe a) -> [NH.QueryItem]
|
||||
toQuery x = [(fmap . fmap) toQueryParam x]
|
||||
where toQueryParam = T.encodeUtf8 . WH.toQueryParam
|
||||
|
||||
-- *** OpenAPI `CollectionFormat` Utils
|
||||
|
||||
-- | Determines the format of the array if type array is used.
|
||||
data CollectionFormat
|
||||
= CommaSeparated -- ^ CSV format for multiple parameters.
|
||||
| SpaceSeparated -- ^ Also called "SSV"
|
||||
| TabSeparated -- ^ Also called "TSV"
|
||||
| PipeSeparated -- ^ `value1|value2|value2`
|
||||
| MultiParamArray -- ^ Using multiple GET parameters, e.g. `foo=bar&foo=baz`. This is valid only for parameters in "query" ('NH.Query') or "formData" ('WH.Form')
|
||||
|
||||
toHeaderColl :: WH.ToHttpApiData a => CollectionFormat -> (NH.HeaderName, [a]) -> [NH.Header]
|
||||
toHeaderColl c xs = _toColl c toHeader xs
|
||||
|
||||
toFormColl :: WH.ToHttpApiData v => CollectionFormat -> (BC.ByteString, [v]) -> WH.Form
|
||||
toFormColl c xs = WH.toForm $ fmap unpack $ _toColl c toHeader $ pack xs
|
||||
where
|
||||
pack (k,v) = (CI.mk k, v)
|
||||
unpack (k,v) = (BC.unpack (CI.original k), BC.unpack v)
|
||||
|
||||
toQueryColl :: WH.ToHttpApiData a => CollectionFormat -> (BC.ByteString, Maybe [a]) -> NH.Query
|
||||
toQueryColl c xs = _toCollA c toQuery xs
|
||||
|
||||
_toColl :: P.Traversable f => CollectionFormat -> (f a -> [(b, BC.ByteString)]) -> f [a] -> [(b, BC.ByteString)]
|
||||
_toColl c encode xs = fmap (fmap P.fromJust) (_toCollA' c fencode BC.singleton (fmap Just xs))
|
||||
where fencode = fmap (fmap Just) . encode . fmap P.fromJust
|
||||
{-# INLINE fencode #-}
|
||||
|
||||
_toCollA :: (P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t BC.ByteString)]) -> f (t [a]) -> [(b, t BC.ByteString)]
|
||||
_toCollA c encode xs = _toCollA' c encode BC.singleton xs
|
||||
|
||||
_toCollA' :: (P.Monoid c, P.Traversable f, P.Traversable t, P.Alternative t) => CollectionFormat -> (f (t a) -> [(b, t c)]) -> (Char -> c) -> f (t [a]) -> [(b, t c)]
|
||||
_toCollA' c encode one xs = case c of
|
||||
CommaSeparated -> go (one ',')
|
||||
SpaceSeparated -> go (one ' ')
|
||||
TabSeparated -> go (one '\t')
|
||||
PipeSeparated -> go (one '|')
|
||||
MultiParamArray -> expandList
|
||||
where
|
||||
go sep =
|
||||
[P.foldl1 (\(sk, sv) (_, v) -> (sk, (combine sep <$> sv <*> v) <|> sv <|> v)) expandList]
|
||||
combine sep x y = x <> sep <> y
|
||||
expandList = (P.concatMap encode . (P.traverse . P.traverse) P.toList) xs
|
||||
{-# INLINE go #-}
|
||||
{-# INLINE expandList #-}
|
||||
{-# INLINE combine #-}
|
||||
|
||||
-- * AuthMethods
|
||||
|
||||
-- | Provides a method to apply auth methods to requests
|
||||
class P.Typeable a =>
|
||||
AuthMethod a where
|
||||
applyAuthMethod
|
||||
:: OpenAPIPetstoreConfig
|
||||
-> a
|
||||
-> OpenAPIPetstoreRequest req contentType res accept
|
||||
-> IO (OpenAPIPetstoreRequest req contentType res accept)
|
||||
|
||||
-- | An existential wrapper for any AuthMethod
|
||||
data AnyAuthMethod = forall a. AuthMethod a => AnyAuthMethod a deriving (P.Typeable)
|
||||
|
||||
instance AuthMethod AnyAuthMethod where applyAuthMethod config (AnyAuthMethod a) req = applyAuthMethod config a req
|
||||
|
||||
-- | indicates exceptions related to AuthMethods
|
||||
data AuthMethodException = AuthMethodException String deriving (P.Show, P.Typeable)
|
||||
|
||||
instance E.Exception AuthMethodException
|
||||
|
||||
-- | apply all matching AuthMethods in config to request
|
||||
_applyAuthMethods
|
||||
:: OpenAPIPetstoreRequest req contentType res accept
|
||||
-> OpenAPIPetstoreConfig
|
||||
-> IO (OpenAPIPetstoreRequest req contentType res accept)
|
||||
_applyAuthMethods req config@(OpenAPIPetstoreConfig {configAuthMethods = as}) =
|
||||
foldlM go req as
|
||||
where
|
||||
go r (AnyAuthMethod a) = applyAuthMethod config a r
|
||||
|
||||
-- * Utils
|
||||
|
||||
-- | Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)
|
||||
_omitNulls :: [(Text, A.Value)] -> A.Value
|
||||
_omitNulls = A.object . P.filter notNull
|
||||
where
|
||||
notNull (_, A.Null) = False
|
||||
notNull _ = True
|
||||
|
||||
-- | Encodes fields using WH.toQueryParam
|
||||
_toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text])
|
||||
_toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x
|
||||
|
||||
-- | Collapse (Just "") to Nothing
|
||||
_emptyToNothing :: Maybe String -> Maybe String
|
||||
_emptyToNothing (Just "") = Nothing
|
||||
_emptyToNothing x = x
|
||||
{-# INLINE _emptyToNothing #-}
|
||||
|
||||
-- | Collapse (Just mempty) to Nothing
|
||||
_memptyToNothing :: (P.Monoid a, P.Eq a) => Maybe a -> Maybe a
|
||||
_memptyToNothing (Just x) | x P.== P.mempty = Nothing
|
||||
_memptyToNothing x = x
|
||||
{-# INLINE _memptyToNothing #-}
|
||||
|
||||
-- * DateTime Formatting
|
||||
|
||||
newtype DateTime = DateTime { unDateTime :: TI.UTCTime }
|
||||
deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData,TI.ParseTime,TI.FormatTime)
|
||||
instance A.FromJSON DateTime where
|
||||
parseJSON = A.withText "DateTime" (_readDateTime . T.unpack)
|
||||
instance A.ToJSON DateTime where
|
||||
toJSON (DateTime t) = A.toJSON (_showDateTime t)
|
||||
instance WH.FromHttpApiData DateTime where
|
||||
parseUrlPiece = P.left T.pack . _readDateTime . T.unpack
|
||||
instance WH.ToHttpApiData DateTime where
|
||||
toUrlPiece (DateTime t) = T.pack (_showDateTime t)
|
||||
instance P.Show DateTime where
|
||||
show (DateTime t) = _showDateTime t
|
||||
instance MimeRender MimeMultipartFormData DateTime where
|
||||
mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
|
||||
-- | @_parseISO8601@
|
||||
_readDateTime :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t
|
||||
_readDateTime =
|
||||
_parseISO8601
|
||||
{-# INLINE _readDateTime #-}
|
||||
|
||||
-- | @TI.formatISO8601Millis@
|
||||
_showDateTime :: (t ~ TI.UTCTime, TI.FormatTime t) => t -> String
|
||||
_showDateTime =
|
||||
TI.formatISO8601Millis
|
||||
{-# INLINE _showDateTime #-}
|
||||
|
||||
-- | parse an ISO8601 date-time string
|
||||
_parseISO8601 :: (TI.ParseTime t, Monad m, Alternative m) => String -> m t
|
||||
_parseISO8601 t =
|
||||
P.asum $
|
||||
P.flip (TI.parseTimeM True TI.defaultTimeLocale) t <$>
|
||||
["%FT%T%QZ", "%FT%T%Q%z", "%FT%T%Q%Z"]
|
||||
{-# INLINE _parseISO8601 #-}
|
||||
|
||||
-- * Date Formatting
|
||||
|
||||
newtype Date = Date { unDate :: TI.Day }
|
||||
deriving (P.Enum,P.Eq,P.Data,P.Ord,P.Ix,NF.NFData,TI.ParseTime,TI.FormatTime)
|
||||
instance A.FromJSON Date where
|
||||
parseJSON = A.withText "Date" (_readDate . T.unpack)
|
||||
instance A.ToJSON Date where
|
||||
toJSON (Date t) = A.toJSON (_showDate t)
|
||||
instance WH.FromHttpApiData Date where
|
||||
parseUrlPiece = P.left T.pack . _readDate . T.unpack
|
||||
instance WH.ToHttpApiData Date where
|
||||
toUrlPiece (Date t) = T.pack (_showDate t)
|
||||
instance P.Show Date where
|
||||
show (Date t) = _showDate t
|
||||
instance MimeRender MimeMultipartFormData Date where
|
||||
mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
|
||||
-- | @TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"@
|
||||
_readDate :: (TI.ParseTime t, Monad m) => String -> m t
|
||||
_readDate =
|
||||
TI.parseTimeM True TI.defaultTimeLocale "%Y-%m-%d"
|
||||
{-# INLINE _readDate #-}
|
||||
|
||||
-- | @TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"@
|
||||
_showDate :: TI.FormatTime t => t -> String
|
||||
_showDate =
|
||||
TI.formatTime TI.defaultTimeLocale "%Y-%m-%d"
|
||||
{-# INLINE _showDate #-}
|
||||
|
||||
-- * Byte/Binary Formatting
|
||||
|
||||
|
||||
-- | base64 encoded characters
|
||||
newtype ByteArray = ByteArray { unByteArray :: BL.ByteString }
|
||||
deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData)
|
||||
|
||||
instance A.FromJSON ByteArray where
|
||||
parseJSON = A.withText "ByteArray" _readByteArray
|
||||
instance A.ToJSON ByteArray where
|
||||
toJSON = A.toJSON . _showByteArray
|
||||
instance WH.FromHttpApiData ByteArray where
|
||||
parseUrlPiece = P.left T.pack . _readByteArray
|
||||
instance WH.ToHttpApiData ByteArray where
|
||||
toUrlPiece = _showByteArray
|
||||
instance P.Show ByteArray where
|
||||
show = T.unpack . _showByteArray
|
||||
instance MimeRender MimeMultipartFormData ByteArray where
|
||||
mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
|
||||
-- | read base64 encoded characters
|
||||
_readByteArray :: Monad m => Text -> m ByteArray
|
||||
_readByteArray = P.either P.fail (pure . ByteArray) . BL64.decode . BL.fromStrict . T.encodeUtf8
|
||||
{-# INLINE _readByteArray #-}
|
||||
|
||||
-- | show base64 encoded characters
|
||||
_showByteArray :: ByteArray -> Text
|
||||
_showByteArray = T.decodeUtf8 . BL.toStrict . BL64.encode . unByteArray
|
||||
{-# INLINE _showByteArray #-}
|
||||
|
||||
-- | any sequence of octets
|
||||
newtype Binary = Binary { unBinary :: BL.ByteString }
|
||||
deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData)
|
||||
|
||||
instance A.FromJSON Binary where
|
||||
parseJSON = A.withText "Binary" _readBinaryBase64
|
||||
instance A.ToJSON Binary where
|
||||
toJSON = A.toJSON . _showBinaryBase64
|
||||
instance WH.FromHttpApiData Binary where
|
||||
parseUrlPiece = P.left T.pack . _readBinaryBase64
|
||||
instance WH.ToHttpApiData Binary where
|
||||
toUrlPiece = _showBinaryBase64
|
||||
instance P.Show Binary where
|
||||
show = T.unpack . _showBinaryBase64
|
||||
instance MimeRender MimeMultipartFormData Binary where
|
||||
mimeRender _ = unBinary
|
||||
|
||||
_readBinaryBase64 :: Monad m => Text -> m Binary
|
||||
_readBinaryBase64 = P.either P.fail (pure . Binary) . BL64.decode . BL.fromStrict . T.encodeUtf8
|
||||
{-# INLINE _readBinaryBase64 #-}
|
||||
|
||||
_showBinaryBase64 :: Binary -> Text
|
||||
_showBinaryBase64 = T.decodeUtf8 . BL.toStrict . BL64.encode . unBinary
|
||||
{-# INLINE _showBinaryBase64 #-}
|
||||
|
||||
-- * Lens Type Aliases
|
||||
|
||||
type Lens_' s a = Lens_ s s a a
|
||||
type Lens_ s t a b = forall (f :: * -> *). Functor f => (a -> f b) -> s -> f t
|
||||
@@ -0,0 +1,118 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.Logging
|
||||
Katip Logging functions
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
|
||||
module OpenAPIPetstore.Logging where
|
||||
|
||||
import qualified Control.Exception.Safe as E
|
||||
import qualified Control.Monad.IO.Class as P
|
||||
import qualified Control.Monad.Trans.Reader as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Lens.Micro as L
|
||||
import qualified System.IO as IO
|
||||
|
||||
import Data.Text (Text)
|
||||
import GHC.Exts (IsString(..))
|
||||
|
||||
import qualified Katip as LG
|
||||
|
||||
-- * Type Aliases (for compatibility)
|
||||
|
||||
-- | Runs a Katip logging block with the Log environment
|
||||
type LogExecWithContext = forall m. P.MonadIO m =>
|
||||
LogContext -> LogExec m
|
||||
|
||||
-- | A Katip logging block
|
||||
type LogExec m = forall a. LG.KatipT m a -> m a
|
||||
|
||||
-- | A Katip Log environment
|
||||
type LogContext = LG.LogEnv
|
||||
|
||||
-- | A Katip Log severity
|
||||
type LogLevel = LG.Severity
|
||||
|
||||
-- * default logger
|
||||
|
||||
-- | the default log environment
|
||||
initLogContext :: IO LogContext
|
||||
initLogContext = LG.initLogEnv "OpenAPIPetstore" "dev"
|
||||
|
||||
-- | Runs a Katip logging block with the Log environment
|
||||
runDefaultLogExecWithContext :: LogExecWithContext
|
||||
runDefaultLogExecWithContext = LG.runKatipT
|
||||
|
||||
-- * stdout logger
|
||||
|
||||
-- | Runs a Katip logging block with the Log environment
|
||||
stdoutLoggingExec :: LogExecWithContext
|
||||
stdoutLoggingExec = runDefaultLogExecWithContext
|
||||
|
||||
-- | A Katip Log environment which targets stdout
|
||||
stdoutLoggingContext :: LogContext -> IO LogContext
|
||||
stdoutLoggingContext cxt = do
|
||||
handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stdout LG.InfoS LG.V2
|
||||
LG.registerScribe "stdout" handleScribe LG.defaultScribeSettings cxt
|
||||
|
||||
-- * stderr logger
|
||||
|
||||
-- | Runs a Katip logging block with the Log environment
|
||||
stderrLoggingExec :: LogExecWithContext
|
||||
stderrLoggingExec = runDefaultLogExecWithContext
|
||||
|
||||
-- | A Katip Log environment which targets stderr
|
||||
stderrLoggingContext :: LogContext -> IO LogContext
|
||||
stderrLoggingContext cxt = do
|
||||
handleScribe <- LG.mkHandleScribe LG.ColorIfTerminal IO.stderr LG.InfoS LG.V2
|
||||
LG.registerScribe "stderr" handleScribe LG.defaultScribeSettings cxt
|
||||
|
||||
-- * Null logger
|
||||
|
||||
-- | Disables Katip logging
|
||||
runNullLogExec :: LogExecWithContext
|
||||
runNullLogExec le (LG.KatipT f) = P.runReaderT f (L.set LG.logEnvScribes mempty le)
|
||||
|
||||
-- * Log Msg
|
||||
|
||||
-- | Log a katip message
|
||||
_log :: (Applicative m, LG.Katip m) => Text -> LogLevel -> Text -> m ()
|
||||
_log src level msg = do
|
||||
LG.logMsg (fromString $ T.unpack src) level (LG.logStr msg)
|
||||
|
||||
-- * Log Exceptions
|
||||
|
||||
-- | re-throws exceptions after logging them
|
||||
logExceptions
|
||||
:: (LG.Katip m, E.MonadCatch m, Applicative m)
|
||||
=> Text -> m a -> m a
|
||||
logExceptions src =
|
||||
E.handle
|
||||
(\(e :: E.SomeException) -> do
|
||||
_log src LG.ErrorS ((T.pack . show) e)
|
||||
E.throw e)
|
||||
|
||||
-- * Log Level
|
||||
|
||||
levelInfo :: LogLevel
|
||||
levelInfo = LG.InfoS
|
||||
|
||||
levelError :: LogLevel
|
||||
levelError = LG.ErrorS
|
||||
|
||||
levelDebug :: LogLevel
|
||||
levelDebug = LG.DebugS
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.MimeTypes
|
||||
-}
|
||||
|
||||
{-# LANGUAGE ConstraintKinds #-}
|
||||
{-# LANGUAGE ExistentialQuantification #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.MimeTypes where
|
||||
|
||||
import qualified Control.Arrow as P (left)
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Builder as BB
|
||||
import qualified Data.ByteString.Char8 as BC
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.ByteString.Lazy.Char8 as BCL
|
||||
import qualified Data.Data as P (Typeable)
|
||||
import qualified Data.Proxy as P (Proxy(..))
|
||||
import qualified Data.String as P
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Network.HTTP.Media as ME
|
||||
import qualified Web.FormUrlEncoded as WH
|
||||
import qualified Web.HttpApiData as WH
|
||||
|
||||
import Prelude (($), (.),(<$>),(<*>),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty)
|
||||
import qualified Prelude as P
|
||||
|
||||
-- * ContentType MimeType
|
||||
|
||||
data ContentType a = MimeType a => ContentType { unContentType :: a }
|
||||
|
||||
-- * Accept MimeType
|
||||
|
||||
data Accept a = MimeType a => Accept { unAccept :: a }
|
||||
|
||||
-- * Consumes Class
|
||||
|
||||
class MimeType mtype => Consumes req mtype where
|
||||
|
||||
-- * Produces Class
|
||||
|
||||
class MimeType mtype => Produces req mtype where
|
||||
|
||||
-- * Default Mime Types
|
||||
|
||||
data MimeJSON = MimeJSON deriving (P.Typeable)
|
||||
data MimeXML = MimeXML deriving (P.Typeable)
|
||||
data MimePlainText = MimePlainText deriving (P.Typeable)
|
||||
data MimeFormUrlEncoded = MimeFormUrlEncoded deriving (P.Typeable)
|
||||
data MimeMultipartFormData = MimeMultipartFormData deriving (P.Typeable)
|
||||
data MimeOctetStream = MimeOctetStream deriving (P.Typeable)
|
||||
data MimeNoContent = MimeNoContent deriving (P.Typeable)
|
||||
data MimeAny = MimeAny deriving (P.Typeable)
|
||||
|
||||
-- | A type for responses without content-body.
|
||||
data NoContent = NoContent
|
||||
deriving (P.Show, P.Eq, P.Typeable)
|
||||
|
||||
|
||||
-- * MimeType Class
|
||||
|
||||
class P.Typeable mtype => MimeType mtype where
|
||||
{-# MINIMAL mimeType | mimeTypes #-}
|
||||
|
||||
mimeTypes :: P.Proxy mtype -> [ME.MediaType]
|
||||
mimeTypes p =
|
||||
case mimeType p of
|
||||
Just x -> [x]
|
||||
Nothing -> []
|
||||
|
||||
mimeType :: P.Proxy mtype -> Maybe ME.MediaType
|
||||
mimeType p =
|
||||
case mimeTypes p of
|
||||
[] -> Nothing
|
||||
(x:_) -> Just x
|
||||
|
||||
mimeType' :: mtype -> Maybe ME.MediaType
|
||||
mimeType' _ = mimeType (P.Proxy :: P.Proxy mtype)
|
||||
mimeTypes' :: mtype -> [ME.MediaType]
|
||||
mimeTypes' _ = mimeTypes (P.Proxy :: P.Proxy mtype)
|
||||
|
||||
-- Default MimeType Instances
|
||||
|
||||
-- | @application/json; charset=utf-8@
|
||||
instance MimeType MimeJSON where
|
||||
mimeType _ = Just $ P.fromString "application/json"
|
||||
-- | @application/xml; charset=utf-8@
|
||||
instance MimeType MimeXML where
|
||||
mimeType _ = Just $ P.fromString "application/xml"
|
||||
-- | @application/x-www-form-urlencoded@
|
||||
instance MimeType MimeFormUrlEncoded where
|
||||
mimeType _ = Just $ P.fromString "application/x-www-form-urlencoded"
|
||||
-- | @multipart/form-data@
|
||||
instance MimeType MimeMultipartFormData where
|
||||
mimeType _ = Just $ P.fromString "multipart/form-data"
|
||||
-- | @text/plain; charset=utf-8@
|
||||
instance MimeType MimePlainText where
|
||||
mimeType _ = Just $ P.fromString "text/plain"
|
||||
-- | @application/octet-stream@
|
||||
instance MimeType MimeOctetStream where
|
||||
mimeType _ = Just $ P.fromString "application/octet-stream"
|
||||
-- | @"*/*"@
|
||||
instance MimeType MimeAny where
|
||||
mimeType _ = Just $ P.fromString "*/*"
|
||||
instance MimeType MimeNoContent where
|
||||
mimeType _ = Nothing
|
||||
|
||||
-- * MimeRender Class
|
||||
|
||||
class MimeType mtype => MimeRender mtype x where
|
||||
mimeRender :: P.Proxy mtype -> x -> BL.ByteString
|
||||
mimeRender' :: mtype -> x -> BL.ByteString
|
||||
mimeRender' _ x = mimeRender (P.Proxy :: P.Proxy mtype) x
|
||||
|
||||
|
||||
mimeRenderDefaultMultipartFormData :: WH.ToHttpApiData a => a -> BL.ByteString
|
||||
mimeRenderDefaultMultipartFormData = BL.fromStrict . T.encodeUtf8 . WH.toQueryParam
|
||||
|
||||
-- Default MimeRender Instances
|
||||
|
||||
-- | `A.encode`
|
||||
instance A.ToJSON a => MimeRender MimeJSON a where mimeRender _ = A.encode
|
||||
-- | @WH.urlEncodeAsForm@
|
||||
instance WH.ToForm a => MimeRender MimeFormUrlEncoded a where mimeRender _ = WH.urlEncodeAsForm
|
||||
|
||||
-- | @P.id@
|
||||
instance MimeRender MimePlainText BL.ByteString where mimeRender _ = P.id
|
||||
-- | @BL.fromStrict . T.encodeUtf8@
|
||||
instance MimeRender MimePlainText T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8
|
||||
-- | @BCL.pack@
|
||||
instance MimeRender MimePlainText String where mimeRender _ = BCL.pack
|
||||
|
||||
-- | @P.id@
|
||||
instance MimeRender MimeOctetStream BL.ByteString where mimeRender _ = P.id
|
||||
-- | @BL.fromStrict . T.encodeUtf8@
|
||||
instance MimeRender MimeOctetStream T.Text where mimeRender _ = BL.fromStrict . T.encodeUtf8
|
||||
-- | @BCL.pack@
|
||||
instance MimeRender MimeOctetStream String where mimeRender _ = BCL.pack
|
||||
|
||||
instance MimeRender MimeMultipartFormData BL.ByteString where mimeRender _ = P.id
|
||||
|
||||
instance MimeRender MimeMultipartFormData Bool where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData Char where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData Double where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData Float where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData Int where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData Integer where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData String where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
instance MimeRender MimeMultipartFormData T.Text where mimeRender _ = mimeRenderDefaultMultipartFormData
|
||||
|
||||
-- | @P.Right . P.const NoContent@
|
||||
instance MimeRender MimeNoContent NoContent where mimeRender _ = P.const BCL.empty
|
||||
|
||||
|
||||
-- * MimeUnrender Class
|
||||
|
||||
class MimeType mtype => MimeUnrender mtype o where
|
||||
mimeUnrender :: P.Proxy mtype -> BL.ByteString -> P.Either String o
|
||||
mimeUnrender' :: mtype -> BL.ByteString -> P.Either String o
|
||||
mimeUnrender' _ x = mimeUnrender (P.Proxy :: P.Proxy mtype) x
|
||||
|
||||
-- Default MimeUnrender Instances
|
||||
|
||||
-- | @A.eitherDecode@
|
||||
instance A.FromJSON a => MimeUnrender MimeJSON a where mimeUnrender _ = A.eitherDecode
|
||||
-- | @P.left T.unpack . WH.urlDecodeAsForm@
|
||||
instance WH.FromForm a => MimeUnrender MimeFormUrlEncoded a where mimeUnrender _ = P.left T.unpack . WH.urlDecodeAsForm
|
||||
-- | @P.Right . P.id@
|
||||
|
||||
instance MimeUnrender MimePlainText BL.ByteString where mimeUnrender _ = P.Right . P.id
|
||||
-- | @P.left P.show . TL.decodeUtf8'@
|
||||
instance MimeUnrender MimePlainText T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict
|
||||
-- | @P.Right . BCL.unpack@
|
||||
instance MimeUnrender MimePlainText String where mimeUnrender _ = P.Right . BCL.unpack
|
||||
|
||||
-- | @P.Right . P.id@
|
||||
instance MimeUnrender MimeOctetStream BL.ByteString where mimeUnrender _ = P.Right . P.id
|
||||
-- | @P.left P.show . T.decodeUtf8' . BL.toStrict@
|
||||
instance MimeUnrender MimeOctetStream T.Text where mimeUnrender _ = P.left P.show . T.decodeUtf8' . BL.toStrict
|
||||
-- | @P.Right . BCL.unpack@
|
||||
instance MimeUnrender MimeOctetStream String where mimeUnrender _ = P.Right . BCL.unpack
|
||||
|
||||
-- | @P.Right . P.const NoContent@
|
||||
instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P.const NoContent
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,629 @@
|
||||
{-
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI Version: 3.0.1
|
||||
OpenAPI Petstore API version: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
-}
|
||||
|
||||
{-|
|
||||
Module : OpenAPIPetstore.Lens
|
||||
-}
|
||||
|
||||
{-# LANGUAGE KindSignatures #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module OpenAPIPetstore.ModelLens where
|
||||
|
||||
import qualified Data.Aeson as A
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
import qualified Data.Data as P (Data, Typeable)
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Time as TI
|
||||
|
||||
import Data.Text (Text)
|
||||
|
||||
import Prelude (($), (.),(<$>),(<*>),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor)
|
||||
import qualified Prelude as P
|
||||
|
||||
import OpenAPIPetstore.Model
|
||||
import OpenAPIPetstore.Core
|
||||
|
||||
|
||||
-- * AdditionalPropertiesClass
|
||||
|
||||
-- | 'additionalPropertiesClassMapProperty' Lens
|
||||
additionalPropertiesClassMapPropertyL :: Lens_' AdditionalPropertiesClass (Maybe (Map.Map String Text))
|
||||
additionalPropertiesClassMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapProperty, ..} ) <$> f additionalPropertiesClassMapProperty
|
||||
{-# INLINE additionalPropertiesClassMapPropertyL #-}
|
||||
|
||||
-- | 'additionalPropertiesClassMapOfMapProperty' Lens
|
||||
additionalPropertiesClassMapOfMapPropertyL :: Lens_' AdditionalPropertiesClass (Maybe (Map.Map String (Map.Map String Text)))
|
||||
additionalPropertiesClassMapOfMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapOfMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapOfMapProperty, ..} ) <$> f additionalPropertiesClassMapOfMapProperty
|
||||
{-# INLINE additionalPropertiesClassMapOfMapPropertyL #-}
|
||||
|
||||
|
||||
|
||||
-- * Animal
|
||||
|
||||
-- | 'animalClassName' Lens
|
||||
animalClassNameL :: Lens_' Animal (Text)
|
||||
animalClassNameL f Animal{..} = (\animalClassName -> Animal { animalClassName, ..} ) <$> f animalClassName
|
||||
{-# INLINE animalClassNameL #-}
|
||||
|
||||
-- | 'animalColor' Lens
|
||||
animalColorL :: Lens_' Animal (Maybe Text)
|
||||
animalColorL f Animal{..} = (\animalColor -> Animal { animalColor, ..} ) <$> f animalColor
|
||||
{-# INLINE animalColorL #-}
|
||||
|
||||
|
||||
|
||||
-- * AnimalFarm
|
||||
|
||||
|
||||
|
||||
-- * ApiResponse
|
||||
|
||||
-- | 'apiResponseCode' Lens
|
||||
apiResponseCodeL :: Lens_' ApiResponse (Maybe Int)
|
||||
apiResponseCodeL f ApiResponse{..} = (\apiResponseCode -> ApiResponse { apiResponseCode, ..} ) <$> f apiResponseCode
|
||||
{-# INLINE apiResponseCodeL #-}
|
||||
|
||||
-- | 'apiResponseType' Lens
|
||||
apiResponseTypeL :: Lens_' ApiResponse (Maybe Text)
|
||||
apiResponseTypeL f ApiResponse{..} = (\apiResponseType -> ApiResponse { apiResponseType, ..} ) <$> f apiResponseType
|
||||
{-# INLINE apiResponseTypeL #-}
|
||||
|
||||
-- | 'apiResponseMessage' Lens
|
||||
apiResponseMessageL :: Lens_' ApiResponse (Maybe Text)
|
||||
apiResponseMessageL f ApiResponse{..} = (\apiResponseMessage -> ApiResponse { apiResponseMessage, ..} ) <$> f apiResponseMessage
|
||||
{-# INLINE apiResponseMessageL #-}
|
||||
|
||||
|
||||
|
||||
-- * ArrayOfArrayOfNumberOnly
|
||||
|
||||
-- | 'arrayOfArrayOfNumberOnlyArrayArrayNumber' Lens
|
||||
arrayOfArrayOfNumberOnlyArrayArrayNumberL :: Lens_' ArrayOfArrayOfNumberOnly (Maybe [[Double]])
|
||||
arrayOfArrayOfNumberOnlyArrayArrayNumberL f ArrayOfArrayOfNumberOnly{..} = (\arrayOfArrayOfNumberOnlyArrayArrayNumber -> ArrayOfArrayOfNumberOnly { arrayOfArrayOfNumberOnlyArrayArrayNumber, ..} ) <$> f arrayOfArrayOfNumberOnlyArrayArrayNumber
|
||||
{-# INLINE arrayOfArrayOfNumberOnlyArrayArrayNumberL #-}
|
||||
|
||||
|
||||
|
||||
-- * ArrayOfNumberOnly
|
||||
|
||||
-- | 'arrayOfNumberOnlyArrayNumber' Lens
|
||||
arrayOfNumberOnlyArrayNumberL :: Lens_' ArrayOfNumberOnly (Maybe [Double])
|
||||
arrayOfNumberOnlyArrayNumberL f ArrayOfNumberOnly{..} = (\arrayOfNumberOnlyArrayNumber -> ArrayOfNumberOnly { arrayOfNumberOnlyArrayNumber, ..} ) <$> f arrayOfNumberOnlyArrayNumber
|
||||
{-# INLINE arrayOfNumberOnlyArrayNumberL #-}
|
||||
|
||||
|
||||
|
||||
-- * ArrayTest
|
||||
|
||||
-- | 'arrayTestArrayOfString' Lens
|
||||
arrayTestArrayOfStringL :: Lens_' ArrayTest (Maybe [Text])
|
||||
arrayTestArrayOfStringL f ArrayTest{..} = (\arrayTestArrayOfString -> ArrayTest { arrayTestArrayOfString, ..} ) <$> f arrayTestArrayOfString
|
||||
{-# INLINE arrayTestArrayOfStringL #-}
|
||||
|
||||
-- | 'arrayTestArrayArrayOfInteger' Lens
|
||||
arrayTestArrayArrayOfIntegerL :: Lens_' ArrayTest (Maybe [[Integer]])
|
||||
arrayTestArrayArrayOfIntegerL f ArrayTest{..} = (\arrayTestArrayArrayOfInteger -> ArrayTest { arrayTestArrayArrayOfInteger, ..} ) <$> f arrayTestArrayArrayOfInteger
|
||||
{-# INLINE arrayTestArrayArrayOfIntegerL #-}
|
||||
|
||||
-- | 'arrayTestArrayArrayOfModel' Lens
|
||||
arrayTestArrayArrayOfModelL :: Lens_' ArrayTest (Maybe [[ReadOnlyFirst]])
|
||||
arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> ArrayTest { arrayTestArrayArrayOfModel, ..} ) <$> f arrayTestArrayArrayOfModel
|
||||
{-# INLINE arrayTestArrayArrayOfModelL #-}
|
||||
|
||||
|
||||
|
||||
-- * Capitalization
|
||||
|
||||
-- | 'capitalizationSmallCamel' Lens
|
||||
capitalizationSmallCamelL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationSmallCamelL f Capitalization{..} = (\capitalizationSmallCamel -> Capitalization { capitalizationSmallCamel, ..} ) <$> f capitalizationSmallCamel
|
||||
{-# INLINE capitalizationSmallCamelL #-}
|
||||
|
||||
-- | 'capitalizationCapitalCamel' Lens
|
||||
capitalizationCapitalCamelL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationCapitalCamelL f Capitalization{..} = (\capitalizationCapitalCamel -> Capitalization { capitalizationCapitalCamel, ..} ) <$> f capitalizationCapitalCamel
|
||||
{-# INLINE capitalizationCapitalCamelL #-}
|
||||
|
||||
-- | 'capitalizationSmallSnake' Lens
|
||||
capitalizationSmallSnakeL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationSmallSnakeL f Capitalization{..} = (\capitalizationSmallSnake -> Capitalization { capitalizationSmallSnake, ..} ) <$> f capitalizationSmallSnake
|
||||
{-# INLINE capitalizationSmallSnakeL #-}
|
||||
|
||||
-- | 'capitalizationCapitalSnake' Lens
|
||||
capitalizationCapitalSnakeL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationCapitalSnakeL f Capitalization{..} = (\capitalizationCapitalSnake -> Capitalization { capitalizationCapitalSnake, ..} ) <$> f capitalizationCapitalSnake
|
||||
{-# INLINE capitalizationCapitalSnakeL #-}
|
||||
|
||||
-- | 'capitalizationScaEthFlowPoints' Lens
|
||||
capitalizationScaEthFlowPointsL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationScaEthFlowPointsL f Capitalization{..} = (\capitalizationScaEthFlowPoints -> Capitalization { capitalizationScaEthFlowPoints, ..} ) <$> f capitalizationScaEthFlowPoints
|
||||
{-# INLINE capitalizationScaEthFlowPointsL #-}
|
||||
|
||||
-- | 'capitalizationAttName' Lens
|
||||
capitalizationAttNameL :: Lens_' Capitalization (Maybe Text)
|
||||
capitalizationAttNameL f Capitalization{..} = (\capitalizationAttName -> Capitalization { capitalizationAttName, ..} ) <$> f capitalizationAttName
|
||||
{-# INLINE capitalizationAttNameL #-}
|
||||
|
||||
|
||||
|
||||
-- * Cat
|
||||
|
||||
-- | 'catClassName' Lens
|
||||
catClassNameL :: Lens_' Cat (Text)
|
||||
catClassNameL f Cat{..} = (\catClassName -> Cat { catClassName, ..} ) <$> f catClassName
|
||||
{-# INLINE catClassNameL #-}
|
||||
|
||||
-- | 'catColor' Lens
|
||||
catColorL :: Lens_' Cat (Maybe Text)
|
||||
catColorL f Cat{..} = (\catColor -> Cat { catColor, ..} ) <$> f catColor
|
||||
{-# INLINE catColorL #-}
|
||||
|
||||
-- | 'catDeclawed' Lens
|
||||
catDeclawedL :: Lens_' Cat (Maybe Bool)
|
||||
catDeclawedL f Cat{..} = (\catDeclawed -> Cat { catDeclawed, ..} ) <$> f catDeclawed
|
||||
{-# INLINE catDeclawedL #-}
|
||||
|
||||
|
||||
|
||||
-- * Category
|
||||
|
||||
-- | 'categoryId' Lens
|
||||
categoryIdL :: Lens_' Category (Maybe Integer)
|
||||
categoryIdL f Category{..} = (\categoryId -> Category { categoryId, ..} ) <$> f categoryId
|
||||
{-# INLINE categoryIdL #-}
|
||||
|
||||
-- | 'categoryName' Lens
|
||||
categoryNameL :: Lens_' Category (Maybe Text)
|
||||
categoryNameL f Category{..} = (\categoryName -> Category { categoryName, ..} ) <$> f categoryName
|
||||
{-# INLINE categoryNameL #-}
|
||||
|
||||
|
||||
|
||||
-- * ClassModel
|
||||
|
||||
-- | 'classModelClass' Lens
|
||||
classModelClassL :: Lens_' ClassModel (Maybe Text)
|
||||
classModelClassL f ClassModel{..} = (\classModelClass -> ClassModel { classModelClass, ..} ) <$> f classModelClass
|
||||
{-# INLINE classModelClassL #-}
|
||||
|
||||
|
||||
|
||||
-- * Client
|
||||
|
||||
-- | 'clientClient' Lens
|
||||
clientClientL :: Lens_' Client (Maybe Text)
|
||||
clientClientL f Client{..} = (\clientClient -> Client { clientClient, ..} ) <$> f clientClient
|
||||
{-# INLINE clientClientL #-}
|
||||
|
||||
|
||||
|
||||
-- * Dog
|
||||
|
||||
-- | 'dogClassName' Lens
|
||||
dogClassNameL :: Lens_' Dog (Text)
|
||||
dogClassNameL f Dog{..} = (\dogClassName -> Dog { dogClassName, ..} ) <$> f dogClassName
|
||||
{-# INLINE dogClassNameL #-}
|
||||
|
||||
-- | 'dogColor' Lens
|
||||
dogColorL :: Lens_' Dog (Maybe Text)
|
||||
dogColorL f Dog{..} = (\dogColor -> Dog { dogColor, ..} ) <$> f dogColor
|
||||
{-# INLINE dogColorL #-}
|
||||
|
||||
-- | 'dogBreed' Lens
|
||||
dogBreedL :: Lens_' Dog (Maybe Text)
|
||||
dogBreedL f Dog{..} = (\dogBreed -> Dog { dogBreed, ..} ) <$> f dogBreed
|
||||
{-# INLINE dogBreedL #-}
|
||||
|
||||
|
||||
|
||||
-- * EnumArrays
|
||||
|
||||
-- | 'enumArraysJustSymbol' Lens
|
||||
enumArraysJustSymbolL :: Lens_' EnumArrays (Maybe E'JustSymbol)
|
||||
enumArraysJustSymbolL f EnumArrays{..} = (\enumArraysJustSymbol -> EnumArrays { enumArraysJustSymbol, ..} ) <$> f enumArraysJustSymbol
|
||||
{-# INLINE enumArraysJustSymbolL #-}
|
||||
|
||||
-- | 'enumArraysArrayEnum' Lens
|
||||
enumArraysArrayEnumL :: Lens_' EnumArrays (Maybe [E'ArrayEnum])
|
||||
enumArraysArrayEnumL f EnumArrays{..} = (\enumArraysArrayEnum -> EnumArrays { enumArraysArrayEnum, ..} ) <$> f enumArraysArrayEnum
|
||||
{-# INLINE enumArraysArrayEnumL #-}
|
||||
|
||||
|
||||
|
||||
-- * EnumClass
|
||||
|
||||
|
||||
|
||||
-- * EnumTest
|
||||
|
||||
-- | 'enumTestEnumString' Lens
|
||||
enumTestEnumStringL :: Lens_' EnumTest (Maybe E'EnumString)
|
||||
enumTestEnumStringL f EnumTest{..} = (\enumTestEnumString -> EnumTest { enumTestEnumString, ..} ) <$> f enumTestEnumString
|
||||
{-# INLINE enumTestEnumStringL #-}
|
||||
|
||||
-- | 'enumTestEnumStringRequired' Lens
|
||||
enumTestEnumStringRequiredL :: Lens_' EnumTest (E'EnumString)
|
||||
enumTestEnumStringRequiredL f EnumTest{..} = (\enumTestEnumStringRequired -> EnumTest { enumTestEnumStringRequired, ..} ) <$> f enumTestEnumStringRequired
|
||||
{-# INLINE enumTestEnumStringRequiredL #-}
|
||||
|
||||
-- | 'enumTestEnumInteger' Lens
|
||||
enumTestEnumIntegerL :: Lens_' EnumTest (Maybe E'EnumInteger)
|
||||
enumTestEnumIntegerL f EnumTest{..} = (\enumTestEnumInteger -> EnumTest { enumTestEnumInteger, ..} ) <$> f enumTestEnumInteger
|
||||
{-# INLINE enumTestEnumIntegerL #-}
|
||||
|
||||
-- | 'enumTestEnumNumber' Lens
|
||||
enumTestEnumNumberL :: Lens_' EnumTest (Maybe E'EnumNumber)
|
||||
enumTestEnumNumberL f EnumTest{..} = (\enumTestEnumNumber -> EnumTest { enumTestEnumNumber, ..} ) <$> f enumTestEnumNumber
|
||||
{-# INLINE enumTestEnumNumberL #-}
|
||||
|
||||
-- | 'enumTestOuterEnum' Lens
|
||||
enumTestOuterEnumL :: Lens_' EnumTest (Maybe OuterEnum)
|
||||
enumTestOuterEnumL f EnumTest{..} = (\enumTestOuterEnum -> EnumTest { enumTestOuterEnum, ..} ) <$> f enumTestOuterEnum
|
||||
{-# INLINE enumTestOuterEnumL #-}
|
||||
|
||||
|
||||
|
||||
-- * FormatTest
|
||||
|
||||
-- | 'formatTestInteger' Lens
|
||||
formatTestIntegerL :: Lens_' FormatTest (Maybe Int)
|
||||
formatTestIntegerL f FormatTest{..} = (\formatTestInteger -> FormatTest { formatTestInteger, ..} ) <$> f formatTestInteger
|
||||
{-# INLINE formatTestIntegerL #-}
|
||||
|
||||
-- | 'formatTestInt32' Lens
|
||||
formatTestInt32L :: Lens_' FormatTest (Maybe Int)
|
||||
formatTestInt32L f FormatTest{..} = (\formatTestInt32 -> FormatTest { formatTestInt32, ..} ) <$> f formatTestInt32
|
||||
{-# INLINE formatTestInt32L #-}
|
||||
|
||||
-- | 'formatTestInt64' Lens
|
||||
formatTestInt64L :: Lens_' FormatTest (Maybe Integer)
|
||||
formatTestInt64L f FormatTest{..} = (\formatTestInt64 -> FormatTest { formatTestInt64, ..} ) <$> f formatTestInt64
|
||||
{-# INLINE formatTestInt64L #-}
|
||||
|
||||
-- | 'formatTestNumber' Lens
|
||||
formatTestNumberL :: Lens_' FormatTest (Double)
|
||||
formatTestNumberL f FormatTest{..} = (\formatTestNumber -> FormatTest { formatTestNumber, ..} ) <$> f formatTestNumber
|
||||
{-# INLINE formatTestNumberL #-}
|
||||
|
||||
-- | 'formatTestFloat' Lens
|
||||
formatTestFloatL :: Lens_' FormatTest (Maybe Float)
|
||||
formatTestFloatL f FormatTest{..} = (\formatTestFloat -> FormatTest { formatTestFloat, ..} ) <$> f formatTestFloat
|
||||
{-# INLINE formatTestFloatL #-}
|
||||
|
||||
-- | 'formatTestDouble' Lens
|
||||
formatTestDoubleL :: Lens_' FormatTest (Maybe Double)
|
||||
formatTestDoubleL f FormatTest{..} = (\formatTestDouble -> FormatTest { formatTestDouble, ..} ) <$> f formatTestDouble
|
||||
{-# INLINE formatTestDoubleL #-}
|
||||
|
||||
-- | 'formatTestString' Lens
|
||||
formatTestStringL :: Lens_' FormatTest (Maybe Text)
|
||||
formatTestStringL f FormatTest{..} = (\formatTestString -> FormatTest { formatTestString, ..} ) <$> f formatTestString
|
||||
{-# INLINE formatTestStringL #-}
|
||||
|
||||
-- | 'formatTestByte' Lens
|
||||
formatTestByteL :: Lens_' FormatTest (ByteArray)
|
||||
formatTestByteL f FormatTest{..} = (\formatTestByte -> FormatTest { formatTestByte, ..} ) <$> f formatTestByte
|
||||
{-# INLINE formatTestByteL #-}
|
||||
|
||||
-- | 'formatTestBinary' Lens
|
||||
formatTestBinaryL :: Lens_' FormatTest (Maybe FilePath)
|
||||
formatTestBinaryL f FormatTest{..} = (\formatTestBinary -> FormatTest { formatTestBinary, ..} ) <$> f formatTestBinary
|
||||
{-# INLINE formatTestBinaryL #-}
|
||||
|
||||
-- | 'formatTestDate' Lens
|
||||
formatTestDateL :: Lens_' FormatTest (Date)
|
||||
formatTestDateL f FormatTest{..} = (\formatTestDate -> FormatTest { formatTestDate, ..} ) <$> f formatTestDate
|
||||
{-# INLINE formatTestDateL #-}
|
||||
|
||||
-- | 'formatTestDateTime' Lens
|
||||
formatTestDateTimeL :: Lens_' FormatTest (Maybe DateTime)
|
||||
formatTestDateTimeL f FormatTest{..} = (\formatTestDateTime -> FormatTest { formatTestDateTime, ..} ) <$> f formatTestDateTime
|
||||
{-# INLINE formatTestDateTimeL #-}
|
||||
|
||||
-- | 'formatTestUuid' Lens
|
||||
formatTestUuidL :: Lens_' FormatTest (Maybe Text)
|
||||
formatTestUuidL f FormatTest{..} = (\formatTestUuid -> FormatTest { formatTestUuid, ..} ) <$> f formatTestUuid
|
||||
{-# INLINE formatTestUuidL #-}
|
||||
|
||||
-- | 'formatTestPassword' Lens
|
||||
formatTestPasswordL :: Lens_' FormatTest (Text)
|
||||
formatTestPasswordL f FormatTest{..} = (\formatTestPassword -> FormatTest { formatTestPassword, ..} ) <$> f formatTestPassword
|
||||
{-# INLINE formatTestPasswordL #-}
|
||||
|
||||
|
||||
|
||||
-- * HasOnlyReadOnly
|
||||
|
||||
-- | 'hasOnlyReadOnlyBar' Lens
|
||||
hasOnlyReadOnlyBarL :: Lens_' HasOnlyReadOnly (Maybe Text)
|
||||
hasOnlyReadOnlyBarL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyBar -> HasOnlyReadOnly { hasOnlyReadOnlyBar, ..} ) <$> f hasOnlyReadOnlyBar
|
||||
{-# INLINE hasOnlyReadOnlyBarL #-}
|
||||
|
||||
-- | 'hasOnlyReadOnlyFoo' Lens
|
||||
hasOnlyReadOnlyFooL :: Lens_' HasOnlyReadOnly (Maybe Text)
|
||||
hasOnlyReadOnlyFooL f HasOnlyReadOnly{..} = (\hasOnlyReadOnlyFoo -> HasOnlyReadOnly { hasOnlyReadOnlyFoo, ..} ) <$> f hasOnlyReadOnlyFoo
|
||||
{-# INLINE hasOnlyReadOnlyFooL #-}
|
||||
|
||||
|
||||
|
||||
-- * MapTest
|
||||
|
||||
-- | 'mapTestMapMapOfString' Lens
|
||||
mapTestMapMapOfStringL :: Lens_' MapTest (Maybe (Map.Map String (Map.Map String Text)))
|
||||
mapTestMapMapOfStringL f MapTest{..} = (\mapTestMapMapOfString -> MapTest { mapTestMapMapOfString, ..} ) <$> f mapTestMapMapOfString
|
||||
{-# INLINE mapTestMapMapOfStringL #-}
|
||||
|
||||
-- | 'mapTestMapOfEnumString' Lens
|
||||
mapTestMapOfEnumStringL :: Lens_' MapTest (Maybe (Map.Map String E'Inner))
|
||||
mapTestMapOfEnumStringL f MapTest{..} = (\mapTestMapOfEnumString -> MapTest { mapTestMapOfEnumString, ..} ) <$> f mapTestMapOfEnumString
|
||||
{-# INLINE mapTestMapOfEnumStringL #-}
|
||||
|
||||
|
||||
|
||||
-- * MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
-- | 'mixedPropertiesAndAdditionalPropertiesClassUuid' Lens
|
||||
mixedPropertiesAndAdditionalPropertiesClassUuidL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe Text)
|
||||
mixedPropertiesAndAdditionalPropertiesClassUuidL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassUuid -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassUuid
|
||||
{-# INLINE mixedPropertiesAndAdditionalPropertiesClassUuidL #-}
|
||||
|
||||
-- | 'mixedPropertiesAndAdditionalPropertiesClassDateTime' Lens
|
||||
mixedPropertiesAndAdditionalPropertiesClassDateTimeL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe DateTime)
|
||||
mixedPropertiesAndAdditionalPropertiesClassDateTimeL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassDateTime -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassDateTime, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassDateTime
|
||||
{-# INLINE mixedPropertiesAndAdditionalPropertiesClassDateTimeL #-}
|
||||
|
||||
-- | 'mixedPropertiesAndAdditionalPropertiesClassMap' Lens
|
||||
mixedPropertiesAndAdditionalPropertiesClassMapL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe (Map.Map String Animal))
|
||||
mixedPropertiesAndAdditionalPropertiesClassMapL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassMap -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassMap, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassMap
|
||||
{-# INLINE mixedPropertiesAndAdditionalPropertiesClassMapL #-}
|
||||
|
||||
|
||||
|
||||
-- * Model200Response
|
||||
|
||||
-- | 'model200ResponseName' Lens
|
||||
model200ResponseNameL :: Lens_' Model200Response (Maybe Int)
|
||||
model200ResponseNameL f Model200Response{..} = (\model200ResponseName -> Model200Response { model200ResponseName, ..} ) <$> f model200ResponseName
|
||||
{-# INLINE model200ResponseNameL #-}
|
||||
|
||||
-- | 'model200ResponseClass' Lens
|
||||
model200ResponseClassL :: Lens_' Model200Response (Maybe Text)
|
||||
model200ResponseClassL f Model200Response{..} = (\model200ResponseClass -> Model200Response { model200ResponseClass, ..} ) <$> f model200ResponseClass
|
||||
{-# INLINE model200ResponseClassL #-}
|
||||
|
||||
|
||||
|
||||
-- * ModelList
|
||||
|
||||
-- | 'modelList123list' Lens
|
||||
modelList123listL :: Lens_' ModelList (Maybe Text)
|
||||
modelList123listL f ModelList{..} = (\modelList123list -> ModelList { modelList123list, ..} ) <$> f modelList123list
|
||||
{-# INLINE modelList123listL #-}
|
||||
|
||||
|
||||
|
||||
-- * ModelReturn
|
||||
|
||||
-- | 'modelReturnReturn' Lens
|
||||
modelReturnReturnL :: Lens_' ModelReturn (Maybe Int)
|
||||
modelReturnReturnL f ModelReturn{..} = (\modelReturnReturn -> ModelReturn { modelReturnReturn, ..} ) <$> f modelReturnReturn
|
||||
{-# INLINE modelReturnReturnL #-}
|
||||
|
||||
|
||||
|
||||
-- * Name
|
||||
|
||||
-- | 'nameName' Lens
|
||||
nameNameL :: Lens_' Name (Int)
|
||||
nameNameL f Name{..} = (\nameName -> Name { nameName, ..} ) <$> f nameName
|
||||
{-# INLINE nameNameL #-}
|
||||
|
||||
-- | 'nameSnakeCase' Lens
|
||||
nameSnakeCaseL :: Lens_' Name (Maybe Int)
|
||||
nameSnakeCaseL f Name{..} = (\nameSnakeCase -> Name { nameSnakeCase, ..} ) <$> f nameSnakeCase
|
||||
{-# INLINE nameSnakeCaseL #-}
|
||||
|
||||
-- | 'nameProperty' Lens
|
||||
namePropertyL :: Lens_' Name (Maybe Text)
|
||||
namePropertyL f Name{..} = (\nameProperty -> Name { nameProperty, ..} ) <$> f nameProperty
|
||||
{-# INLINE namePropertyL #-}
|
||||
|
||||
-- | 'name123number' Lens
|
||||
name123numberL :: Lens_' Name (Maybe Int)
|
||||
name123numberL f Name{..} = (\name123number -> Name { name123number, ..} ) <$> f name123number
|
||||
{-# INLINE name123numberL #-}
|
||||
|
||||
|
||||
|
||||
-- * NumberOnly
|
||||
|
||||
-- | 'numberOnlyJustNumber' Lens
|
||||
numberOnlyJustNumberL :: Lens_' NumberOnly (Maybe Double)
|
||||
numberOnlyJustNumberL f NumberOnly{..} = (\numberOnlyJustNumber -> NumberOnly { numberOnlyJustNumber, ..} ) <$> f numberOnlyJustNumber
|
||||
{-# INLINE numberOnlyJustNumberL #-}
|
||||
|
||||
|
||||
|
||||
-- * Order
|
||||
|
||||
-- | 'orderId' Lens
|
||||
orderIdL :: Lens_' Order (Maybe Integer)
|
||||
orderIdL f Order{..} = (\orderId -> Order { orderId, ..} ) <$> f orderId
|
||||
{-# INLINE orderIdL #-}
|
||||
|
||||
-- | 'orderPetId' Lens
|
||||
orderPetIdL :: Lens_' Order (Maybe Integer)
|
||||
orderPetIdL f Order{..} = (\orderPetId -> Order { orderPetId, ..} ) <$> f orderPetId
|
||||
{-# INLINE orderPetIdL #-}
|
||||
|
||||
-- | 'orderQuantity' Lens
|
||||
orderQuantityL :: Lens_' Order (Maybe Int)
|
||||
orderQuantityL f Order{..} = (\orderQuantity -> Order { orderQuantity, ..} ) <$> f orderQuantity
|
||||
{-# INLINE orderQuantityL #-}
|
||||
|
||||
-- | 'orderShipDate' Lens
|
||||
orderShipDateL :: Lens_' Order (Maybe DateTime)
|
||||
orderShipDateL f Order{..} = (\orderShipDate -> Order { orderShipDate, ..} ) <$> f orderShipDate
|
||||
{-# INLINE orderShipDateL #-}
|
||||
|
||||
-- | 'orderStatus' Lens
|
||||
orderStatusL :: Lens_' Order (Maybe E'Status)
|
||||
orderStatusL f Order{..} = (\orderStatus -> Order { orderStatus, ..} ) <$> f orderStatus
|
||||
{-# INLINE orderStatusL #-}
|
||||
|
||||
-- | 'orderComplete' Lens
|
||||
orderCompleteL :: Lens_' Order (Maybe Bool)
|
||||
orderCompleteL f Order{..} = (\orderComplete -> Order { orderComplete, ..} ) <$> f orderComplete
|
||||
{-# INLINE orderCompleteL #-}
|
||||
|
||||
|
||||
|
||||
-- * OuterComposite
|
||||
|
||||
-- | 'outerCompositeMyNumber' Lens
|
||||
outerCompositeMyNumberL :: Lens_' OuterComposite (Maybe Double)
|
||||
outerCompositeMyNumberL f OuterComposite{..} = (\outerCompositeMyNumber -> OuterComposite { outerCompositeMyNumber, ..} ) <$> f outerCompositeMyNumber
|
||||
{-# INLINE outerCompositeMyNumberL #-}
|
||||
|
||||
-- | 'outerCompositeMyString' Lens
|
||||
outerCompositeMyStringL :: Lens_' OuterComposite (Maybe Text)
|
||||
outerCompositeMyStringL f OuterComposite{..} = (\outerCompositeMyString -> OuterComposite { outerCompositeMyString, ..} ) <$> f outerCompositeMyString
|
||||
{-# INLINE outerCompositeMyStringL #-}
|
||||
|
||||
-- | 'outerCompositeMyBoolean' Lens
|
||||
outerCompositeMyBooleanL :: Lens_' OuterComposite (Maybe Bool)
|
||||
outerCompositeMyBooleanL f OuterComposite{..} = (\outerCompositeMyBoolean -> OuterComposite { outerCompositeMyBoolean, ..} ) <$> f outerCompositeMyBoolean
|
||||
{-# INLINE outerCompositeMyBooleanL #-}
|
||||
|
||||
|
||||
|
||||
-- * OuterEnum
|
||||
|
||||
|
||||
|
||||
-- * Pet
|
||||
|
||||
-- | 'petId' Lens
|
||||
petIdL :: Lens_' Pet (Maybe Integer)
|
||||
petIdL f Pet{..} = (\petId -> Pet { petId, ..} ) <$> f petId
|
||||
{-# INLINE petIdL #-}
|
||||
|
||||
-- | 'petCategory' Lens
|
||||
petCategoryL :: Lens_' Pet (Maybe Category)
|
||||
petCategoryL f Pet{..} = (\petCategory -> Pet { petCategory, ..} ) <$> f petCategory
|
||||
{-# INLINE petCategoryL #-}
|
||||
|
||||
-- | 'petName' Lens
|
||||
petNameL :: Lens_' Pet (Text)
|
||||
petNameL f Pet{..} = (\petName -> Pet { petName, ..} ) <$> f petName
|
||||
{-# INLINE petNameL #-}
|
||||
|
||||
-- | 'petPhotoUrls' Lens
|
||||
petPhotoUrlsL :: Lens_' Pet ([Text])
|
||||
petPhotoUrlsL f Pet{..} = (\petPhotoUrls -> Pet { petPhotoUrls, ..} ) <$> f petPhotoUrls
|
||||
{-# INLINE petPhotoUrlsL #-}
|
||||
|
||||
-- | 'petTags' Lens
|
||||
petTagsL :: Lens_' Pet (Maybe [Tag])
|
||||
petTagsL f Pet{..} = (\petTags -> Pet { petTags, ..} ) <$> f petTags
|
||||
{-# INLINE petTagsL #-}
|
||||
|
||||
-- | 'petStatus' Lens
|
||||
petStatusL :: Lens_' Pet (Maybe E'Status2)
|
||||
petStatusL f Pet{..} = (\petStatus -> Pet { petStatus, ..} ) <$> f petStatus
|
||||
{-# INLINE petStatusL #-}
|
||||
|
||||
|
||||
|
||||
-- * ReadOnlyFirst
|
||||
|
||||
-- | 'readOnlyFirstBar' Lens
|
||||
readOnlyFirstBarL :: Lens_' ReadOnlyFirst (Maybe Text)
|
||||
readOnlyFirstBarL f ReadOnlyFirst{..} = (\readOnlyFirstBar -> ReadOnlyFirst { readOnlyFirstBar, ..} ) <$> f readOnlyFirstBar
|
||||
{-# INLINE readOnlyFirstBarL #-}
|
||||
|
||||
-- | 'readOnlyFirstBaz' Lens
|
||||
readOnlyFirstBazL :: Lens_' ReadOnlyFirst (Maybe Text)
|
||||
readOnlyFirstBazL f ReadOnlyFirst{..} = (\readOnlyFirstBaz -> ReadOnlyFirst { readOnlyFirstBaz, ..} ) <$> f readOnlyFirstBaz
|
||||
{-# INLINE readOnlyFirstBazL #-}
|
||||
|
||||
|
||||
|
||||
-- * SpecialModelName
|
||||
|
||||
-- | 'specialModelNameSpecialPropertyName' Lens
|
||||
specialModelNameSpecialPropertyNameL :: Lens_' SpecialModelName (Maybe Integer)
|
||||
specialModelNameSpecialPropertyNameL f SpecialModelName{..} = (\specialModelNameSpecialPropertyName -> SpecialModelName { specialModelNameSpecialPropertyName, ..} ) <$> f specialModelNameSpecialPropertyName
|
||||
{-# INLINE specialModelNameSpecialPropertyNameL #-}
|
||||
|
||||
|
||||
|
||||
-- * Tag
|
||||
|
||||
-- | 'tagId' Lens
|
||||
tagIdL :: Lens_' Tag (Maybe Integer)
|
||||
tagIdL f Tag{..} = (\tagId -> Tag { tagId, ..} ) <$> f tagId
|
||||
{-# INLINE tagIdL #-}
|
||||
|
||||
-- | 'tagName' Lens
|
||||
tagNameL :: Lens_' Tag (Maybe Text)
|
||||
tagNameL f Tag{..} = (\tagName -> Tag { tagName, ..} ) <$> f tagName
|
||||
{-# INLINE tagNameL #-}
|
||||
|
||||
|
||||
|
||||
-- * User
|
||||
|
||||
-- | 'userId' Lens
|
||||
userIdL :: Lens_' User (Maybe Integer)
|
||||
userIdL f User{..} = (\userId -> User { userId, ..} ) <$> f userId
|
||||
{-# INLINE userIdL #-}
|
||||
|
||||
-- | 'userUsername' Lens
|
||||
userUsernameL :: Lens_' User (Maybe Text)
|
||||
userUsernameL f User{..} = (\userUsername -> User { userUsername, ..} ) <$> f userUsername
|
||||
{-# INLINE userUsernameL #-}
|
||||
|
||||
-- | 'userFirstName' Lens
|
||||
userFirstNameL :: Lens_' User (Maybe Text)
|
||||
userFirstNameL f User{..} = (\userFirstName -> User { userFirstName, ..} ) <$> f userFirstName
|
||||
{-# INLINE userFirstNameL #-}
|
||||
|
||||
-- | 'userLastName' Lens
|
||||
userLastNameL :: Lens_' User (Maybe Text)
|
||||
userLastNameL f User{..} = (\userLastName -> User { userLastName, ..} ) <$> f userLastName
|
||||
{-# INLINE userLastNameL #-}
|
||||
|
||||
-- | 'userEmail' Lens
|
||||
userEmailL :: Lens_' User (Maybe Text)
|
||||
userEmailL f User{..} = (\userEmail -> User { userEmail, ..} ) <$> f userEmail
|
||||
{-# INLINE userEmailL #-}
|
||||
|
||||
-- | 'userPassword' Lens
|
||||
userPasswordL :: Lens_' User (Maybe Text)
|
||||
userPasswordL f User{..} = (\userPassword -> User { userPassword, ..} ) <$> f userPassword
|
||||
{-# INLINE userPasswordL #-}
|
||||
|
||||
-- | 'userPhone' Lens
|
||||
userPhoneL :: Lens_' User (Maybe Text)
|
||||
userPhoneL f User{..} = (\userPhone -> User { userPhone, ..} ) <$> f userPhone
|
||||
{-# INLINE userPhoneL #-}
|
||||
|
||||
-- | 'userUserStatus' Lens
|
||||
userUserStatusL :: Lens_' User (Maybe Int)
|
||||
userUserStatusL f User{..} = (\userUserStatus -> User { userUserStatus, ..} ) <$> f userUserStatus
|
||||
{-# INLINE userUserStatusL #-}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user