From 9d858277a361033b450ae62adef30697fe3038f3 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Wed, 5 Sep 2018 11:43:50 +0800 Subject: [PATCH 01/10] add hfmt support (without updating the sample) --- .../languages/HaskellHttpClientCodegen.java | 31 + .../petstore/haskell-http-client/README.md | 2 +- .../lib/OpenAPIPetstore.hs | 2 +- .../lib/OpenAPIPetstore/API.hs | 2 +- .../lib/OpenAPIPetstore/API/AnotherFake.hs | 2 +- .../lib/OpenAPIPetstore/API/Fake.hs | 58 +- .../API/FakeClassnameTags123.hs | 2 +- .../lib/OpenAPIPetstore/API/Pet.hs | 2 +- .../lib/OpenAPIPetstore/API/Store.hs | 14 +- .../lib/OpenAPIPetstore/API/User.hs | 50 +- .../lib/OpenAPIPetstore/Client.hs | 2 +- .../lib/OpenAPIPetstore/Core.hs | 2 +- .../lib/OpenAPIPetstore/Logging.hs | 2 +- .../lib/OpenAPIPetstore/MimeTypes.hs | 2 +- .../lib/OpenAPIPetstore/Model.hs | 261 +--- .../lib/OpenAPIPetstore/ModelLens.hs | 146 +-- .../openapi-petstore.cabal | 2 +- .../petstore/haskell-http-client/openapi.yaml | 1046 ++++++++--------- .../haskell-http-client/tests/Instances.hs | 48 - .../haskell-http-client/tests/Test.hs | 6 - 20 files changed, 624 insertions(+), 1058 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index a17db9ebd1e..d4537cacbce 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -24,6 +24,7 @@ import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.security.SecurityScheme; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.tuple.Pair; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; @@ -135,6 +136,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public HaskellHttpClientCodegen() { super(); + if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { + LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=/usr/local/bin/hfmt' (Linux/Mac)"); + } + this.prependFormOrBodyParameters = true; // override the mapping to keep the original mapping in Haskell @@ -1345,4 +1350,30 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC .replace("\\", "\\\\") .replace("\"", "\\\"")); } + + @Override + public void postProcessFile(File file, String fileType) { + if (file == null) { + return; + } + String hfmtPath = System.getenv("HFMT_PATH"); + if (StringUtils.isEmpty(hfmtPath)) { + return; // skip if HFMT_PATH env variable is not defined + } + + // only process files with hs extension + if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { + String command = hfmtPath + " -w " + file.toString(); + try { + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + if (p.exitValue() != 0) { + LOGGER.error("Error running the command ({}): {}", command, p.exitValue()); + } + } catch (Exception e) { + LOGGER.error("Error running the command ({}): {}", command, e.getMessage()); + } + LOGGER.info("Successfully executed: " + command); + } + } } diff --git a/samples/client/petstore/haskell-http-client/README.md b/samples/client/petstore/haskell-http-client/README.md index 89946e86fc6..df8a3631630 100644 --- a/samples/client/petstore/haskell-http-client/README.md +++ b/samples/client/petstore/haskell-http-client/README.md @@ -2,7 +2,7 @@ The library in `lib` provides auto-generated-from-OpenAPI [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the OpenAPI Petstore API. -OpenApi Version: 3.0.0 +OpenApi Version: 3.0.1 ## Installation diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index 4e71ab9e720..83e607b1ad7 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 3c3deada26b..7335a85067e 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index 8ecaa5703a1..aa3b293eb67 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index 51f5f5e51c7..4d73209965f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} @@ -64,19 +64,17 @@ import qualified Prelude as P -- Test serialization of outer boolean types -- fakeOuterBooleanSerialize - :: (Consumes FakeOuterBooleanSerialize MimeJSON) - => Accept accept -- ^ request accept ('MimeType') - -> OpenAPIPetstoreRequest FakeOuterBooleanSerialize MimeJSON Bool accept -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 Body8 - --- | @application/json@ -instance Consumes FakeOuterBooleanSerialize MimeJSON +instance HasBodyParam FakeOuterBooleanSerialize BodyBool -- | @*/*@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype @@ -89,10 +87,11 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype -- Test serialization of object with outer number type -- fakeOuterCompositeSerialize - :: (Consumes FakeOuterCompositeSerialize MimeJSON) - => Accept accept -- ^ request accept ('MimeType') - -> OpenAPIPetstoreRequest FakeOuterCompositeSerialize MimeJSON OuterComposite accept -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 @@ -100,9 +99,6 @@ data FakeOuterCompositeSerialize -- | /Body Param/ "OuterComposite" - Input composite as post body instance HasBodyParam FakeOuterCompositeSerialize OuterComposite --- | @application/json@ -instance Consumes FakeOuterCompositeSerialize MimeJSON - -- | @*/*@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype @@ -114,19 +110,17 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype -- Test serialization of outer number types -- fakeOuterNumberSerialize - :: (Consumes FakeOuterNumberSerialize MimeJSON) - => Accept accept -- ^ request accept ('MimeType') - -> OpenAPIPetstoreRequest FakeOuterNumberSerialize MimeJSON Double accept -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 Body6 - --- | @application/json@ -instance Consumes FakeOuterNumberSerialize MimeJSON +instance HasBodyParam FakeOuterNumberSerialize Body -- | @*/*@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype @@ -139,19 +133,17 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype -- Test serialization of outer string types -- fakeOuterStringSerialize - :: (Consumes FakeOuterStringSerialize MimeJSON) - => Accept accept -- ^ request accept ('MimeType') - -> OpenAPIPetstoreRequest FakeOuterStringSerialize MimeJSON Text accept -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 Body7 - --- | @application/json@ -instance Consumes FakeOuterStringSerialize MimeJSON +instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype @@ -353,7 +345,7 @@ instance HasOptionalParam TestEnumParameters EnumHeaderString where -- | /Optional Param/ "enum_query_string_array" - Query parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumQueryStringArray where applyOptionalParam req (EnumQueryStringArray xs) = - req `setQuery` toQueryColl MultiParamArray ("enum_query_string_array", Just 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 diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index e1776cbfd8b..5719e3c4cd4 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 11c9352c582..7b6de84e74b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index 628da518121..12bcd0bc94a 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} @@ -128,11 +128,12 @@ instance Produces GetOrderById MimeJSON -- Place an order for a pet -- placeOrder - :: (Consumes PlaceOrder MimeJSON, MimeRender MimeJSON Order) - => Accept accept -- ^ request accept ('MimeType') + :: (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 MimeJSON Order accept -placeOrder _ order = + -> OpenAPIPetstoreRequest PlaceOrder contentType Order accept +placeOrder _ _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order @@ -141,9 +142,6 @@ data PlaceOrder -- | /Body Param/ "Order" - order placed for purchasing the pet instance HasBodyParam PlaceOrder Order --- | @application/json@ -instance Consumes PlaceOrder MimeJSON - -- | @application/xml@ instance Produces PlaceOrder MimeXML -- | @application/json@ diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index 76b4963a8f1..efc6ad66f31 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} @@ -66,10 +66,11 @@ import qualified Prelude as P -- This can only be done by the logged in user. -- createUser - :: (Consumes CreateUser MimeJSON, MimeRender MimeJSON User) - => User -- ^ "user" - Created user object - -> OpenAPIPetstoreRequest CreateUser MimeJSON NoContent MimeNoContent -createUser user = + :: (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 @@ -78,9 +79,6 @@ data CreateUser -- | /Body Param/ "User" - Created user object instance HasBodyParam CreateUser User --- | @application/json@ -instance Consumes CreateUser MimeJSON - instance Produces CreateUser MimeNoContent @@ -91,10 +89,11 @@ instance Produces CreateUser MimeNoContent -- Creates list of users with given input array -- createUsersWithArrayInput - :: (Consumes CreateUsersWithArrayInput MimeJSON, MimeRender MimeJSON User2) - => User2 -- ^ "user" - List of user object - -> OpenAPIPetstoreRequest CreateUsersWithArrayInput MimeJSON NoContent MimeNoContent -createUsersWithArrayInput user = + :: (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 @@ -103,9 +102,6 @@ data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object instance HasBodyParam CreateUsersWithArrayInput User2 --- | @application/json@ -instance Consumes CreateUsersWithArrayInput MimeJSON - instance Produces CreateUsersWithArrayInput MimeNoContent @@ -116,10 +112,11 @@ instance Produces CreateUsersWithArrayInput MimeNoContent -- Creates list of users with given input array -- createUsersWithListInput - :: (Consumes CreateUsersWithListInput MimeJSON, MimeRender MimeJSON User2) - => User2 -- ^ "user" - List of user object - -> OpenAPIPetstoreRequest CreateUsersWithListInput MimeJSON NoContent MimeNoContent -createUsersWithListInput user = + :: (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 @@ -128,9 +125,6 @@ data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object instance HasBodyParam CreateUsersWithListInput User2 --- | @application/json@ -instance Consumes CreateUsersWithListInput MimeJSON - instance Produces CreateUsersWithListInput MimeNoContent @@ -223,11 +217,12 @@ instance Produces LogoutUser MimeNoContent -- This can only be done by the logged in user. -- updateUser - :: (Consumes UpdateUser MimeJSON, MimeRender MimeJSON User) - => User -- ^ "user" - Updated user object + :: (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 MimeJSON NoContent MimeNoContent -updateUser user (Username username) = + -> OpenAPIPetstoreRequest UpdateUser contentType NoContent MimeNoContent +updateUser _ user (Username username) = _mkRequest "PUT" ["/user/",toPath username] `setBodyParam` user @@ -236,8 +231,5 @@ data UpdateUser -- | /Body Param/ "User" - Updated user object instance HasBodyParam UpdateUser User --- | @application/json@ -instance Consumes UpdateUser MimeJSON - instance Produces UpdateUser MimeNoContent diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs index d9203a5bd4f..31cd12f7ada 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs index 019f2ce6131..6fbc9899d34 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index 3241dbd85a5..8e3d4ac772b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs index 33b2868d0fa..0da4b6310f0 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index f4a0f43dbad..19b575dd855 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} @@ -72,14 +72,14 @@ newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } -- ** ApiKey newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) --- ** Body6 -newtype Body6 = Body6 { unBody6 :: Double } deriving (P.Eq, P.Show, A.ToJSON) +-- ** Body +newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON) --- ** Body7 -newtype Body7 = Body7 { unBody7 :: Text } deriving (P.Eq, P.Show, A.ToJSON) +-- ** BodyBool +newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON) --- ** Body8 -newtype Body8 = Body8 { unBody8 :: Bool } deriving (P.Eq, P.Show, A.ToJSON) +-- ** BodyText +newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON) -- ** Byte newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) @@ -416,253 +416,6 @@ mkArrayTest = , arrayTestArrayArrayOfModel = Nothing } --- ** Body --- | Body -data Body = Body - { bodyName :: !(Maybe Text) -- ^ "name" - Updated name of the pet - , bodyStatus :: !(Maybe Text) -- ^ "status" - Updated status of the pet - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body -instance A.FromJSON Body where - parseJSON = A.withObject "Body" $ \o -> - Body - <$> (o .:? "name") - <*> (o .:? "status") - --- | ToJSON Body -instance A.ToJSON Body where - toJSON Body {..} = - _omitNulls - [ "name" .= bodyName - , "status" .= bodyStatus - ] - - --- | Construct a value of type 'Body' (by applying it's required fields, if any) -mkBody - :: Body -mkBody = - Body - { bodyName = Nothing - , bodyStatus = Nothing - } - --- ** Body1 --- | Body1 -data Body1 = Body1 - { body1AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server - , body1File :: !(Maybe FilePath) -- ^ "file" - file to upload - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body1 -instance A.FromJSON Body1 where - parseJSON = A.withObject "Body1" $ \o -> - Body1 - <$> (o .:? "additionalMetadata") - <*> (o .:? "file") - --- | ToJSON Body1 -instance A.ToJSON Body1 where - toJSON Body1 {..} = - _omitNulls - [ "additionalMetadata" .= body1AdditionalMetadata - , "file" .= body1File - ] - - --- | Construct a value of type 'Body1' (by applying it's required fields, if any) -mkBody1 - :: Body1 -mkBody1 = - Body1 - { body1AdditionalMetadata = Nothing - , body1File = Nothing - } - --- ** Body2 --- | Body2 -data Body2 = Body2 - { body2EnumFormStringArray :: !(Maybe [E'EnumFormStringArray]) -- ^ "enum_form_string_array" - Form parameter enum test (string array) - , body2EnumFormString :: !(Maybe E'EnumFormString) -- ^ "enum_form_string" - Form parameter enum test (string) - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body2 -instance A.FromJSON Body2 where - parseJSON = A.withObject "Body2" $ \o -> - Body2 - <$> (o .:? "enum_form_string_array") - <*> (o .:? "enum_form_string") - --- | ToJSON Body2 -instance A.ToJSON Body2 where - toJSON Body2 {..} = - _omitNulls - [ "enum_form_string_array" .= body2EnumFormStringArray - , "enum_form_string" .= body2EnumFormString - ] - - --- | Construct a value of type 'Body2' (by applying it's required fields, if any) -mkBody2 - :: Body2 -mkBody2 = - Body2 - { body2EnumFormStringArray = Nothing - , body2EnumFormString = Nothing - } - --- ** Body3 --- | Body3 -data Body3 = Body3 - { body3Integer :: !(Maybe Int) -- ^ "integer" - None - , body3Int32 :: !(Maybe Int) -- ^ "int32" - None - , body3Int64 :: !(Maybe Integer) -- ^ "int64" - None - , body3Number :: !(Double) -- ^ /Required/ "number" - None - , body3Float :: !(Maybe Float) -- ^ "float" - None - , body3Double :: !(Double) -- ^ /Required/ "double" - None - , body3String :: !(Maybe Text) -- ^ "string" - None - , body3PatternWithoutDelimiter :: !(Text) -- ^ /Required/ "pattern_without_delimiter" - None - , body3Byte :: !(ByteArray) -- ^ /Required/ "byte" - None - , body3Binary :: !(Maybe FilePath) -- ^ "binary" - None - , body3Date :: !(Maybe Date) -- ^ "date" - None - , body3DateTime :: !(Maybe DateTime) -- ^ "dateTime" - None - , body3Password :: !(Maybe Text) -- ^ "password" - None - , body3Callback :: !(Maybe Text) -- ^ "callback" - None - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body3 -instance A.FromJSON Body3 where - parseJSON = A.withObject "Body3" $ \o -> - Body3 - <$> (o .:? "integer") - <*> (o .:? "int32") - <*> (o .:? "int64") - <*> (o .: "number") - <*> (o .:? "float") - <*> (o .: "double") - <*> (o .:? "string") - <*> (o .: "pattern_without_delimiter") - <*> (o .: "byte") - <*> (o .:? "binary") - <*> (o .:? "date") - <*> (o .:? "dateTime") - <*> (o .:? "password") - <*> (o .:? "callback") - --- | ToJSON Body3 -instance A.ToJSON Body3 where - toJSON Body3 {..} = - _omitNulls - [ "integer" .= body3Integer - , "int32" .= body3Int32 - , "int64" .= body3Int64 - , "number" .= body3Number - , "float" .= body3Float - , "double" .= body3Double - , "string" .= body3String - , "pattern_without_delimiter" .= body3PatternWithoutDelimiter - , "byte" .= body3Byte - , "binary" .= body3Binary - , "date" .= body3Date - , "dateTime" .= body3DateTime - , "password" .= body3Password - , "callback" .= body3Callback - ] - - --- | Construct a value of type 'Body3' (by applying it's required fields, if any) -mkBody3 - :: Double -- ^ 'body3Number': None - -> Double -- ^ 'body3Double': None - -> Text -- ^ 'body3PatternWithoutDelimiter': None - -> ByteArray -- ^ 'body3Byte': None - -> Body3 -mkBody3 body3Number body3Double body3PatternWithoutDelimiter body3Byte = - Body3 - { body3Integer = Nothing - , body3Int32 = Nothing - , body3Int64 = Nothing - , body3Number - , body3Float = Nothing - , body3Double - , body3String = Nothing - , body3PatternWithoutDelimiter - , body3Byte - , body3Binary = Nothing - , body3Date = Nothing - , body3DateTime = Nothing - , body3Password = Nothing - , body3Callback = Nothing - } - --- ** Body4 --- | Body4 -data Body4 = Body4 - { body4Param :: !(Text) -- ^ /Required/ "param" - field1 - , body4Param2 :: !(Text) -- ^ /Required/ "param2" - field2 - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body4 -instance A.FromJSON Body4 where - parseJSON = A.withObject "Body4" $ \o -> - Body4 - <$> (o .: "param") - <*> (o .: "param2") - --- | ToJSON Body4 -instance A.ToJSON Body4 where - toJSON Body4 {..} = - _omitNulls - [ "param" .= body4Param - , "param2" .= body4Param2 - ] - - --- | Construct a value of type 'Body4' (by applying it's required fields, if any) -mkBody4 - :: Text -- ^ 'body4Param': field1 - -> Text -- ^ 'body4Param2': field2 - -> Body4 -mkBody4 body4Param body4Param2 = - Body4 - { body4Param - , body4Param2 - } - --- ** Body5 --- | Body5 -data Body5 = Body5 - { body5AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server - , body5RequiredFile :: !(FilePath) -- ^ /Required/ "requiredFile" - file to upload - } deriving (P.Show, P.Eq, P.Typeable) - --- | FromJSON Body5 -instance A.FromJSON Body5 where - parseJSON = A.withObject "Body5" $ \o -> - Body5 - <$> (o .:? "additionalMetadata") - <*> (o .: "requiredFile") - --- | ToJSON Body5 -instance A.ToJSON Body5 where - toJSON Body5 {..} = - _omitNulls - [ "additionalMetadata" .= body5AdditionalMetadata - , "requiredFile" .= body5RequiredFile - ] - - --- | Construct a value of type 'Body5' (by applying it's required fields, if any) -mkBody5 - :: FilePath -- ^ 'body5RequiredFile': file to upload - -> Body5 -mkBody5 body5RequiredFile = - Body5 - { body5AdditionalMetadata = Nothing - , body5RequiredFile - } - -- ** Capitalization -- | Capitalization data Capitalization = Capitalization diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index 317dbe109c8..2fd47679ee3 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -3,7 +3,7 @@ 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.0 + OpenAPI Version: 3.0.1 OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} @@ -124,150 +124,6 @@ arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> Ar --- * Body - --- | 'bodyName' Lens -bodyNameL :: Lens_' Body (Maybe Text) -bodyNameL f Body{..} = (\bodyName -> Body { bodyName, ..} ) <$> f bodyName -{-# INLINE bodyNameL #-} - --- | 'bodyStatus' Lens -bodyStatusL :: Lens_' Body (Maybe Text) -bodyStatusL f Body{..} = (\bodyStatus -> Body { bodyStatus, ..} ) <$> f bodyStatus -{-# INLINE bodyStatusL #-} - - - --- * Body1 - --- | 'body1AdditionalMetadata' Lens -body1AdditionalMetadataL :: Lens_' Body1 (Maybe Text) -body1AdditionalMetadataL f Body1{..} = (\body1AdditionalMetadata -> Body1 { body1AdditionalMetadata, ..} ) <$> f body1AdditionalMetadata -{-# INLINE body1AdditionalMetadataL #-} - --- | 'body1File' Lens -body1FileL :: Lens_' Body1 (Maybe FilePath) -body1FileL f Body1{..} = (\body1File -> Body1 { body1File, ..} ) <$> f body1File -{-# INLINE body1FileL #-} - - - --- * Body2 - --- | 'body2EnumFormStringArray' Lens -body2EnumFormStringArrayL :: Lens_' Body2 (Maybe [E'EnumFormStringArray]) -body2EnumFormStringArrayL f Body2{..} = (\body2EnumFormStringArray -> Body2 { body2EnumFormStringArray, ..} ) <$> f body2EnumFormStringArray -{-# INLINE body2EnumFormStringArrayL #-} - --- | 'body2EnumFormString' Lens -body2EnumFormStringL :: Lens_' Body2 (Maybe E'EnumFormString) -body2EnumFormStringL f Body2{..} = (\body2EnumFormString -> Body2 { body2EnumFormString, ..} ) <$> f body2EnumFormString -{-# INLINE body2EnumFormStringL #-} - - - --- * Body3 - --- | 'body3Integer' Lens -body3IntegerL :: Lens_' Body3 (Maybe Int) -body3IntegerL f Body3{..} = (\body3Integer -> Body3 { body3Integer, ..} ) <$> f body3Integer -{-# INLINE body3IntegerL #-} - --- | 'body3Int32' Lens -body3Int32L :: Lens_' Body3 (Maybe Int) -body3Int32L f Body3{..} = (\body3Int32 -> Body3 { body3Int32, ..} ) <$> f body3Int32 -{-# INLINE body3Int32L #-} - --- | 'body3Int64' Lens -body3Int64L :: Lens_' Body3 (Maybe Integer) -body3Int64L f Body3{..} = (\body3Int64 -> Body3 { body3Int64, ..} ) <$> f body3Int64 -{-# INLINE body3Int64L #-} - --- | 'body3Number' Lens -body3NumberL :: Lens_' Body3 (Double) -body3NumberL f Body3{..} = (\body3Number -> Body3 { body3Number, ..} ) <$> f body3Number -{-# INLINE body3NumberL #-} - --- | 'body3Float' Lens -body3FloatL :: Lens_' Body3 (Maybe Float) -body3FloatL f Body3{..} = (\body3Float -> Body3 { body3Float, ..} ) <$> f body3Float -{-# INLINE body3FloatL #-} - --- | 'body3Double' Lens -body3DoubleL :: Lens_' Body3 (Double) -body3DoubleL f Body3{..} = (\body3Double -> Body3 { body3Double, ..} ) <$> f body3Double -{-# INLINE body3DoubleL #-} - --- | 'body3String' Lens -body3StringL :: Lens_' Body3 (Maybe Text) -body3StringL f Body3{..} = (\body3String -> Body3 { body3String, ..} ) <$> f body3String -{-# INLINE body3StringL #-} - --- | 'body3PatternWithoutDelimiter' Lens -body3PatternWithoutDelimiterL :: Lens_' Body3 (Text) -body3PatternWithoutDelimiterL f Body3{..} = (\body3PatternWithoutDelimiter -> Body3 { body3PatternWithoutDelimiter, ..} ) <$> f body3PatternWithoutDelimiter -{-# INLINE body3PatternWithoutDelimiterL #-} - --- | 'body3Byte' Lens -body3ByteL :: Lens_' Body3 (ByteArray) -body3ByteL f Body3{..} = (\body3Byte -> Body3 { body3Byte, ..} ) <$> f body3Byte -{-# INLINE body3ByteL #-} - --- | 'body3Binary' Lens -body3BinaryL :: Lens_' Body3 (Maybe FilePath) -body3BinaryL f Body3{..} = (\body3Binary -> Body3 { body3Binary, ..} ) <$> f body3Binary -{-# INLINE body3BinaryL #-} - --- | 'body3Date' Lens -body3DateL :: Lens_' Body3 (Maybe Date) -body3DateL f Body3{..} = (\body3Date -> Body3 { body3Date, ..} ) <$> f body3Date -{-# INLINE body3DateL #-} - --- | 'body3DateTime' Lens -body3DateTimeL :: Lens_' Body3 (Maybe DateTime) -body3DateTimeL f Body3{..} = (\body3DateTime -> Body3 { body3DateTime, ..} ) <$> f body3DateTime -{-# INLINE body3DateTimeL #-} - --- | 'body3Password' Lens -body3PasswordL :: Lens_' Body3 (Maybe Text) -body3PasswordL f Body3{..} = (\body3Password -> Body3 { body3Password, ..} ) <$> f body3Password -{-# INLINE body3PasswordL #-} - --- | 'body3Callback' Lens -body3CallbackL :: Lens_' Body3 (Maybe Text) -body3CallbackL f Body3{..} = (\body3Callback -> Body3 { body3Callback, ..} ) <$> f body3Callback -{-# INLINE body3CallbackL #-} - - - --- * Body4 - --- | 'body4Param' Lens -body4ParamL :: Lens_' Body4 (Text) -body4ParamL f Body4{..} = (\body4Param -> Body4 { body4Param, ..} ) <$> f body4Param -{-# INLINE body4ParamL #-} - --- | 'body4Param2' Lens -body4Param2L :: Lens_' Body4 (Text) -body4Param2L f Body4{..} = (\body4Param2 -> Body4 { body4Param2, ..} ) <$> f body4Param2 -{-# INLINE body4Param2L #-} - - - --- * Body5 - --- | 'body5AdditionalMetadata' Lens -body5AdditionalMetadataL :: Lens_' Body5 (Maybe Text) -body5AdditionalMetadataL f Body5{..} = (\body5AdditionalMetadata -> Body5 { body5AdditionalMetadata, ..} ) <$> f body5AdditionalMetadata -{-# INLINE body5AdditionalMetadataL #-} - --- | 'body5RequiredFile' Lens -body5RequiredFileL :: Lens_' Body5 (FilePath) -body5RequiredFileL f Body5{..} = (\body5RequiredFile -> Body5 { body5RequiredFile, ..} ) <$> f body5RequiredFile -{-# INLINE body5RequiredFileL #-} - - - -- * Capitalization -- | 'capitalizationSmallCamel' Lens diff --git a/samples/client/petstore/haskell-http-client/openapi-petstore.cabal b/samples/client/petstore/haskell-http-client/openapi-petstore.cabal index 456867d6512..a4c4bbb6e9f 100644 --- a/samples/client/petstore/haskell-http-client/openapi-petstore.cabal +++ b/samples/client/petstore/haskell-http-client/openapi-petstore.cabal @@ -10,7 +10,7 @@ description: . . OpenAPI Petstore API version: 1.0.0 . - OpenAPI version: 3.0.0 + OpenAPI version: 3.0.1 . category: Web homepage: https://openapi-generator.tech diff --git a/samples/client/petstore/haskell-http-client/openapi.yaml b/samples/client/petstore/haskell-http-client/openapi.yaml index 688703b430a..1ccb557da3b 100644 --- a/samples/client/petstore/haskell-http-client/openapi.yaml +++ b/samples/client/petstore/haskell-http-client/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.0.0 +openapi: 3.0.1 info: description: 'This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: @@ -22,9 +22,18 @@ paths: post: operationId: addPet requestBody: - $ref: '#/components/requestBodies/Pet' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true responses: 405: + content: {} description: Invalid input security: - petstore_auth: @@ -36,13 +45,24 @@ paths: put: operationId: updatePet requestBody: - $ref: '#/components/requestBodies/Pet' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true responses: 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found 405: + content: {} description: Validation exception security: - petstore_auth: @@ -86,6 +106,7 @@ paths: type: array description: successful operation 400: + content: {} description: Invalid status value security: - petstore_auth: @@ -125,6 +146,7 @@ paths: type: array description: successful operation 400: + content: {} description: Invalid tag value security: - petstore_auth: @@ -137,24 +159,20 @@ paths: delete: operationId: deletePet parameters: - - explode: false - in: header + - in: header name: api_key - required: false schema: type: string - style: simple - description: Pet id to delete - explode: false in: path name: petId required: true schema: format: int64 type: integer - style: simple responses: 400: + content: {} description: Invalid pet value security: - petstore_auth: @@ -168,14 +186,12 @@ paths: operationId: getPetById parameters: - description: ID of pet to return - explode: false in: path name: petId required: true schema: format: int64 type: integer - style: simple responses: 200: content: @@ -187,8 +203,10 @@ paths: $ref: '#/components/schemas/Pet' description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found security: - api_key: [] @@ -199,21 +217,26 @@ paths: operationId: updatePetWithForm parameters: - description: ID of pet that needs to be updated - explode: false in: path name: petId required: true schema: format: int64 type: integer - style: simple requestBody: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body' + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string responses: 405: + content: {} description: Invalid input security: - petstore_auth: @@ -227,19 +250,24 @@ paths: operationId: uploadFile parameters: - description: ID of pet to update - explode: false in: path name: petId required: true schema: format: int64 type: integer - style: simple requestBody: content: multipart/form-data: schema: - $ref: '#/components/schemas/body_1' + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string responses: 200: content: @@ -278,7 +306,7 @@ paths: operationId: placeOrder requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/Order' description: order placed for purchasing the pet @@ -294,6 +322,7 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: + content: {} description: Invalid Order summary: Place an order for a pet tags: @@ -304,17 +333,17 @@ paths: operationId: deleteOrder parameters: - description: ID of the order that needs to be deleted - explode: false in: path name: order_id required: true schema: type: string - style: simple responses: 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Order not found summary: Delete purchase order by ID tags: @@ -324,7 +353,6 @@ paths: operationId: getOrderById parameters: - description: ID of pet that needs to be fetched - explode: false in: path name: order_id required: true @@ -333,7 +361,6 @@ paths: maximum: 5 minimum: 1 type: integer - style: simple responses: 200: content: @@ -345,8 +372,10 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Order not found summary: Find purchase order by ID tags: @@ -357,13 +386,14 @@ paths: operationId: createUser requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' description: Created user object required: true responses: default: + content: {} description: successful operation summary: Create user tags: @@ -372,9 +402,17 @@ paths: post: operationId: createUsersWithArrayInput requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation summary: Creates list of users with given input array tags: @@ -383,9 +421,17 @@ paths: post: operationId: createUsersWithListInput requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation summary: Creates list of users with given input array tags: @@ -395,21 +441,17 @@ paths: operationId: loginUser parameters: - description: The user name for login - explode: true in: query name: username required: true schema: type: string - style: form - description: The password for login in clear text - explode: true in: query name: password required: true schema: type: string - style: form responses: 200: content: @@ -423,19 +465,16 @@ paths: headers: X-Rate-Limit: description: calls per hour allowed by the user - explode: false schema: format: int32 type: integer - style: simple X-Expires-After: description: date in UTC when token expires - explode: false schema: format: date-time type: string - style: simple 400: + content: {} description: Invalid username/password supplied summary: Logs user into the system tags: @@ -445,6 +484,7 @@ paths: operationId: logoutUser responses: default: + content: {} description: successful operation summary: Logs out current logged in user session tags: @@ -455,17 +495,17 @@ paths: operationId: deleteUser parameters: - description: The name that needs to be deleted - explode: false in: path name: username required: true schema: type: string - style: simple responses: 400: + content: {} description: Invalid username supplied 404: + content: {} description: User not found summary: Delete user tags: @@ -474,13 +514,11 @@ paths: operationId: getUserByName parameters: - description: The name that needs to be fetched. Use user1 for testing. - explode: false in: path name: username required: true schema: type: string - style: simple responses: 200: content: @@ -492,8 +530,10 @@ paths: $ref: '#/components/schemas/User' description: successful operation 400: + content: {} description: Invalid username supplied 404: + content: {} description: User not found summary: Get user by user name tags: @@ -503,24 +543,24 @@ paths: operationId: updateUser parameters: - description: name that need to be deleted - explode: false in: path name: username required: true schema: type: string - style: simple requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' description: Updated user object required: true responses: 400: + content: {} description: Invalid user supplied 404: + content: {} description: User not found summary: Updated user tags: @@ -530,7 +570,12 @@ paths: description: To test class name in snake case operationId: testClassname requestBody: - $ref: '#/components/requestBodies/Client' + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true responses: 200: content: @@ -552,7 +597,6 @@ paths: explode: false in: header name: enum_header_string_array - required: false schema: items: default: $ @@ -563,10 +607,8 @@ paths: type: array style: simple - description: Header parameter enum test (string) - explode: false in: header name: enum_header_string - required: false schema: default: -efg enum: @@ -574,12 +616,10 @@ paths: - -efg - (xyz) type: string - style: simple - description: Query parameter enum test (string array) - explode: true + explode: false in: query name: enum_query_string_array - required: false schema: items: default: $ @@ -590,10 +630,8 @@ paths: type: array style: form - description: Query parameter enum test (string) - explode: true in: query name: enum_query_string - required: false schema: default: -efg enum: @@ -601,40 +639,52 @@ paths: - -efg - (xyz) type: string - style: form - description: Query parameter enum test (double) - explode: true in: query name: enum_query_integer - required: false schema: enum: - 1 - -2 format: int32 type: integer - style: form - description: Query parameter enum test (double) - explode: true in: query name: enum_query_double - required: false schema: enum: - 1.1 - -1.2 format: double type: number - style: form requestBody: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body_2' + properties: + enum_form_string_array: + description: Form parameter enum test (string array) + items: + default: $ + enum: + - '>' + - $ + type: string + type: array + enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string responses: 400: + content: {} description: Invalid request 404: + content: {} description: Not found summary: To test enum parameters tags: @@ -643,7 +693,12 @@ paths: description: To test "client" model operationId: testClientModel requestBody: - $ref: '#/components/requestBodies/Client' + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true responses: 200: content: @@ -665,11 +720,83 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body_3' + properties: + integer: + description: None + maximum: 100 + minimum: 10 + type: integer + int32: + description: None + format: int32 + maximum: 200 + minimum: 20 + type: integer + int64: + description: None + format: int64 + type: integer + number: + description: None + maximum: 543.2 + minimum: 32.1 + type: number + float: + description: None + format: float + maximum: 987.6 + type: number + double: + description: None + format: double + maximum: 123.4 + minimum: 67.8 + type: number + string: + description: None + pattern: /[a-z]/i + type: string + pattern_without_delimiter: + description: None + pattern: ^[A-Z].* + type: string + byte: + description: None + format: byte + type: string + binary: + description: None + format: binary + type: string + date: + description: None + format: date + type: string + dateTime: + description: None + format: date-time + type: string + password: + description: None + format: password + maxLength: 64 + minLength: 10 + type: string + callback: + description: None + type: string + required: + - byte + - double + - number + - pattern_without_delimiter + required: true responses: 400: + content: {} description: Invalid username supplied 404: + content: {} description: User not found security: - http_basic_test: [] @@ -686,10 +813,11 @@ paths: operationId: fakeOuterNumberSerialize requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/OuterNumber' description: Input number as post body + required: false responses: 200: content: @@ -705,10 +833,11 @@ paths: operationId: fakeOuterStringSerialize requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/OuterString' description: Input string as post body + required: false responses: 200: content: @@ -724,10 +853,11 @@ paths: operationId: fakeOuterBooleanSerialize requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/OuterBoolean' description: Input boolean as post body + required: false responses: 200: content: @@ -743,10 +873,11 @@ paths: operationId: fakeOuterCompositeSerialize requestBody: content: - application/json: + '*/*': schema: $ref: '#/components/schemas/OuterComposite' description: Input composite as post body + required: false responses: 200: content: @@ -763,9 +894,20 @@ paths: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body_4' + properties: + param: + description: field1 + type: string + param2: + description: field2 + type: string + required: + - param + - param2 + required: true responses: 200: + content: {} description: successful operation summary: test json serialization of form data tags: @@ -784,6 +926,7 @@ paths: required: true responses: 200: + content: {} description: successful operation summary: test inline additionalProperties tags: @@ -792,13 +935,11 @@ paths: put: operationId: testBodyWithQueryParams parameters: - - explode: true - in: query + - in: query name: query required: true schema: type: string - style: form requestBody: content: application/json: @@ -807,6 +948,7 @@ paths: required: true responses: 200: + content: {} description: Success tags: - fake @@ -815,7 +957,12 @@ paths: description: To test special tags and operation ID starting with number operationId: 123_test_@#$%_special_tags requestBody: - $ref: '#/components/requestBodies/Client' + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + description: client model + required: true responses: 200: content: @@ -838,6 +985,7 @@ paths: required: true responses: 200: + content: {} description: Success tags: - fake @@ -846,19 +994,27 @@ paths: operationId: uploadFileWithRequiredFile parameters: - description: ID of pet to update - explode: false in: path name: petId required: true schema: format: int64 type: integer - style: simple requestBody: content: multipart/form-data: schema: - $ref: '#/components/schemas/body_5' + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + requiredFile: + description: file to upload + format: binary + type: string + required: + - requiredFile + required: true responses: 200: content: @@ -874,68 +1030,7 @@ paths: tags: - pet components: - requestBodies: - UserArray: - content: - application/json: - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true - Client: - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - description: client model - required: true - Pet: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true schemas: - Order: - example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed - properties: - id: - format: int64 - type: integer - petId: - format: int64 - type: integer - quantity: - format: int32 - type: integer - shipDate: - format: date-time - type: string - status: - description: Order Status - enum: - - placed - - approved - - delivered - type: string - complete: - default: false - type: boolean - type: object - xml: - name: Order Category: example: name: name @@ -983,72 +1078,45 @@ components: type: object xml: name: User - Tag: - example: - name: name - id: 1 + OuterNumber: + type: number + ArrayOfNumberOnly: properties: - id: - format: int64 - type: integer - name: + ArrayNumber: + items: + type: number + type: array + type: object + Capitalization: + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + description: | + Name of the pet type: string type: object - xml: - name: Tag - Pet: - example: - photoUrls: - - photoUrls - - photoUrls - name: doggie - id: 0 - category: - name: name - id: 6 - tags: - - name: name - id: 1 - - name: name - id: 1 - status: available + MixedPropertiesAndAdditionalPropertiesClass: properties: - id: - format: int64 - type: integer - x-is-unique: true - category: - $ref: '#/components/schemas/Category' - name: - example: doggie + uuid: + format: uuid type: string - photoUrls: - items: - type: string - type: array - xml: - name: photoUrl - wrapped: true - tags: - items: - $ref: '#/components/schemas/Tag' - type: array - xml: - name: tag - wrapped: true - status: - description: pet status in the store - enum: - - available - - pending - - sold + dateTime: + format: date-time type: string - required: - - name - - photoUrls + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object type: object - xml: - name: Pet ApiResponse: example: code: 0 @@ -1063,14 +1131,6 @@ components: message: type: string type: object - Return: - description: Model for testing reserved words - properties: - return: - format: int32 - type: integer - xml: - name: Return Name: description: Model for testing model name same as property name properties: @@ -1084,13 +1144,30 @@ components: property: type: string 123Number: - format: int32 readOnly: true type: integer required: - name + type: object xml: name: Name + EnumClass: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + List: + properties: + 123-list: + type: string + type: object + NumberOnly: + properties: + JustNumber: + type: number + type: object 200_response: description: Model for testing model name starting with number properties: @@ -1099,13 +1176,16 @@ components: type: integer class: type: string + type: object xml: name: Name - ClassModel: - description: Model for testing model with "_class" property + Client: + example: + client: client properties: - _class: + client: type: string + type: object Dog: allOf: - $ref: '#/components/schemas/Animal' @@ -1113,94 +1193,6 @@ components: breed: type: string type: object - Cat: - allOf: - - $ref: '#/components/schemas/Animal' - - properties: - declawed: - type: boolean - type: object - Animal: - discriminator: - propertyName: className - properties: - className: - type: string - color: - default: red - type: string - required: - - className - type: object - AnimalFarm: - items: - $ref: '#/components/schemas/Animal' - type: array - format_test: - properties: - integer: - format: int32 - maximum: 100 - minimum: 10 - type: integer - int32: - format: int32 - maximum: 200 - minimum: 20 - type: integer - int64: - format: int64 - type: integer - number: - maximum: 543.2 - minimum: 32.1 - type: number - float: - format: float - maximum: 987.6 - minimum: 54.3 - type: number - double: - format: double - maximum: 123.4 - minimum: 67.8 - type: number - string: - pattern: /[a-z]/i - type: string - byte: - format: byte - type: string - binary: - format: binary - type: string - date: - format: date - type: string - dateTime: - format: date-time - type: string - uuid: - format: uuid - type: string - password: - format: password - maxLength: 64 - minLength: 10 - type: string - required: - - byte - - date - - number - - password - type: object - EnumClass: - default: -efg - enum: - - _abc - - -efg - - (xyz) - type: string Enum_Test: properties: enum_string: @@ -1232,6 +1224,40 @@ components: required: - enum_string_required type: object + Order: + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + type: object + xml: + name: Order AdditionalPropertiesClass: properties: map_property: @@ -1245,31 +1271,23 @@ components: type: object type: object type: object - MixedPropertiesAndAdditionalPropertiesClass: + $special[model.name]: properties: - uuid: - format: uuid - type: string - dateTime: - format: date-time - type: string - map: - additionalProperties: - $ref: '#/components/schemas/Animal' - type: object - type: object - List: - properties: - 123-list: - type: string + $special[property.name]: + format: int64 + type: integer type: object - Client: - example: - client: client + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words properties: - client: - type: string + return: + format: int32 + type: integer type: object + xml: + name: Return ReadOnlyFirst: properties: bar: @@ -1278,54 +1296,21 @@ components: baz: type: string type: object - hasOnlyReadOnly: - properties: - bar: - readOnly: true - type: string - foo: - readOnly: true - type: string - type: object - Capitalization: - properties: - smallCamel: - type: string - CapitalCamel: - type: string - small_Snake: - type: string - Capital_Snake: - type: string - SCA_ETH_Flow_Points: - type: string - ATT_NAME: - description: | - Name of the pet - type: string - type: object - MapTest: + ArrayOfArrayOfNumberOnly: properties: - map_map_of_string: - additionalProperties: - additionalProperties: - type: string - type: object - type: object - map_of_enum_string: - additionalProperties: - enum: - - UPPER - - lower - type: string - type: object - direct_map: - additionalProperties: - type: boolean - type: object - indirect_map: - $ref: '#/components/schemas/StringBooleanMap' + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string ArrayTest: properties: array_of_string: @@ -1346,48 +1331,6 @@ components: type: array type: array type: object - NumberOnly: - properties: - JustNumber: - type: number - type: object - ArrayOfNumberOnly: - properties: - ArrayNumber: - items: - type: number - type: array - type: object - ArrayOfArrayOfNumberOnly: - properties: - ArrayArrayNumber: - items: - items: - type: number - type: array - type: array - type: object - EnumArrays: - properties: - just_symbol: - enum: - - '>=' - - $ - type: string - array_enum: - items: - enum: - - fish - - crab - type: string - type: array - type: object - OuterEnum: - enum: - - placed - - approved - - delivered - type: string OuterComposite: example: my_string: my_string @@ -1402,182 +1345,237 @@ components: type: boolean x-codegen-body-parameter-name: boolean_post_body type: object - OuterNumber: - type: number - OuterString: - type: string - OuterBoolean: - type: boolean - x-codegen-body-parameter-name: boolean_post_body - StringBooleanMap: - additionalProperties: - type: boolean - FileSchemaTestClass: - example: - file: - sourceURI: sourceURI - files: - - sourceURI: sourceURI - - sourceURI: sourceURI - properties: - file: - $ref: '#/components/schemas/File' - files: - items: - $ref: '#/components/schemas/File' - type: array - type: object - File: - description: Must be named `File` for test. - example: - sourceURI: sourceURI - properties: - sourceURI: - description: Test capitalization - type: string - type: object - _special_model.name_: - properties: - $special[property.name]: - format: int64 - type: integer - xml: - name: $special[model.name] - body: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string - type: object - body_1: - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - file: - description: file to upload - format: binary - type: string - type: object - body_2: - properties: - enum_form_string_array: - description: Form parameter enum test (string array) - items: - default: $ - enum: - - '>' - - $ - type: string - type: array - enum_form_string: - default: -efg - description: Form parameter enum test (string) - enum: - - _abc - - -efg - - (xyz) - type: string - type: object - body_3: + format_test: properties: integer: - description: None - format: int32 - maximum: 100 - minimum: 10 + maximum: 1E+2 + minimum: 1E+1 type: integer int32: - description: None format: int32 - maximum: 200 - minimum: 20 + maximum: 2E+2 + minimum: 2E+1 type: integer int64: - description: None format: int64 type: integer number: - description: None maximum: 543.2 minimum: 32.1 type: number float: - description: None format: float maximum: 987.6 + minimum: 54.3 type: number double: - description: None format: double maximum: 123.4 minimum: 67.8 type: number string: - description: None pattern: /[a-z]/i type: string - pattern_without_delimiter: - description: None - pattern: ^[A-Z].* - type: string byte: - description: None format: byte + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ type: string binary: - description: None format: binary type: string date: - description: None format: date type: string dateTime: - description: None format: date-time type: string + uuid: + format: uuid + type: string password: - description: None format: password maxLength: 64 minLength: 10 type: string - callback: - description: None - type: string required: - byte - - double + - date - number - - pattern_without_delimiter + - password + type: object + EnumArrays: + properties: + just_symbol: + enum: + - '>=' + - $ + type: string + array_enum: + items: + enum: + - fish + - crab + type: string + type: array + type: object + OuterString: + type: string + ClassModel: + description: Model for testing model with "_class" property + properties: + _class: + type: string type: object - body_4: + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + FileSchemaTestClass: + example: + file: + sourceURI: sourceURI + files: + - sourceURI: sourceURI + - sourceURI: sourceURI properties: - param: - description: field1 + file: + $ref: '#/components/schemas/File' + files: + items: + $ref: '#/components/schemas/File' + type: array + type: object + Animal: + discriminator: + propertyName: className + properties: + className: type: string - param2: - description: field2 + color: + default: red type: string required: - - param - - param2 + - className + type: object + StringBooleanMap: + additionalProperties: + type: boolean + type: object + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - properties: + declawed: + type: boolean + type: object + MapTest: + properties: + map_map_of_string: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + map_of_enum_string: + additionalProperties: + enum: + - UPPER + - lower + type: string + type: object + direct_map: + additionalProperties: + type: boolean + type: object + indirect_map: + $ref: '#/components/schemas/StringBooleanMap' type: object - body_5: + Tag: + example: + name: name + id: 1 properties: - additionalMetadata: - description: Additional data to pass to server + id: + format: int64 + type: integer + name: type: string - requiredFile: - description: file to upload - format: binary + type: object + xml: + name: Tag + AnimalFarm: + items: + $ref: '#/components/schemas/Animal' + type: array + File: + description: Must be named `File` for test. + example: + sourceURI: sourceURI + properties: + sourceURI: + description: Test capitalization + type: string + type: object + Pet: + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available + properties: + id: + format: int64 + type: integer + x-is-unique: true + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold type: string required: - - requiredFile + - name + - photoUrls + type: object + xml: + name: Pet + hasOnlyReadOnly: + properties: + bar: + readOnly: true + type: string + foo: + readOnly: true + type: string type: object securitySchemes: petstore_auth: @@ -1588,6 +1586,9 @@ components: write:pets: modify pets in your account read:pets: read your pets type: oauth2 + http_basic_test: + scheme: basic + type: http api_key: in: header name: api_key @@ -1596,6 +1597,3 @@ components: in: query name: api_key_query type: apiKey - http_basic_test: - scheme: basic - type: http diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 6e54830ccfa..14cef8e188c 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -130,54 +130,6 @@ instance Arbitrary ArrayTest where <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] -instance Arbitrary Body where - arbitrary = - Body - <$> arbitrary -- bodyName :: Maybe Text - <*> arbitrary -- bodyStatus :: Maybe Text - -instance Arbitrary Body1 where - arbitrary = - Body1 - <$> arbitrary -- body1AdditionalMetadata :: Maybe Text - <*> arbitrary -- body1File :: Maybe FilePath - -instance Arbitrary Body2 where - arbitrary = - Body2 - <$> arbitrary -- body2EnumFormStringArray :: Maybe [Text] - <*> arbitrary -- body2EnumFormString :: Maybe Text - -instance Arbitrary Body3 where - arbitrary = - Body3 - <$> arbitrary -- body3Integer :: Maybe Int - <*> arbitrary -- body3Int32 :: Maybe Int - <*> arbitrary -- body3Int64 :: Maybe Integer - <*> arbitrary -- body3Number :: Double - <*> arbitrary -- body3Float :: Maybe Float - <*> arbitrary -- body3Double :: Double - <*> arbitrary -- body3String :: Maybe Text - <*> arbitrary -- body3PatternWithoutDelimiter :: Text - <*> arbitrary -- body3Byte :: ByteArray - <*> arbitrary -- body3Binary :: Maybe FilePath - <*> arbitrary -- body3Date :: Maybe Date - <*> arbitrary -- body3DateTime :: Maybe DateTime - <*> arbitrary -- body3Password :: Maybe Text - <*> arbitrary -- body3Callback :: Maybe Text - -instance Arbitrary Body4 where - arbitrary = - Body4 - <$> arbitrary -- body4Param :: Text - <*> arbitrary -- body4Param2 :: Text - -instance Arbitrary Body5 where - arbitrary = - Body5 - <$> arbitrary -- body5AdditionalMetadata :: Maybe Text - <*> arbitrary -- body5RequiredFile :: FilePath - instance Arbitrary Capitalization where arbitrary = Capitalization diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index ee6483020f4..ea6fff251e3 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -27,12 +27,6 @@ main = propMimeEq MimeJSON (Proxy :: Proxy ArrayOfArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayTest) - propMimeEq MimeJSON (Proxy :: Proxy Body) - propMimeEq MimeJSON (Proxy :: Proxy Body1) - propMimeEq MimeJSON (Proxy :: Proxy Body2) - propMimeEq MimeJSON (Proxy :: Proxy Body3) - propMimeEq MimeJSON (Proxy :: Proxy Body4) - propMimeEq MimeJSON (Proxy :: Proxy Body5) propMimeEq MimeJSON (Proxy :: Proxy Capitalization) propMimeEq MimeJSON (Proxy :: Proxy Cat) propMimeEq MimeJSON (Proxy :: Proxy Category) -- GitLab From dfdde0b8b82ecdb1989fb5493e5c59c19e1685cf Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Wed, 5 Sep 2018 12:01:14 +0800 Subject: [PATCH 02/10] update haskell httpclient samples with hfmt --- .../languages/HaskellHttpClientCodegen.java | 2 +- .../petstore/haskell-http-client/Setup.hs | 3 +- .../lib/OpenAPIPetstore.hs | 18 +- .../lib/OpenAPIPetstore/API.hs | 14 +- .../lib/OpenAPIPetstore/API/AnotherFake.hs | 102 +- .../lib/OpenAPIPetstore/API/Fake.hs | 320 ++-- .../API/FakeClassnameTags123.hs | 107 +- .../lib/OpenAPIPetstore/API/Pet.hs | 296 ++- .../lib/OpenAPIPetstore/API/Store.hs | 157 +- .../lib/OpenAPIPetstore/API/User.hs | 230 ++- .../lib/OpenAPIPetstore/Logging.hs | 52 +- .../lib/OpenAPIPetstore/Model.hs | 1609 ++++++++--------- .../lib/OpenAPIPetstore/ModelLens.hs | 700 +++---- .../haskell-http-client/tests/Instances.hs | 435 ++--- .../haskell-http-client/tests/Test.hs | 28 +- 15 files changed, 2036 insertions(+), 2037 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index d4537cacbce..24814d62c0e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -137,7 +137,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC super(); if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { - LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=/usr/local/bin/hfmt' (Linux/Mac)"); + LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); } this.prependFormOrBodyParameters = true; diff --git a/samples/client/petstore/haskell-http-client/Setup.hs b/samples/client/petstore/haskell-http-client/Setup.hs index 9a994af677b..ebdc00e6461 100644 --- a/samples/client/petstore/haskell-http-client/Setup.hs +++ b/samples/client/petstore/haskell-http-client/Setup.hs @@ -1,2 +1,3 @@ -import Distribution.Simple +import Distribution.Simple + main = defaultMain diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index 83e607b1ad7..ca94dec0b43 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -7,13 +7,11 @@ OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} - {-| Module : OpenAPIPetstore -} - module OpenAPIPetstore - ( module OpenAPIPetstore.API + ( module OpenAPIPetstore.API , module OpenAPIPetstore.Client , module OpenAPIPetstore.Core , module OpenAPIPetstore.Logging @@ -22,10 +20,10 @@ module OpenAPIPetstore , 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 \ No newline at end of file +import OpenAPIPetstore.API +import OpenAPIPetstore.Client +import OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model +import OpenAPIPetstore.ModelLens diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 7335a85067e..2cd3be61554 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -7,11 +7,9 @@ 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 @@ -21,9 +19,9 @@ module OpenAPIPetstore.API , 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 \ No newline at end of file +import OpenAPIPetstore.API.AnotherFake +import OpenAPIPetstore.API.Fake +import OpenAPIPetstore.API.FakeClassnameTags123 +import OpenAPIPetstore.API.Pet +import OpenAPIPetstore.API.Store +import OpenAPIPetstore.API.User diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index aa3b293eb67..13908b80c25 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -7,80 +7,82 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations - - -- ** AnotherFake - -- *** op123testSpecialTags - -- | @PATCH \/another-fake\/dummy@ --- +-- -- To test special tags --- +-- -- To test special tags and operation ID starting with number --- -op123testSpecialTags - :: (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) +-- +op123testSpecialTags :: + (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest Op123testSpecialTags MimeJSON Client MimeJSON op123testSpecialTags client = - _mkRequest "PATCH" ["/another-fake/dummy"] - `setBodyParam` client + _mkRequest "PATCH" ["/another-fake/dummy"] `setBodyParam` client -data Op123testSpecialTags +data Op123testSpecialTags -- | /Body Param/ "Client" - client model -instance HasBodyParam Op123testSpecialTags Client +instance HasBodyParam Op123testSpecialTags Client -- | @application/json@ instance Consumes Op123testSpecialTags MimeJSON -- | @application/json@ instance Produces Op123testSpecialTags MimeJSON - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index 4d73209965f..3e8181a2880 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -7,214 +7,203 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations - - -- ** Fake - -- *** fakeOuterBooleanSerialize - -- | @POST \/fake\/outer\/boolean@ --- +-- -- Test serialization of outer boolean types --- -fakeOuterBooleanSerialize - :: (Consumes FakeOuterBooleanSerialize contentType) +-- +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"] +fakeOuterBooleanSerialize _ _ = _mkRequest "POST" ["/fake/outer/boolean"] -data FakeOuterBooleanSerialize +data FakeOuterBooleanSerialize -- | /Body Param/ "body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BodyBool +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) +-- +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"] +fakeOuterCompositeSerialize _ _ = _mkRequest "POST" ["/fake/outer/composite"] -data FakeOuterCompositeSerialize +data FakeOuterCompositeSerialize -- | /Body Param/ "OuterComposite" - Input composite as post body -instance HasBodyParam FakeOuterCompositeSerialize OuterComposite +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) +-- +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"] +fakeOuterNumberSerialize _ _ = _mkRequest "POST" ["/fake/outer/number"] -data FakeOuterNumberSerialize +data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body -instance HasBodyParam FakeOuterNumberSerialize 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) +-- +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"] +fakeOuterStringSerialize _ _ = _mkRequest "POST" ["/fake/outer/string"] -data FakeOuterStringSerialize +data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body -instance HasBodyParam FakeOuterStringSerialize BodyText +instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype - -- *** testBodyWithFileSchema - -- | @PUT \/fake\/body-with-file-schema@ --- +-- -- For this test, the body for this request much reference a schema named `File`. --- -testBodyWithFileSchema - :: (Consumes TestBodyWithFileSchema MimeJSON, MimeRender MimeJSON FileSchemaTestClass) +-- +testBodyWithFileSchema :: + ( Consumes TestBodyWithFileSchema MimeJSON + , MimeRender MimeJSON FileSchemaTestClass + ) => FileSchemaTestClass -- ^ "fileSchemaTestClass" -> OpenAPIPetstoreRequest TestBodyWithFileSchema MimeJSON NoContent MimeNoContent testBodyWithFileSchema fileSchemaTestClass = - _mkRequest "PUT" ["/fake/body-with-file-schema"] - `setBodyParam` fileSchemaTestClass + _mkRequest "PUT" ["/fake/body-with-file-schema"] `setBodyParam` + fileSchemaTestClass -data TestBodyWithFileSchema -instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass +data TestBodyWithFileSchema + +instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass -- | @application/json@ instance Consumes TestBodyWithFileSchema MimeJSON instance Produces TestBodyWithFileSchema MimeNoContent - -- *** testBodyWithQueryParams - -- | @PUT \/fake\/body-with-query-params@ --- -testBodyWithQueryParams - :: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) +-- +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) + _mkRequest "PUT" ["/fake/body-with-query-params"] `setBodyParam` user `setQuery` + toQuery ("query", Just query) + +data TestBodyWithQueryParams -data TestBodyWithQueryParams -instance HasBodyParam TestBodyWithQueryParams User +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) +-- +testClientModel :: + (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON -testClientModel client = - _mkRequest "PATCH" ["/fake"] - `setBodyParam` client +testClientModel client = _mkRequest "PATCH" ["/fake"] `setBodyParam` client -data TestClientModel +data TestClientModel -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClientModel Client +instance HasBodyParam TestClientModel Client -- | @application/json@ instance Consumes TestClientModel MimeJSON @@ -222,33 +211,31 @@ 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 å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- -- AuthMethod: 'AuthBasicHttpBasicTest' --- -testEndpointParameters - :: (Consumes TestEndpointParameters MimeFormUrlEncoded) +-- +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) + _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 +data TestEndpointParameters -- | /Optional Param/ "integer" - None instance HasOptionalParam TestEndpointParameters ParamInteger where @@ -257,23 +244,19 @@ instance HasOptionalParam TestEndpointParameters ParamInteger where -- | /Optional Param/ "int32" - None instance HasOptionalParam TestEndpointParameters Int32 where - applyOptionalParam req (Int32 xs) = - req `addForm` toForm ("int32", xs) + 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) + 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) + 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) + applyOptionalParam req (ParamString xs) = req `addForm` toForm ("string", xs) -- | /Optional Param/ "binary" - None instance HasOptionalParam TestEndpointParameters ParamBinary where @@ -282,8 +265,7 @@ instance HasOptionalParam TestEndpointParameters ParamBinary where -- | /Optional Param/ "date" - None instance HasOptionalParam TestEndpointParameters ParamDate where - applyOptionalParam req (ParamDate xs) = - req `addForm` toForm ("date", xs) + applyOptionalParam req (ParamDate xs) = req `addForm` toForm ("date", xs) -- | /Optional Param/ "dateTime" - None instance HasOptionalParam TestEndpointParameters ParamDateTime where @@ -292,35 +274,30 @@ instance HasOptionalParam TestEndpointParameters ParamDateTime where -- | /Optional Param/ "password" - None instance HasOptionalParam TestEndpointParameters Password where - applyOptionalParam req (Password xs) = - req `addForm` toForm ("password", xs) + 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) + 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) +-- +testEnumParameters :: + (Consumes TestEnumParameters MimeFormUrlEncoded) => OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent -testEnumParameters = - _mkRequest "GET" ["/fake"] +testEnumParameters = _mkRequest "GET" ["/fake"] -data TestEnumParameters +data TestEnumParameters -- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumFormStringArray where @@ -345,7 +322,8 @@ instance HasOptionalParam TestEnumParameters EnumHeaderString where -- | /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) + 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 @@ -367,52 +345,48 @@ instance Consumes TestEnumParameters MimeFormUrlEncoded instance Produces TestEnumParameters MimeNoContent - -- *** testInlineAdditionalProperties - -- | @POST \/fake\/inline-additionalProperties@ --- +-- -- test inline additionalProperties --- -testInlineAdditionalProperties - :: (Consumes TestInlineAdditionalProperties MimeJSON, MimeRender MimeJSON RequestBody) +-- +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 + _mkRequest "POST" ["/fake/inline-additionalProperties"] `setBodyParam` + requestBody -data TestInlineAdditionalProperties +data TestInlineAdditionalProperties -- | /Body Param/ "request_body" - request body -instance HasBodyParam TestInlineAdditionalProperties RequestBody +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) +-- +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) + _mkRequest "GET" ["/fake/jsonFormData"] `addForm` toForm ("param", param) `addForm` + toForm ("param2", param2) -data TestJsonFormData +data TestJsonFormData -- | @application/x-www-form-urlencoded@ instance Consumes TestJsonFormData MimeFormUrlEncoded instance Produces TestJsonFormData MimeNoContent - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index 5719e3c4cd4..85867102d1c 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -7,83 +7,86 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +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) +-- +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 + _mkRequest "PATCH" ["/fake_classname_test"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) `setBodyParam` + client -data TestClassname +data TestClassname -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClassname Client +instance HasBodyParam TestClassname Client -- | @application/json@ instance Consumes TestClassname MimeJSON -- | @application/json@ instance Produces TestClassname MimeJSON - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 7b6de84e74b..1b3c1f1df24 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -7,279 +7,275 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +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) +-- +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 + _mkRequest "POST" ["/pet"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` + pet -data AddPet +data AddPet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam AddPet Pet +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 +-- +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) + _mkRequest "DELETE" ["/pet/", toPath petId] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + +data DeletePet -data DeletePet instance HasOptionalParam DeletePet ApiKey where - applyOptionalParam req (ApiKey xs) = - req `setHeader` toHeader ("api_key", xs) + 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') +-- +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) +findPetsByStatus _ (Status status) = + _mkRequest "GET" ["/pet/findByStatus"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setQuery` + toQueryColl CommaSeparated ("status", Just status) -data FindPetsByStatus +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') +-- +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) +findPetsByTags _ (Tags tags) = + _mkRequest "GET" ["/pet/findByTags"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setQuery` + toQueryColl CommaSeparated ("tags", Just tags) -{-# DEPRECATED findPetsByTags "" #-} +{-# DEPRECATED +findPetsByTags "" + #-} -data 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') +-- +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) +getPetById _ (PetId petId) = + _mkRequest "GET" ["/pet/", toPath petId] `_hasAuthType` + (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetPetById +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) +-- +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 + _mkRequest "PUT" ["/pet"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` + pet -data UpdatePet +data UpdatePet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam UpdatePet Pet +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) +-- +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) + _mkRequest "POST" ["/pet/", toPath petId] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UpdatePetWithForm +data UpdatePetWithForm -- | /Optional Param/ "name" - Updated name of the pet instance HasOptionalParam UpdatePetWithForm Name2 where - applyOptionalParam req (Name2 xs) = - req `addForm` toForm ("name", xs) + 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) + 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) +-- +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) + _mkRequest "POST" ["/pet/", toPath petId, "/uploadImage"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UploadFile +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) + req `_addMultiFormPart` + NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) -- | /Optional Param/ "file" - file to upload instance HasOptionalParam UploadFile File2 where @@ -292,35 +288,33 @@ instance Consumes UploadFile MimeMultipartFormData -- | @application/json@ instance Produces UploadFile MimeJSON - -- *** uploadFileWithRequiredFile - -- | @POST \/fake\/{petId}\/uploadImageWithRequiredFile@ --- +-- -- uploads an image (required) --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFileWithRequiredFile - :: (Consumes UploadFileWithRequiredFile MimeMultipartFormData) +-- +uploadFileWithRequiredFile :: + (Consumes UploadFileWithRequiredFile MimeMultipartFormData) => RequiredFile -- ^ "requiredFile" - file to upload -> PetId -- ^ "petId" - ID of pet to update -> OpenAPIPetstoreRequest UploadFileWithRequiredFile MimeMultipartFormData ApiResponse MimeJSON uploadFileWithRequiredFile (RequiredFile requiredFile) (PetId petId) = - _mkRequest "POST" ["/fake/",toPath petId,"/uploadImageWithRequiredFile"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) - `_addMultiFormPart` NH.partFileSource "requiredFile" requiredFile + _mkRequest "POST" ["/fake/", toPath petId, "/uploadImageWithRequiredFile"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `_addMultiFormPart` + NH.partFileSource "requiredFile" requiredFile -data UploadFileWithRequiredFile +data UploadFileWithRequiredFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFileWithRequiredFile AdditionalMetadata where applyOptionalParam req (AdditionalMetadata xs) = - req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) + req `_addMultiFormPart` + NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) -- | @multipart/form-data@ instance Consumes UploadFileWithRequiredFile MimeMultipartFormData -- | @application/json@ instance Produces UploadFileWithRequiredFile MimeJSON - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index 12bcd0bc94a..d4e7b353eab 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -7,143 +7,140 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +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 +-- +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] + _mkRequest "DELETE" ["/store/order/", toPath orderId] -data DeleteOrder +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 :: + OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON getInventory = - _mkRequest "GET" ["/store/inventory"] - `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) + _mkRequest "GET" ["/store/inventory"] `_hasAuthType` + (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetInventory +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') +-- +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] +getOrderById _ (OrderId orderId) = + _mkRequest "GET" ["/store/order/", toPath orderId] -data GetOrderById +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) +-- +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 +placeOrder _ _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order -data PlaceOrder +data PlaceOrder -- | /Body Param/ "Order" - order placed for purchasing the pet -instance HasBodyParam PlaceOrder Order +instance HasBodyParam PlaceOrder Order -- | @application/xml@ instance Produces PlaceOrder MimeXML + -- | @application/json@ instance Produces PlaceOrder MimeJSON - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index efc6ad66f31..e97fec08a03 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -7,229 +7,217 @@ 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 FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +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) +-- +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 +createUser _ user = _mkRequest "POST" ["/user"] `setBodyParam` user -data CreateUser +data CreateUser -- | /Body Param/ "User" - Created user object -instance HasBodyParam CreateUser User +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) +-- +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 + _mkRequest "POST" ["/user/createWithArray"] `setBodyParam` user -data CreateUsersWithArrayInput +data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithArrayInput User2 +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) +-- +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 + _mkRequest "POST" ["/user/createWithList"] `setBodyParam` user -data CreateUsersWithListInput +data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithListInput User2 +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 +-- +deleteUser :: + Username -- ^ "username" - The name that needs to be deleted -> OpenAPIPetstoreRequest DeleteUser MimeNoContent NoContent MimeNoContent -deleteUser (Username username) = - _mkRequest "DELETE" ["/user/",toPath username] +deleteUser (Username username) = _mkRequest "DELETE" ["/user/", toPath username] -data DeleteUser +data DeleteUser instance Produces DeleteUser MimeNoContent - -- *** getUserByName - -- | @GET \/user\/{username}@ --- +-- -- Get user by user name --- -getUserByName - :: Accept accept -- ^ request accept ('MimeType') +-- +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] +getUserByName _ (Username username) = + _mkRequest "GET" ["/user/", toPath username] -data GetUserByName +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') +-- +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) +loginUser _ (Username username) (Password password) = + _mkRequest "GET" ["/user/login"] `setQuery` + toQuery ("username", Just username) `setQuery` + toQuery ("password", Just password) -data LoginUser +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"] +-- +logoutUser :: + OpenAPIPetstoreRequest LogoutUser MimeNoContent NoContent MimeNoContent +logoutUser = _mkRequest "GET" ["/user/logout"] -data LogoutUser +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) +-- +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 + _mkRequest "PUT" ["/user/", toPath username] `setBodyParam` user -data UpdateUser +data UpdateUser -- | /Body Param/ "User" - Updated user object -instance HasBodyParam UpdateUser User +instance HasBodyParam UpdateUser User instance Produces UpdateUser MimeNoContent - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index 8e3d4ac772b..35eeff12114 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -7,35 +7,33 @@ 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 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.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 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 Data.Text (Text) +import GHC.Exts (IsString (..)) -import qualified Katip as LG +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 +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 @@ -47,7 +45,6 @@ type LogContext = LG.LogEnv type LogLevel = LG.Severity -- * default logger - -- | the default log environment initLogContext :: IO LogContext initLogContext = LG.initLogEnv "OpenAPIPetstore" "dev" @@ -57,7 +54,6 @@ runDefaultLogExecWithContext :: LogExecWithContext runDefaultLogExecWithContext = LG.runKatipT -- * stdout logger - -- | Runs a Katip logging block with the Log environment stdoutLoggingExec :: LogExecWithContext stdoutLoggingExec = runDefaultLogExecWithContext @@ -65,11 +61,10 @@ 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 + 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 @@ -77,28 +72,25 @@ 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 + 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) +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 :: + (LG.Katip m, E.MonadCatch m, Applicative m) => Text -> m a -> m a logExceptions src = E.handle (\(e :: E.SomeException) -> do @@ -106,7 +98,6 @@ logExceptions src = E.throw e) -- * Log Level - levelInfo :: LogLevel levelInfo = LG.InfoS @@ -115,4 +106,3 @@ levelError = LG.ErrorS levelDebug :: LogLevel levelDebug = LG.DebugS - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index 19b575dd855..bf901e19eed 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -7,194 +7,277 @@ OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} - {-| Module : OpenAPIPetstore.Model -} - -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC + -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.Model where -import OpenAPIPetstore.Core -import OpenAPIPetstore.MimeTypes - -import Data.Aeson ((.:),(.:!),(.:?),(.=)) - -import qualified Control.Arrow as P (left) -import qualified Data.Aeson as A -import qualified Data.ByteString as B -import qualified Data.ByteString.Base64 as B64 -import qualified Data.ByteString.Char8 as BC -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.HashMap.Lazy as HM -import qualified Data.Map as Map -import qualified Data.Maybe as P -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Time as TI -import qualified Lens.Micro as L -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Function ((&)) -import Data.Monoid ((<>)) -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.Core +import OpenAPIPetstore.MimeTypes + +import Data.Aeson ((.:), (.:!), (.:?), (.=)) + +import qualified Control.Arrow as P (left) +import qualified Data.Aeson as A +import qualified Data.ByteString as B +import qualified Data.ByteString.Base64 as B64 +import qualified Data.ByteString.Char8 as BC +import qualified Data.ByteString.Lazy as BL +import qualified Data.Data as P (TypeRep, Typeable, typeOf, + typeRep) +import qualified Data.Foldable as P +import qualified Data.HashMap.Lazy as HM +import qualified Data.Map as Map +import qualified Data.Maybe as P +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import qualified Data.Time as TI +import qualified Lens.Micro as L +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import Prelude (Applicative, Bool (..), Char, + Double, FilePath, Float, Functor, + Int, Integer, Maybe (..), Monad, + String, fmap, maybe, mempty, pure, + undefined, ($), (.), (/=), (<$>), + (<*>), (=<<), (>>=)) + +import qualified Prelude as P -- * Parameter newtypes - - -- ** AdditionalMetadata -newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show) +newtype AdditionalMetadata = AdditionalMetadata + { unAdditionalMetadata :: Text + } deriving (P.Eq, P.Show) -- ** ApiKey -newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) +newtype ApiKey = ApiKey + { unApiKey :: Text + } deriving (P.Eq, P.Show) -- ** Body -newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON) +newtype Body = Body + { unBody :: Double + } deriving (P.Eq, P.Show, A.ToJSON) -- ** BodyBool -newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON) +newtype BodyBool = BodyBool + { unBodyBool :: Bool + } deriving (P.Eq, P.Show, A.ToJSON) -- ** BodyText -newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON) +newtype BodyText = BodyText + { unBodyText :: Text + } deriving (P.Eq, P.Show, A.ToJSON) -- ** Byte -newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) +newtype Byte = Byte + { unByte :: ByteArray + } deriving (P.Eq, P.Show) -- ** Callback -newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show) +newtype Callback = Callback + { unCallback :: Text + } deriving (P.Eq, P.Show) -- ** EnumFormString -newtype EnumFormString = EnumFormString { unEnumFormString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumFormString = EnumFormString + { unEnumFormString :: E'EnumFormString + } deriving (P.Eq, P.Show) -- ** EnumFormStringArray -newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) +newtype EnumFormStringArray = EnumFormStringArray + { unEnumFormStringArray :: [E'EnumFormStringArray] + } deriving (P.Eq, P.Show) -- ** EnumHeaderString -newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumHeaderString = EnumHeaderString + { unEnumHeaderString :: E'EnumFormString + } deriving (P.Eq, P.Show) -- ** EnumHeaderStringArray -newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) +newtype EnumHeaderStringArray = EnumHeaderStringArray + { unEnumHeaderStringArray :: [E'EnumFormStringArray] + } deriving (P.Eq, P.Show) -- ** EnumQueryDouble -newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: E'EnumNumber } deriving (P.Eq, P.Show) +newtype EnumQueryDouble = EnumQueryDouble + { unEnumQueryDouble :: E'EnumNumber + } deriving (P.Eq, P.Show) -- ** EnumQueryInteger -newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: E'EnumQueryInteger } deriving (P.Eq, P.Show) +newtype EnumQueryInteger = EnumQueryInteger + { unEnumQueryInteger :: E'EnumQueryInteger + } deriving (P.Eq, P.Show) -- ** EnumQueryString -newtype EnumQueryString = EnumQueryString { unEnumQueryString :: E'EnumFormString } deriving (P.Eq, P.Show) +newtype EnumQueryString = EnumQueryString + { unEnumQueryString :: E'EnumFormString + } deriving (P.Eq, P.Show) -- ** EnumQueryStringArray -newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) +newtype EnumQueryStringArray = EnumQueryStringArray + { unEnumQueryStringArray :: [E'EnumFormStringArray] + } deriving (P.Eq, P.Show) -- ** File2 -newtype File2 = File2 { unFile2 :: FilePath } deriving (P.Eq, P.Show) +newtype File2 = File2 + { unFile2 :: FilePath + } deriving (P.Eq, P.Show) -- ** Int32 -newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show) +newtype Int32 = Int32 + { unInt32 :: Int + } deriving (P.Eq, P.Show) -- ** Int64 -newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show) +newtype Int64 = Int64 + { unInt64 :: Integer + } deriving (P.Eq, P.Show) -- ** Name2 -newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show) +newtype Name2 = Name2 + { unName2 :: Text + } deriving (P.Eq, P.Show) -- ** Number -newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show) +newtype Number = Number + { unNumber :: Double + } deriving (P.Eq, P.Show) -- ** OrderId -newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show) +newtype OrderId = OrderId + { unOrderId :: Integer + } deriving (P.Eq, P.Show) -- ** OrderIdText -newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show) +newtype OrderIdText = OrderIdText + { unOrderIdText :: Text + } deriving (P.Eq, P.Show) -- ** Param -newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show) +newtype Param = Param + { unParam :: Text + } deriving (P.Eq, P.Show) -- ** Param2 -newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show) +newtype Param2 = Param2 + { unParam2 :: Text + } deriving (P.Eq, P.Show) -- ** ParamBinary -newtype ParamBinary = ParamBinary { unParamBinary :: FilePath } deriving (P.Eq, P.Show) +newtype ParamBinary = ParamBinary + { unParamBinary :: FilePath + } deriving (P.Eq, P.Show) -- ** ParamDate -newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show) +newtype ParamDate = ParamDate + { unParamDate :: Date + } deriving (P.Eq, P.Show) -- ** ParamDateTime -newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show) +newtype ParamDateTime = ParamDateTime + { unParamDateTime :: DateTime + } deriving (P.Eq, P.Show) -- ** ParamDouble -newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show) +newtype ParamDouble = ParamDouble + { unParamDouble :: Double + } deriving (P.Eq, P.Show) -- ** ParamFloat -newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show) +newtype ParamFloat = ParamFloat + { unParamFloat :: Float + } deriving (P.Eq, P.Show) -- ** ParamInteger -newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show) +newtype ParamInteger = ParamInteger + { unParamInteger :: Int + } deriving (P.Eq, P.Show) -- ** ParamString -newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show) +newtype ParamString = ParamString + { unParamString :: Text + } deriving (P.Eq, P.Show) -- ** Password -newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show) +newtype Password = Password + { unPassword :: Text + } deriving (P.Eq, P.Show) -- ** PatternWithoutDelimiter -newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show) +newtype PatternWithoutDelimiter = PatternWithoutDelimiter + { unPatternWithoutDelimiter :: Text + } deriving (P.Eq, P.Show) -- ** PetId -newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) +newtype PetId = PetId + { unPetId :: Integer + } deriving (P.Eq, P.Show) -- ** Query -newtype Query = Query { unQuery :: Text } deriving (P.Eq, P.Show) +newtype Query = Query + { unQuery :: Text + } deriving (P.Eq, P.Show) -- ** RequestBody -newtype RequestBody = RequestBody { unRequestBody :: (Map.Map String Text) } deriving (P.Eq, P.Show, A.ToJSON) +newtype RequestBody = RequestBody + { unRequestBody :: (Map.Map String Text) + } deriving (P.Eq, P.Show, A.ToJSON) -- ** RequiredFile -newtype RequiredFile = RequiredFile { unRequiredFile :: FilePath } deriving (P.Eq, P.Show) +newtype RequiredFile = RequiredFile + { unRequiredFile :: FilePath + } deriving (P.Eq, P.Show) -- ** Status -newtype Status = Status { unStatus :: [E'Status2] } deriving (P.Eq, P.Show) +newtype Status = Status + { unStatus :: [E'Status2] + } deriving (P.Eq, P.Show) -- ** StatusText -newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show) +newtype StatusText = StatusText + { unStatusText :: Text + } deriving (P.Eq, P.Show) -- ** Tags -newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show) +newtype Tags = Tags + { unTags :: [Text] + } deriving (P.Eq, P.Show) -- ** User2 -newtype User2 = User2 { unUser2 :: [User] } deriving (P.Eq, P.Show, A.ToJSON) +newtype User2 = User2 + { unUser2 :: [User] + } deriving (P.Eq, P.Show, A.ToJSON) -- ** Username -newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show) +newtype Username = Username + { unUsername :: Text + } deriving (P.Eq, P.Show) -- * Models - - -- ** AdditionalPropertiesClass -- | AdditionalPropertiesClass data AdditionalPropertiesClass = AdditionalPropertiesClass @@ -204,23 +287,21 @@ data AdditionalPropertiesClass = AdditionalPropertiesClass -- | FromJSON AdditionalPropertiesClass instance A.FromJSON AdditionalPropertiesClass where - parseJSON = A.withObject "AdditionalPropertiesClass" $ \o -> - AdditionalPropertiesClass - <$> (o .:? "map_property") - <*> (o .:? "map_of_map_property") + parseJSON = + A.withObject "AdditionalPropertiesClass" $ \o -> + AdditionalPropertiesClass <$> (o .:? "map_property") <*> + (o .:? "map_of_map_property") -- | ToJSON AdditionalPropertiesClass instance A.ToJSON AdditionalPropertiesClass where toJSON AdditionalPropertiesClass {..} = - _omitNulls + _omitNulls [ "map_property" .= additionalPropertiesClassMapProperty , "map_of_map_property" .= additionalPropertiesClassMapOfMapProperty ] - -- | Construct a value of type 'AdditionalPropertiesClass' (by applying it's required fields, if any) -mkAdditionalPropertiesClass - :: AdditionalPropertiesClass +mkAdditionalPropertiesClass :: AdditionalPropertiesClass mkAdditionalPropertiesClass = AdditionalPropertiesClass { additionalPropertiesClassMapProperty = Nothing @@ -231,92 +312,69 @@ mkAdditionalPropertiesClass = -- | Animal data Animal = Animal { animalClassName :: !(Text) -- ^ /Required/ "className" - , animalColor :: !(Maybe Text) -- ^ "color" + , animalColor :: !(Maybe Text) -- ^ "color" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Animal instance A.FromJSON Animal where - parseJSON = A.withObject "Animal" $ \o -> - Animal - <$> (o .: "className") - <*> (o .:? "color") + parseJSON = + A.withObject "Animal" $ \o -> + Animal <$> (o .: "className") <*> (o .:? "color") -- | ToJSON Animal instance A.ToJSON Animal where toJSON Animal {..} = - _omitNulls - [ "className" .= animalClassName - , "color" .= animalColor - ] - + _omitNulls ["className" .= animalClassName, "color" .= animalColor] -- | Construct a value of type 'Animal' (by applying it's required fields, if any) -mkAnimal - :: Text -- ^ 'animalClassName' +mkAnimal :: + Text -- ^ 'animalClassName' -> Animal -mkAnimal animalClassName = - Animal - { animalClassName - , animalColor = Nothing - } +mkAnimal animalClassName = Animal {animalClassName, animalColor = Nothing} -- ** AnimalFarm -- | AnimalFarm data AnimalFarm = AnimalFarm - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON AnimalFarm instance A.FromJSON AnimalFarm where - parseJSON = A.withObject "AnimalFarm" $ \o -> - pure AnimalFarm - + parseJSON = A.withObject "AnimalFarm" $ \o -> pure AnimalFarm -- | ToJSON AnimalFarm instance A.ToJSON AnimalFarm where - toJSON AnimalFarm = - _omitNulls - [ - ] - + toJSON AnimalFarm = _omitNulls [] -- | Construct a value of type 'AnimalFarm' (by applying it's required fields, if any) -mkAnimalFarm - :: AnimalFarm -mkAnimalFarm = - AnimalFarm - { - } +mkAnimalFarm :: AnimalFarm +mkAnimalFarm = AnimalFarm {} -- ** ApiResponse -- | ApiResponse data ApiResponse = ApiResponse - { apiResponseCode :: !(Maybe Int) -- ^ "code" - , apiResponseType :: !(Maybe Text) -- ^ "type" + { apiResponseCode :: !(Maybe Int) -- ^ "code" + , apiResponseType :: !(Maybe Text) -- ^ "type" , apiResponseMessage :: !(Maybe Text) -- ^ "message" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ApiResponse instance A.FromJSON ApiResponse where - parseJSON = A.withObject "ApiResponse" $ \o -> - ApiResponse - <$> (o .:? "code") - <*> (o .:? "type") - <*> (o .:? "message") + parseJSON = + A.withObject "ApiResponse" $ \o -> + ApiResponse <$> (o .:? "code") <*> (o .:? "type") <*> (o .:? "message") -- | ToJSON ApiResponse instance A.ToJSON ApiResponse where toJSON ApiResponse {..} = - _omitNulls + _omitNulls [ "code" .= apiResponseCode , "type" .= apiResponseType , "message" .= apiResponseMessage ] - -- | Construct a value of type 'ApiResponse' (by applying it's required fields, if any) -mkApiResponse - :: ApiResponse +mkApiResponse :: ApiResponse mkApiResponse = ApiResponse { apiResponseCode = Nothing @@ -332,25 +390,19 @@ data ArrayOfArrayOfNumberOnly = ArrayOfArrayOfNumberOnly -- | FromJSON ArrayOfArrayOfNumberOnly instance A.FromJSON ArrayOfArrayOfNumberOnly where - parseJSON = A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> - ArrayOfArrayOfNumberOnly - <$> (o .:? "ArrayArrayNumber") + parseJSON = + A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> + ArrayOfArrayOfNumberOnly <$> (o .:? "ArrayArrayNumber") -- | ToJSON ArrayOfArrayOfNumberOnly instance A.ToJSON ArrayOfArrayOfNumberOnly where toJSON ArrayOfArrayOfNumberOnly {..} = - _omitNulls - [ "ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber - ] - + _omitNulls ["ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber] -- | Construct a value of type 'ArrayOfArrayOfNumberOnly' (by applying it's required fields, if any) -mkArrayOfArrayOfNumberOnly - :: ArrayOfArrayOfNumberOnly +mkArrayOfArrayOfNumberOnly :: ArrayOfArrayOfNumberOnly mkArrayOfArrayOfNumberOnly = - ArrayOfArrayOfNumberOnly - { arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing - } + ArrayOfArrayOfNumberOnly {arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing} -- ** ArrayOfNumberOnly -- | ArrayOfNumberOnly @@ -360,55 +412,46 @@ data ArrayOfNumberOnly = ArrayOfNumberOnly -- | FromJSON ArrayOfNumberOnly instance A.FromJSON ArrayOfNumberOnly where - parseJSON = A.withObject "ArrayOfNumberOnly" $ \o -> - ArrayOfNumberOnly - <$> (o .:? "ArrayNumber") + parseJSON = + A.withObject "ArrayOfNumberOnly" $ \o -> + ArrayOfNumberOnly <$> (o .:? "ArrayNumber") -- | ToJSON ArrayOfNumberOnly instance A.ToJSON ArrayOfNumberOnly where toJSON ArrayOfNumberOnly {..} = - _omitNulls - [ "ArrayNumber" .= arrayOfNumberOnlyArrayNumber - ] - + _omitNulls ["ArrayNumber" .= arrayOfNumberOnlyArrayNumber] -- | Construct a value of type 'ArrayOfNumberOnly' (by applying it's required fields, if any) -mkArrayOfNumberOnly - :: ArrayOfNumberOnly -mkArrayOfNumberOnly = - ArrayOfNumberOnly - { arrayOfNumberOnlyArrayNumber = Nothing - } +mkArrayOfNumberOnly :: ArrayOfNumberOnly +mkArrayOfNumberOnly = ArrayOfNumberOnly {arrayOfNumberOnlyArrayNumber = Nothing} -- ** ArrayTest -- | ArrayTest data ArrayTest = ArrayTest - { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" + { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" - , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" + , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ArrayTest instance A.FromJSON ArrayTest where - parseJSON = A.withObject "ArrayTest" $ \o -> - ArrayTest - <$> (o .:? "array_of_string") - <*> (o .:? "array_array_of_integer") - <*> (o .:? "array_array_of_model") + parseJSON = + A.withObject "ArrayTest" $ \o -> + ArrayTest <$> (o .:? "array_of_string") <*> + (o .:? "array_array_of_integer") <*> + (o .:? "array_array_of_model") -- | ToJSON ArrayTest instance A.ToJSON ArrayTest where toJSON ArrayTest {..} = - _omitNulls + _omitNulls [ "array_of_string" .= arrayTestArrayOfString , "array_array_of_integer" .= arrayTestArrayArrayOfInteger , "array_array_of_model" .= arrayTestArrayArrayOfModel ] - -- | Construct a value of type 'ArrayTest' (by applying it's required fields, if any) -mkArrayTest - :: ArrayTest +mkArrayTest :: ArrayTest mkArrayTest = ArrayTest { arrayTestArrayOfString = Nothing @@ -419,29 +462,28 @@ mkArrayTest = -- ** Capitalization -- | Capitalization data Capitalization = Capitalization - { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" - , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" - , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" - , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" + { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" + , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" + , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" + , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" - , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet + , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Capitalization instance A.FromJSON Capitalization where - parseJSON = A.withObject "Capitalization" $ \o -> - Capitalization - <$> (o .:? "smallCamel") - <*> (o .:? "CapitalCamel") - <*> (o .:? "small_Snake") - <*> (o .:? "Capital_Snake") - <*> (o .:? "SCA_ETH_Flow_Points") - <*> (o .:? "ATT_NAME") + parseJSON = + A.withObject "Capitalization" $ \o -> + Capitalization <$> (o .:? "smallCamel") <*> (o .:? "CapitalCamel") <*> + (o .:? "small_Snake") <*> + (o .:? "Capital_Snake") <*> + (o .:? "SCA_ETH_Flow_Points") <*> + (o .:? "ATT_NAME") -- | ToJSON Capitalization instance A.ToJSON Capitalization where toJSON Capitalization {..} = - _omitNulls + _omitNulls [ "smallCamel" .= capitalizationSmallCamel , "CapitalCamel" .= capitalizationCapitalCamel , "small_Snake" .= capitalizationSmallSnake @@ -450,10 +492,8 @@ instance A.ToJSON Capitalization where , "ATT_NAME" .= capitalizationAttName ] - -- | Construct a value of type 'Capitalization' (by applying it's required fields, if any) -mkCapitalization - :: Capitalization +mkCapitalization :: Capitalization mkCapitalization = Capitalization { capitalizationSmallCamel = Nothing @@ -468,70 +508,51 @@ mkCapitalization = -- | Cat data Cat = Cat { catClassName :: !(Text) -- ^ /Required/ "className" - , catColor :: !(Maybe Text) -- ^ "color" - , catDeclawed :: !(Maybe Bool) -- ^ "declawed" + , catColor :: !(Maybe Text) -- ^ "color" + , catDeclawed :: !(Maybe Bool) -- ^ "declawed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Cat instance A.FromJSON Cat where - parseJSON = A.withObject "Cat" $ \o -> - Cat - <$> (o .: "className") - <*> (o .:? "color") - <*> (o .:? "declawed") + parseJSON = + A.withObject "Cat" $ \o -> + Cat <$> (o .: "className") <*> (o .:? "color") <*> (o .:? "declawed") -- | ToJSON Cat instance A.ToJSON Cat where toJSON Cat {..} = - _omitNulls + _omitNulls [ "className" .= catClassName , "color" .= catColor , "declawed" .= catDeclawed ] - -- | Construct a value of type 'Cat' (by applying it's required fields, if any) -mkCat - :: Text -- ^ 'catClassName' +mkCat :: + Text -- ^ 'catClassName' -> Cat mkCat catClassName = - Cat - { catClassName - , catColor = Nothing - , catDeclawed = Nothing - } + Cat {catClassName, catColor = Nothing, catDeclawed = Nothing} -- ** Category -- | Category data Category = Category - { categoryId :: !(Maybe Integer) -- ^ "id" + { categoryId :: !(Maybe Integer) -- ^ "id" , categoryName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Category instance A.FromJSON Category where - parseJSON = A.withObject "Category" $ \o -> - Category - <$> (o .:? "id") - <*> (o .:? "name") + parseJSON = + A.withObject "Category" $ \o -> Category <$> (o .:? "id") <*> (o .:? "name") -- | ToJSON Category instance A.ToJSON Category where - toJSON Category {..} = - _omitNulls - [ "id" .= categoryId - , "name" .= categoryName - ] - + toJSON Category {..} = _omitNulls ["id" .= categoryId, "name" .= categoryName] -- | Construct a value of type 'Category' (by applying it's required fields, if any) -mkCategory - :: Category -mkCategory = - Category - { categoryId = Nothing - , categoryName = Nothing - } +mkCategory :: Category +mkCategory = Category {categoryId = Nothing, categoryName = Nothing} -- ** ClassModel -- | ClassModel @@ -542,25 +563,15 @@ data ClassModel = ClassModel -- | FromJSON ClassModel instance A.FromJSON ClassModel where - parseJSON = A.withObject "ClassModel" $ \o -> - ClassModel - <$> (o .:? "_class") + parseJSON = A.withObject "ClassModel" $ \o -> ClassModel <$> (o .:? "_class") -- | ToJSON ClassModel instance A.ToJSON ClassModel where - toJSON ClassModel {..} = - _omitNulls - [ "_class" .= classModelClass - ] - + toJSON ClassModel {..} = _omitNulls ["_class" .= classModelClass] -- | Construct a value of type 'ClassModel' (by applying it's required fields, if any) -mkClassModel - :: ClassModel -mkClassModel = - ClassModel - { classModelClass = Nothing - } +mkClassModel :: ClassModel +mkClassModel = ClassModel {classModelClass = Nothing} -- ** Client -- | Client @@ -570,119 +581,91 @@ data Client = Client -- | FromJSON Client instance A.FromJSON Client where - parseJSON = A.withObject "Client" $ \o -> - Client - <$> (o .:? "client") + parseJSON = A.withObject "Client" $ \o -> Client <$> (o .:? "client") -- | ToJSON Client instance A.ToJSON Client where - toJSON Client {..} = - _omitNulls - [ "client" .= clientClient - ] - + toJSON Client {..} = _omitNulls ["client" .= clientClient] -- | Construct a value of type 'Client' (by applying it's required fields, if any) -mkClient - :: Client -mkClient = - Client - { clientClient = Nothing - } +mkClient :: Client +mkClient = Client {clientClient = Nothing} -- ** Dog -- | Dog data Dog = Dog { dogClassName :: !(Text) -- ^ /Required/ "className" - , dogColor :: !(Maybe Text) -- ^ "color" - , dogBreed :: !(Maybe Text) -- ^ "breed" + , dogColor :: !(Maybe Text) -- ^ "color" + , dogBreed :: !(Maybe Text) -- ^ "breed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Dog instance A.FromJSON Dog where - parseJSON = A.withObject "Dog" $ \o -> - Dog - <$> (o .: "className") - <*> (o .:? "color") - <*> (o .:? "breed") + parseJSON = + A.withObject "Dog" $ \o -> + Dog <$> (o .: "className") <*> (o .:? "color") <*> (o .:? "breed") -- | ToJSON Dog instance A.ToJSON Dog where toJSON Dog {..} = - _omitNulls - [ "className" .= dogClassName - , "color" .= dogColor - , "breed" .= dogBreed - ] - + _omitNulls + ["className" .= dogClassName, "color" .= dogColor, "breed" .= dogBreed] -- | Construct a value of type 'Dog' (by applying it's required fields, if any) -mkDog - :: Text -- ^ 'dogClassName' +mkDog :: + Text -- ^ 'dogClassName' -> Dog -mkDog dogClassName = - Dog - { dogClassName - , dogColor = Nothing - , dogBreed = Nothing - } +mkDog dogClassName = Dog {dogClassName, dogColor = Nothing, dogBreed = Nothing} -- ** EnumArrays -- | EnumArrays data EnumArrays = EnumArrays { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumArrays instance A.FromJSON EnumArrays where - parseJSON = A.withObject "EnumArrays" $ \o -> - EnumArrays - <$> (o .:? "just_symbol") - <*> (o .:? "array_enum") + parseJSON = + A.withObject "EnumArrays" $ \o -> + EnumArrays <$> (o .:? "just_symbol") <*> (o .:? "array_enum") -- | ToJSON EnumArrays instance A.ToJSON EnumArrays where toJSON EnumArrays {..} = - _omitNulls + _omitNulls [ "just_symbol" .= enumArraysJustSymbol , "array_enum" .= enumArraysArrayEnum ] - -- | Construct a value of type 'EnumArrays' (by applying it's required fields, if any) -mkEnumArrays - :: EnumArrays +mkEnumArrays :: EnumArrays mkEnumArrays = - EnumArrays - { enumArraysJustSymbol = Nothing - , enumArraysArrayEnum = Nothing - } + EnumArrays {enumArraysJustSymbol = Nothing, enumArraysArrayEnum = Nothing} -- ** EnumTest -- | EnumTest data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" , enumTestEnumStringRequired :: !(E'EnumString) -- ^ /Required/ "enum_string_required" - , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" - , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" + , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumTest instance A.FromJSON EnumTest where - parseJSON = A.withObject "EnumTest" $ \o -> - EnumTest - <$> (o .:? "enum_string") - <*> (o .: "enum_string_required") - <*> (o .:? "enum_integer") - <*> (o .:? "enum_number") - <*> (o .:? "outerEnum") + parseJSON = + A.withObject "EnumTest" $ \o -> + EnumTest <$> (o .:? "enum_string") <*> (o .: "enum_string_required") <*> + (o .:? "enum_integer") <*> + (o .:? "enum_number") <*> + (o .:? "outerEnum") -- | ToJSON EnumTest instance A.ToJSON EnumTest where toJSON EnumTest {..} = - _omitNulls + _omitNulls [ "enum_string" .= enumTestEnumString , "enum_string_required" .= enumTestEnumStringRequired , "enum_integer" .= enumTestEnumInteger @@ -690,10 +673,9 @@ instance A.ToJSON EnumTest where , "outerEnum" .= enumTestOuterEnum ] - -- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) -mkEnumTest - :: E'EnumString -- ^ 'enumTestEnumStringRequired' +mkEnumTest :: + E'EnumString -- ^ 'enumTestEnumStringRequired' -> EnumTest mkEnumTest enumTestEnumStringRequired = EnumTest @@ -713,98 +695,79 @@ data File = File -- | FromJSON File instance A.FromJSON File where - parseJSON = A.withObject "File" $ \o -> - File - <$> (o .:? "sourceURI") + parseJSON = A.withObject "File" $ \o -> File <$> (o .:? "sourceURI") -- | ToJSON File instance A.ToJSON File where - toJSON File {..} = - _omitNulls - [ "sourceURI" .= fileSourceUri - ] - + toJSON File {..} = _omitNulls ["sourceURI" .= fileSourceUri] -- | Construct a value of type 'File' (by applying it's required fields, if any) -mkFile - :: File -mkFile = - File - { fileSourceUri = Nothing - } +mkFile :: File +mkFile = File {fileSourceUri = Nothing} -- ** FileSchemaTestClass -- | FileSchemaTestClass data FileSchemaTestClass = FileSchemaTestClass - { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" + { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" , fileSchemaTestClassFiles :: !(Maybe [File]) -- ^ "files" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON FileSchemaTestClass instance A.FromJSON FileSchemaTestClass where - parseJSON = A.withObject "FileSchemaTestClass" $ \o -> - FileSchemaTestClass - <$> (o .:? "file") - <*> (o .:? "files") + parseJSON = + A.withObject "FileSchemaTestClass" $ \o -> + FileSchemaTestClass <$> (o .:? "file") <*> (o .:? "files") -- | ToJSON FileSchemaTestClass instance A.ToJSON FileSchemaTestClass where toJSON FileSchemaTestClass {..} = - _omitNulls - [ "file" .= fileSchemaTestClassFile - , "files" .= fileSchemaTestClassFiles - ] - + _omitNulls + ["file" .= fileSchemaTestClassFile, "files" .= fileSchemaTestClassFiles] -- | Construct a value of type 'FileSchemaTestClass' (by applying it's required fields, if any) -mkFileSchemaTestClass - :: FileSchemaTestClass +mkFileSchemaTestClass :: FileSchemaTestClass mkFileSchemaTestClass = FileSchemaTestClass - { fileSchemaTestClassFile = Nothing - , fileSchemaTestClassFiles = Nothing - } + {fileSchemaTestClassFile = Nothing, fileSchemaTestClassFiles = Nothing} -- ** FormatTest -- | FormatTest data FormatTest = FormatTest - { formatTestInteger :: !(Maybe Int) -- ^ "integer" - , formatTestInt32 :: !(Maybe Int) -- ^ "int32" - , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" - , formatTestNumber :: !(Double) -- ^ /Required/ "number" - , formatTestFloat :: !(Maybe Float) -- ^ "float" - , formatTestDouble :: !(Maybe Double) -- ^ "double" - , formatTestString :: !(Maybe Text) -- ^ "string" - , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" - , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" - , formatTestDate :: !(Date) -- ^ /Required/ "date" + { formatTestInteger :: !(Maybe Int) -- ^ "integer" + , formatTestInt32 :: !(Maybe Int) -- ^ "int32" + , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" + , formatTestNumber :: !(Double) -- ^ /Required/ "number" + , formatTestFloat :: !(Maybe Float) -- ^ "float" + , formatTestDouble :: !(Maybe Double) -- ^ "double" + , formatTestString :: !(Maybe Text) -- ^ "string" + , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" + , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" + , formatTestDate :: !(Date) -- ^ /Required/ "date" , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , formatTestUuid :: !(Maybe Text) -- ^ "uuid" + , formatTestUuid :: !(Maybe Text) -- ^ "uuid" , formatTestPassword :: !(Text) -- ^ /Required/ "password" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON FormatTest instance A.FromJSON FormatTest where - parseJSON = A.withObject "FormatTest" $ \o -> - FormatTest - <$> (o .:? "integer") - <*> (o .:? "int32") - <*> (o .:? "int64") - <*> (o .: "number") - <*> (o .:? "float") - <*> (o .:? "double") - <*> (o .:? "string") - <*> (o .: "byte") - <*> (o .:? "binary") - <*> (o .: "date") - <*> (o .:? "dateTime") - <*> (o .:? "uuid") - <*> (o .: "password") + parseJSON = + A.withObject "FormatTest" $ \o -> + FormatTest <$> (o .:? "integer") <*> (o .:? "int32") <*> (o .:? "int64") <*> + (o .: "number") <*> + (o .:? "float") <*> + (o .:? "double") <*> + (o .:? "string") <*> + (o .: "byte") <*> + (o .:? "binary") <*> + (o .: "date") <*> + (o .:? "dateTime") <*> + (o .:? "uuid") <*> + (o .: "password") -- | ToJSON FormatTest instance A.ToJSON FormatTest where toJSON FormatTest {..} = - _omitNulls + _omitNulls [ "integer" .= formatTestInteger , "int32" .= formatTestInt32 , "int64" .= formatTestInt64 @@ -820,13 +783,12 @@ instance A.ToJSON FormatTest where , "password" .= formatTestPassword ] - -- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) -mkFormatTest - :: Double -- ^ 'formatTestNumber' - -> ByteArray -- ^ 'formatTestByte' - -> Date -- ^ 'formatTestDate' - -> Text -- ^ 'formatTestPassword' +mkFormatTest :: + Double -- ^ 'formatTestNumber' + -> ByteArray -- ^ 'formatTestByte' + -> Date -- ^ 'formatTestDate' + -> Text -- ^ 'formatTestPassword' -> FormatTest mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = FormatTest @@ -854,61 +816,49 @@ data HasOnlyReadOnly = HasOnlyReadOnly -- | FromJSON HasOnlyReadOnly instance A.FromJSON HasOnlyReadOnly where - parseJSON = A.withObject "HasOnlyReadOnly" $ \o -> - HasOnlyReadOnly - <$> (o .:? "bar") - <*> (o .:? "foo") + parseJSON = + A.withObject "HasOnlyReadOnly" $ \o -> + HasOnlyReadOnly <$> (o .:? "bar") <*> (o .:? "foo") -- | ToJSON HasOnlyReadOnly instance A.ToJSON HasOnlyReadOnly where toJSON HasOnlyReadOnly {..} = - _omitNulls - [ "bar" .= hasOnlyReadOnlyBar - , "foo" .= hasOnlyReadOnlyFoo - ] - + _omitNulls ["bar" .= hasOnlyReadOnlyBar, "foo" .= hasOnlyReadOnlyFoo] -- | Construct a value of type 'HasOnlyReadOnly' (by applying it's required fields, if any) -mkHasOnlyReadOnly - :: HasOnlyReadOnly +mkHasOnlyReadOnly :: HasOnlyReadOnly mkHasOnlyReadOnly = - HasOnlyReadOnly - { hasOnlyReadOnlyBar = Nothing - , hasOnlyReadOnlyFoo = Nothing - } + HasOnlyReadOnly {hasOnlyReadOnlyBar = Nothing, hasOnlyReadOnlyFoo = Nothing} -- ** MapTest -- | MapTest data MapTest = MapTest - { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" + { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" - , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" - , mapTestIndirectMap :: !(Maybe StringBooleanMap) -- ^ "indirect_map" + , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" + , mapTestIndirectMap :: !(Maybe StringBooleanMap) -- ^ "indirect_map" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON MapTest instance A.FromJSON MapTest where - parseJSON = A.withObject "MapTest" $ \o -> - MapTest - <$> (o .:? "map_map_of_string") - <*> (o .:? "map_of_enum_string") - <*> (o .:? "direct_map") - <*> (o .:? "indirect_map") + parseJSON = + A.withObject "MapTest" $ \o -> + MapTest <$> (o .:? "map_map_of_string") <*> (o .:? "map_of_enum_string") <*> + (o .:? "direct_map") <*> + (o .:? "indirect_map") -- | ToJSON MapTest instance A.ToJSON MapTest where toJSON MapTest {..} = - _omitNulls + _omitNulls [ "map_map_of_string" .= mapTestMapMapOfString , "map_of_enum_string" .= mapTestMapOfEnumString , "direct_map" .= mapTestDirectMap , "indirect_map" .= mapTestIndirectMap ] - -- | Construct a value of type 'MapTest' (by applying it's required fields, if any) -mkMapTest - :: MapTest +mkMapTest :: MapTest mkMapTest = MapTest { mapTestMapMapOfString = Nothing @@ -927,25 +877,24 @@ data MixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalP -- | FromJSON MixedPropertiesAndAdditionalPropertiesClass instance A.FromJSON MixedPropertiesAndAdditionalPropertiesClass where - parseJSON = A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> - MixedPropertiesAndAdditionalPropertiesClass - <$> (o .:? "uuid") - <*> (o .:? "dateTime") - <*> (o .:? "map") + parseJSON = + A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> + MixedPropertiesAndAdditionalPropertiesClass <$> (o .:? "uuid") <*> + (o .:? "dateTime") <*> + (o .:? "map") -- | ToJSON MixedPropertiesAndAdditionalPropertiesClass instance A.ToJSON MixedPropertiesAndAdditionalPropertiesClass where toJSON MixedPropertiesAndAdditionalPropertiesClass {..} = - _omitNulls + _omitNulls [ "uuid" .= mixedPropertiesAndAdditionalPropertiesClassUuid , "dateTime" .= mixedPropertiesAndAdditionalPropertiesClassDateTime , "map" .= mixedPropertiesAndAdditionalPropertiesClassMap ] - -- | Construct a value of type 'MixedPropertiesAndAdditionalPropertiesClass' (by applying it's required fields, if any) -mkMixedPropertiesAndAdditionalPropertiesClass - :: MixedPropertiesAndAdditionalPropertiesClass +mkMixedPropertiesAndAdditionalPropertiesClass :: + MixedPropertiesAndAdditionalPropertiesClass mkMixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid = Nothing @@ -957,34 +906,27 @@ mkMixedPropertiesAndAdditionalPropertiesClass = -- | Model200Response -- Model for testing model name starting with number data Model200Response = Model200Response - { model200ResponseName :: !(Maybe Int) -- ^ "name" + { model200ResponseName :: !(Maybe Int) -- ^ "name" , model200ResponseClass :: !(Maybe Text) -- ^ "class" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Model200Response instance A.FromJSON Model200Response where - parseJSON = A.withObject "Model200Response" $ \o -> - Model200Response - <$> (o .:? "name") - <*> (o .:? "class") + parseJSON = + A.withObject "Model200Response" $ \o -> + Model200Response <$> (o .:? "name") <*> (o .:? "class") -- | ToJSON Model200Response instance A.ToJSON Model200Response where toJSON Model200Response {..} = - _omitNulls - [ "name" .= model200ResponseName - , "class" .= model200ResponseClass - ] - + _omitNulls + ["name" .= model200ResponseName, "class" .= model200ResponseClass] -- | Construct a value of type 'Model200Response' (by applying it's required fields, if any) -mkModel200Response - :: Model200Response +mkModel200Response :: Model200Response mkModel200Response = Model200Response - { model200ResponseName = Nothing - , model200ResponseClass = Nothing - } + {model200ResponseName = Nothing, model200ResponseClass = Nothing} -- ** ModelList -- | ModelList @@ -994,25 +936,15 @@ data ModelList = ModelList -- | FromJSON ModelList instance A.FromJSON ModelList where - parseJSON = A.withObject "ModelList" $ \o -> - ModelList - <$> (o .:? "123-list") + parseJSON = A.withObject "ModelList" $ \o -> ModelList <$> (o .:? "123-list") -- | ToJSON ModelList instance A.ToJSON ModelList where - toJSON ModelList {..} = - _omitNulls - [ "123-list" .= modelList123list - ] - + toJSON ModelList {..} = _omitNulls ["123-list" .= modelList123list] -- | Construct a value of type 'ModelList' (by applying it's required fields, if any) -mkModelList - :: ModelList -mkModelList = - ModelList - { modelList123list = Nothing - } +mkModelList :: ModelList +mkModelList = ModelList {modelList123list = Nothing} -- ** ModelReturn -- | ModelReturn @@ -1023,59 +955,47 @@ data ModelReturn = ModelReturn -- | FromJSON ModelReturn instance A.FromJSON ModelReturn where - parseJSON = A.withObject "ModelReturn" $ \o -> - ModelReturn - <$> (o .:? "return") + parseJSON = + A.withObject "ModelReturn" $ \o -> ModelReturn <$> (o .:? "return") -- | ToJSON ModelReturn instance A.ToJSON ModelReturn where - toJSON ModelReturn {..} = - _omitNulls - [ "return" .= modelReturnReturn - ] - + toJSON ModelReturn {..} = _omitNulls ["return" .= modelReturnReturn] -- | Construct a value of type 'ModelReturn' (by applying it's required fields, if any) -mkModelReturn - :: ModelReturn -mkModelReturn = - ModelReturn - { modelReturnReturn = Nothing - } +mkModelReturn :: ModelReturn +mkModelReturn = ModelReturn {modelReturnReturn = Nothing} -- ** Name -- | Name -- Model for testing model name same as property name data Name = Name - { nameName :: !(Int) -- ^ /Required/ "name" + { nameName :: !(Int) -- ^ /Required/ "name" , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" - , nameProperty :: !(Maybe Text) -- ^ "property" + , nameProperty :: !(Maybe Text) -- ^ "property" , name123number :: !(Maybe Int) -- ^ "123Number" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Name instance A.FromJSON Name where - parseJSON = A.withObject "Name" $ \o -> - Name - <$> (o .: "name") - <*> (o .:? "snake_case") - <*> (o .:? "property") - <*> (o .:? "123Number") + parseJSON = + A.withObject "Name" $ \o -> + Name <$> (o .: "name") <*> (o .:? "snake_case") <*> (o .:? "property") <*> + (o .:? "123Number") -- | ToJSON Name instance A.ToJSON Name where toJSON Name {..} = - _omitNulls + _omitNulls [ "name" .= nameName , "snake_case" .= nameSnakeCase , "property" .= nameProperty , "123Number" .= name123number ] - -- | Construct a value of type 'Name' (by applying it's required fields, if any) -mkName - :: Int -- ^ 'nameName' +mkName :: + Int -- ^ 'nameName' -> Name mkName nameName = Name @@ -1093,52 +1013,41 @@ data NumberOnly = NumberOnly -- | FromJSON NumberOnly instance A.FromJSON NumberOnly where - parseJSON = A.withObject "NumberOnly" $ \o -> - NumberOnly - <$> (o .:? "JustNumber") + parseJSON = + A.withObject "NumberOnly" $ \o -> NumberOnly <$> (o .:? "JustNumber") -- | ToJSON NumberOnly instance A.ToJSON NumberOnly where - toJSON NumberOnly {..} = - _omitNulls - [ "JustNumber" .= numberOnlyJustNumber - ] - + toJSON NumberOnly {..} = _omitNulls ["JustNumber" .= numberOnlyJustNumber] -- | Construct a value of type 'NumberOnly' (by applying it's required fields, if any) -mkNumberOnly - :: NumberOnly -mkNumberOnly = - NumberOnly - { numberOnlyJustNumber = Nothing - } +mkNumberOnly :: NumberOnly +mkNumberOnly = NumberOnly {numberOnlyJustNumber = Nothing} -- ** Order -- | Order data Order = Order - { orderId :: !(Maybe Integer) -- ^ "id" - , orderPetId :: !(Maybe Integer) -- ^ "petId" + { orderId :: !(Maybe Integer) -- ^ "id" + , orderPetId :: !(Maybe Integer) -- ^ "petId" , orderQuantity :: !(Maybe Int) -- ^ "quantity" , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status , orderComplete :: !(Maybe Bool) -- ^ "complete" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Order instance A.FromJSON Order where - parseJSON = A.withObject "Order" $ \o -> - Order - <$> (o .:? "id") - <*> (o .:? "petId") - <*> (o .:? "quantity") - <*> (o .:? "shipDate") - <*> (o .:? "status") - <*> (o .:? "complete") + parseJSON = + A.withObject "Order" $ \o -> + Order <$> (o .:? "id") <*> (o .:? "petId") <*> (o .:? "quantity") <*> + (o .:? "shipDate") <*> + (o .:? "status") <*> + (o .:? "complete") -- | ToJSON Order instance A.ToJSON Order where toJSON Order {..} = - _omitNulls + _omitNulls [ "id" .= orderId , "petId" .= orderPetId , "quantity" .= orderQuantity @@ -1147,10 +1056,8 @@ instance A.ToJSON Order where , "complete" .= orderComplete ] - -- | Construct a value of type 'Order' (by applying it's required fields, if any) -mkOrder - :: Order +mkOrder :: Order mkOrder = Order { orderId = Nothing @@ -1164,32 +1071,29 @@ mkOrder = -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" + { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" , outerCompositeMyBoolean :: !(Maybe Bool) -- ^ "my_boolean" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON OuterComposite instance A.FromJSON OuterComposite where - parseJSON = A.withObject "OuterComposite" $ \o -> - OuterComposite - <$> (o .:? "my_number") - <*> (o .:? "my_string") - <*> (o .:? "my_boolean") + parseJSON = + A.withObject "OuterComposite" $ \o -> + OuterComposite <$> (o .:? "my_number") <*> (o .:? "my_string") <*> + (o .:? "my_boolean") -- | ToJSON OuterComposite instance A.ToJSON OuterComposite where toJSON OuterComposite {..} = - _omitNulls + _omitNulls [ "my_number" .= outerCompositeMyNumber , "my_string" .= outerCompositeMyString , "my_boolean" .= outerCompositeMyBoolean ] - -- | Construct a value of type 'OuterComposite' (by applying it's required fields, if any) -mkOuterComposite - :: OuterComposite +mkOuterComposite :: OuterComposite mkOuterComposite = OuterComposite { outerCompositeMyNumber = Nothing @@ -1200,29 +1104,27 @@ mkOuterComposite = -- ** Pet -- | Pet data Pet = Pet - { petId :: !(Maybe Integer) -- ^ "id" - , petCategory :: !(Maybe Category) -- ^ "category" - , petName :: !(Text) -- ^ /Required/ "name" + { petId :: !(Maybe Integer) -- ^ "id" + , petCategory :: !(Maybe Category) -- ^ "category" + , petName :: !(Text) -- ^ /Required/ "name" , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" - , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store + , petTags :: !(Maybe [Tag]) -- ^ "tags" + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Pet instance A.FromJSON Pet where - parseJSON = A.withObject "Pet" $ \o -> - Pet - <$> (o .:? "id") - <*> (o .:? "category") - <*> (o .: "name") - <*> (o .: "photoUrls") - <*> (o .:? "tags") - <*> (o .:? "status") + parseJSON = + A.withObject "Pet" $ \o -> + Pet <$> (o .:? "id") <*> (o .:? "category") <*> (o .: "name") <*> + (o .: "photoUrls") <*> + (o .:? "tags") <*> + (o .:? "status") -- | ToJSON Pet instance A.ToJSON Pet where toJSON Pet {..} = - _omitNulls + _omitNulls [ "id" .= petId , "category" .= petCategory , "name" .= petName @@ -1231,11 +1133,10 @@ instance A.ToJSON Pet where , "status" .= petStatus ] - -- | Construct a value of type 'Pet' (by applying it's required fields, if any) -mkPet - :: Text -- ^ 'petName' - -> [Text] -- ^ 'petPhotoUrls' +mkPet :: + Text -- ^ 'petName' + -> [Text] -- ^ 'petPhotoUrls' -> Pet mkPet petName petPhotoUrls = Pet @@ -1256,28 +1157,19 @@ data ReadOnlyFirst = ReadOnlyFirst -- | FromJSON ReadOnlyFirst instance A.FromJSON ReadOnlyFirst where - parseJSON = A.withObject "ReadOnlyFirst" $ \o -> - ReadOnlyFirst - <$> (o .:? "bar") - <*> (o .:? "baz") + parseJSON = + A.withObject "ReadOnlyFirst" $ \o -> + ReadOnlyFirst <$> (o .:? "bar") <*> (o .:? "baz") -- | ToJSON ReadOnlyFirst instance A.ToJSON ReadOnlyFirst where toJSON ReadOnlyFirst {..} = - _omitNulls - [ "bar" .= readOnlyFirstBar - , "baz" .= readOnlyFirstBaz - ] - + _omitNulls ["bar" .= readOnlyFirstBar, "baz" .= readOnlyFirstBaz] -- | Construct a value of type 'ReadOnlyFirst' (by applying it's required fields, if any) -mkReadOnlyFirst - :: ReadOnlyFirst +mkReadOnlyFirst :: ReadOnlyFirst mkReadOnlyFirst = - ReadOnlyFirst - { readOnlyFirstBar = Nothing - , readOnlyFirstBaz = Nothing - } + ReadOnlyFirst {readOnlyFirstBar = Nothing, readOnlyFirstBaz = Nothing} -- ** SpecialModelName -- | SpecialModelName @@ -1287,116 +1179,86 @@ data SpecialModelName = SpecialModelName -- | FromJSON SpecialModelName instance A.FromJSON SpecialModelName where - parseJSON = A.withObject "SpecialModelName" $ \o -> - SpecialModelName - <$> (o .:? "$special[property.name]") + parseJSON = + A.withObject "SpecialModelName" $ \o -> + SpecialModelName <$> (o .:? "$special[property.name]") -- | ToJSON SpecialModelName instance A.ToJSON SpecialModelName where toJSON SpecialModelName {..} = - _omitNulls - [ "$special[property.name]" .= specialModelNameSpecialPropertyName - ] - + _omitNulls + ["$special[property.name]" .= specialModelNameSpecialPropertyName] -- | Construct a value of type 'SpecialModelName' (by applying it's required fields, if any) -mkSpecialModelName - :: SpecialModelName +mkSpecialModelName :: SpecialModelName mkSpecialModelName = - SpecialModelName - { specialModelNameSpecialPropertyName = Nothing - } + SpecialModelName {specialModelNameSpecialPropertyName = Nothing} -- ** StringBooleanMap -- | StringBooleanMap data StringBooleanMap = StringBooleanMap - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON StringBooleanMap instance A.FromJSON StringBooleanMap where - parseJSON = A.withObject "StringBooleanMap" $ \o -> - pure StringBooleanMap - + parseJSON = A.withObject "StringBooleanMap" $ \o -> pure StringBooleanMap -- | ToJSON StringBooleanMap instance A.ToJSON StringBooleanMap where - toJSON StringBooleanMap = - _omitNulls - [ - ] - + toJSON StringBooleanMap = _omitNulls [] -- | Construct a value of type 'StringBooleanMap' (by applying it's required fields, if any) -mkStringBooleanMap - :: StringBooleanMap -mkStringBooleanMap = - StringBooleanMap - { - } +mkStringBooleanMap :: StringBooleanMap +mkStringBooleanMap = StringBooleanMap {} -- ** Tag -- | Tag data Tag = Tag - { tagId :: !(Maybe Integer) -- ^ "id" + { tagId :: !(Maybe Integer) -- ^ "id" , tagName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Tag instance A.FromJSON Tag where - parseJSON = A.withObject "Tag" $ \o -> - Tag - <$> (o .:? "id") - <*> (o .:? "name") + parseJSON = A.withObject "Tag" $ \o -> Tag <$> (o .:? "id") <*> (o .:? "name") -- | ToJSON Tag instance A.ToJSON Tag where - toJSON Tag {..} = - _omitNulls - [ "id" .= tagId - , "name" .= tagName - ] - + toJSON Tag {..} = _omitNulls ["id" .= tagId, "name" .= tagName] -- | Construct a value of type 'Tag' (by applying it's required fields, if any) -mkTag - :: Tag -mkTag = - Tag - { tagId = Nothing - , tagName = Nothing - } +mkTag :: Tag +mkTag = Tag {tagId = Nothing, tagName = Nothing} -- ** User -- | User data User = User - { userId :: !(Maybe Integer) -- ^ "id" - , userUsername :: !(Maybe Text) -- ^ "username" - , userFirstName :: !(Maybe Text) -- ^ "firstName" - , userLastName :: !(Maybe Text) -- ^ "lastName" - , userEmail :: !(Maybe Text) -- ^ "email" - , userPassword :: !(Maybe Text) -- ^ "password" - , userPhone :: !(Maybe Text) -- ^ "phone" + { userId :: !(Maybe Integer) -- ^ "id" + , userUsername :: !(Maybe Text) -- ^ "username" + , userFirstName :: !(Maybe Text) -- ^ "firstName" + , userLastName :: !(Maybe Text) -- ^ "lastName" + , userEmail :: !(Maybe Text) -- ^ "email" + , userPassword :: !(Maybe Text) -- ^ "password" + , userPhone :: !(Maybe Text) -- ^ "phone" , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON User instance A.FromJSON User where - parseJSON = A.withObject "User" $ \o -> - User - <$> (o .:? "id") - <*> (o .:? "username") - <*> (o .:? "firstName") - <*> (o .:? "lastName") - <*> (o .:? "email") - <*> (o .:? "password") - <*> (o .:? "phone") - <*> (o .:? "userStatus") + parseJSON = + A.withObject "User" $ \o -> + User <$> (o .:? "id") <*> (o .:? "username") <*> (o .:? "firstName") <*> + (o .:? "lastName") <*> + (o .:? "email") <*> + (o .:? "password") <*> + (o .:? "phone") <*> + (o .:? "userStatus") -- | ToJSON User instance A.ToJSON User where toJSON User {..} = - _omitNulls + _omitNulls [ "id" .= userId , "username" .= userUsername , "firstName" .= userFirstName @@ -1407,10 +1269,8 @@ instance A.ToJSON User where , "userStatus" .= userUserStatus ] - -- | Construct a value of type 'User' (by applying it's required fields, if any) -mkUser - :: User +mkUser :: User mkUser = User { userId = Nothing @@ -1423,41 +1283,46 @@ mkUser = , userUserStatus = Nothing } - -- * Enums - - -- ** E'ArrayEnum - -- | Enum of 'Text' data E'ArrayEnum = E'ArrayEnum'Fish -- ^ @"fish"@ | E'ArrayEnum'Crab -- ^ @"crab"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'ArrayEnum where toJSON = A.toJSON . fromE'ArrayEnum -instance A.FromJSON E'ArrayEnum where parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o -instance WH.ToHttpApiData E'ArrayEnum where toQueryParam = WH.toQueryParam . fromE'ArrayEnum -instance WH.FromHttpApiData E'ArrayEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum -instance MimeRender MimeMultipartFormData E'ArrayEnum where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'ArrayEnum where + toJSON = A.toJSON . fromE'ArrayEnum + +instance A.FromJSON E'ArrayEnum where + parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o + +instance WH.ToHttpApiData E'ArrayEnum where + toQueryParam = WH.toQueryParam . fromE'ArrayEnum + +instance WH.FromHttpApiData E'ArrayEnum where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum + +instance MimeRender MimeMultipartFormData E'ArrayEnum where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'ArrayEnum' enum fromE'ArrayEnum :: E'ArrayEnum -> Text -fromE'ArrayEnum = \case - E'ArrayEnum'Fish -> "fish" - E'ArrayEnum'Crab -> "crab" +fromE'ArrayEnum = + \case + E'ArrayEnum'Fish -> "fish" + E'ArrayEnum'Crab -> "crab" -- | parse 'E'ArrayEnum' enum toE'ArrayEnum :: Text -> P.Either String E'ArrayEnum -toE'ArrayEnum = \case - "fish" -> P.Right E'ArrayEnum'Fish - "crab" -> P.Right E'ArrayEnum'Crab - s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s - +toE'ArrayEnum = + \case + "fish" -> P.Right E'ArrayEnum'Fish + "crab" -> P.Right E'ArrayEnum'Crab + s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s -- ** E'EnumFormString - --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString = E'EnumFormString'_abc -- ^ @"_abc"@ @@ -1465,142 +1330,194 @@ data E'EnumFormString | E'EnumFormString'_xyz -- ^ @"(xyz)"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumFormString where toJSON = A.toJSON . fromE'EnumFormString -instance A.FromJSON E'EnumFormString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumFormString where toQueryParam = WH.toQueryParam . fromE'EnumFormString -instance WH.FromHttpApiData E'EnumFormString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString -instance MimeRender MimeMultipartFormData E'EnumFormString where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumFormString where + toJSON = A.toJSON . fromE'EnumFormString + +instance A.FromJSON E'EnumFormString where + parseJSON o = + P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumFormString where + toQueryParam = WH.toQueryParam . fromE'EnumFormString + +instance WH.FromHttpApiData E'EnumFormString where + parseQueryParam o = + WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString + +instance MimeRender MimeMultipartFormData E'EnumFormString where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumFormString' enum fromE'EnumFormString :: E'EnumFormString -> Text -fromE'EnumFormString = \case - E'EnumFormString'_abc -> "_abc" - E'EnumFormString'_efg -> "-efg" - E'EnumFormString'_xyz -> "(xyz)" +fromE'EnumFormString = + \case + E'EnumFormString'_abc -> "_abc" + E'EnumFormString'_efg -> "-efg" + E'EnumFormString'_xyz -> "(xyz)" -- | parse 'E'EnumFormString' enum toE'EnumFormString :: Text -> P.Either String E'EnumFormString -toE'EnumFormString = \case - "_abc" -> P.Right E'EnumFormString'_abc - "-efg" -> P.Right E'EnumFormString'_efg - "(xyz)" -> P.Right E'EnumFormString'_xyz - s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s - +toE'EnumFormString = + \case + "_abc" -> P.Right E'EnumFormString'_abc + "-efg" -> P.Right E'EnumFormString'_efg + "(xyz)" -> P.Right E'EnumFormString'_xyz + s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s -- ** E'EnumFormStringArray - -- | Enum of 'Text' data E'EnumFormStringArray = E'EnumFormStringArray'GreaterThan -- ^ @">"@ | E'EnumFormStringArray'Dollar -- ^ @"$"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumFormStringArray where toJSON = A.toJSON . fromE'EnumFormStringArray -instance A.FromJSON E'EnumFormStringArray where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormStringArray =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumFormStringArray where toQueryParam = WH.toQueryParam . fromE'EnumFormStringArray -instance WH.FromHttpApiData E'EnumFormStringArray where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormStringArray -instance MimeRender MimeMultipartFormData E'EnumFormStringArray where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumFormStringArray where + toJSON = A.toJSON . fromE'EnumFormStringArray + +instance A.FromJSON E'EnumFormStringArray where + parseJSON o = + P.either P.fail (pure . P.id) . toE'EnumFormStringArray =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumFormStringArray where + toQueryParam = WH.toQueryParam . fromE'EnumFormStringArray + +instance WH.FromHttpApiData E'EnumFormStringArray where + parseQueryParam o = + WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormStringArray + +instance MimeRender MimeMultipartFormData E'EnumFormStringArray where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumFormStringArray' enum fromE'EnumFormStringArray :: E'EnumFormStringArray -> Text -fromE'EnumFormStringArray = \case - E'EnumFormStringArray'GreaterThan -> ">" - E'EnumFormStringArray'Dollar -> "$" +fromE'EnumFormStringArray = + \case + E'EnumFormStringArray'GreaterThan -> ">" + E'EnumFormStringArray'Dollar -> "$" -- | parse 'E'EnumFormStringArray' enum toE'EnumFormStringArray :: Text -> P.Either String E'EnumFormStringArray -toE'EnumFormStringArray = \case - ">" -> P.Right E'EnumFormStringArray'GreaterThan - "$" -> P.Right E'EnumFormStringArray'Dollar - s -> P.Left $ "toE'EnumFormStringArray: enum parse failure: " P.++ P.show s - +toE'EnumFormStringArray = + \case + ">" -> P.Right E'EnumFormStringArray'GreaterThan + "$" -> P.Right E'EnumFormStringArray'Dollar + s -> P.Left $ "toE'EnumFormStringArray: enum parse failure: " P.++ P.show s -- ** E'EnumInteger - -- | Enum of 'Int' data E'EnumInteger = E'EnumInteger'Num1 -- ^ @1@ | E'EnumInteger'NumMinus_1 -- ^ @-1@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumInteger where toJSON = A.toJSON . fromE'EnumInteger -instance A.FromJSON E'EnumInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumInteger where toQueryParam = WH.toQueryParam . fromE'EnumInteger -instance WH.FromHttpApiData E'EnumInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger -instance MimeRender MimeMultipartFormData E'EnumInteger where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumInteger where + toJSON = A.toJSON . fromE'EnumInteger + +instance A.FromJSON E'EnumInteger where + parseJSON o = + P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumInteger where + toQueryParam = WH.toQueryParam . fromE'EnumInteger + +instance WH.FromHttpApiData E'EnumInteger where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger + +instance MimeRender MimeMultipartFormData E'EnumInteger where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumInteger' enum fromE'EnumInteger :: E'EnumInteger -> Int -fromE'EnumInteger = \case - E'EnumInteger'Num1 -> 1 - E'EnumInteger'NumMinus_1 -> -1 +fromE'EnumInteger = + \case + E'EnumInteger'Num1 -> 1 + E'EnumInteger'NumMinus_1 -> -1 -- | parse 'E'EnumInteger' enum toE'EnumInteger :: Int -> P.Either String E'EnumInteger -toE'EnumInteger = \case - 1 -> P.Right E'EnumInteger'Num1 - -1 -> P.Right E'EnumInteger'NumMinus_1 - s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s - +toE'EnumInteger = + \case + 1 -> P.Right E'EnumInteger'Num1 + -1 -> P.Right E'EnumInteger'NumMinus_1 + s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s -- ** E'EnumNumber - -- | Enum of 'Double' data E'EnumNumber = E'EnumNumber'Num1_Dot_1 -- ^ @1.1@ | E'EnumNumber'NumMinus_1_Dot_2 -- ^ @-1.2@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumNumber where toJSON = A.toJSON . fromE'EnumNumber -instance A.FromJSON E'EnumNumber where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumNumber where toQueryParam = WH.toQueryParam . fromE'EnumNumber -instance WH.FromHttpApiData E'EnumNumber where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber -instance MimeRender MimeMultipartFormData E'EnumNumber where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumNumber where + toJSON = A.toJSON . fromE'EnumNumber + +instance A.FromJSON E'EnumNumber where + parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumNumber where + toQueryParam = WH.toQueryParam . fromE'EnumNumber + +instance WH.FromHttpApiData E'EnumNumber where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber + +instance MimeRender MimeMultipartFormData E'EnumNumber where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumNumber' enum fromE'EnumNumber :: E'EnumNumber -> Double -fromE'EnumNumber = \case - E'EnumNumber'Num1_Dot_1 -> 1.1 - E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 +fromE'EnumNumber = + \case + E'EnumNumber'Num1_Dot_1 -> 1.1 + E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 -- | parse 'E'EnumNumber' enum toE'EnumNumber :: Double -> P.Either String E'EnumNumber -toE'EnumNumber = \case - 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 - -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 - s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s - +toE'EnumNumber = + \case + 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 + -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 + s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s -- ** E'EnumQueryInteger - -- | Enum of 'Int' data E'EnumQueryInteger = E'EnumQueryInteger'Num1 -- ^ @1@ | E'EnumQueryInteger'NumMinus_2 -- ^ @-2@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumQueryInteger where toJSON = A.toJSON . fromE'EnumQueryInteger -instance A.FromJSON E'EnumQueryInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumQueryInteger where toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger -instance WH.FromHttpApiData E'EnumQueryInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger -instance MimeRender MimeMultipartFormData E'EnumQueryInteger where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumQueryInteger where + toJSON = A.toJSON . fromE'EnumQueryInteger + +instance A.FromJSON E'EnumQueryInteger where + parseJSON o = + P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumQueryInteger where + toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger + +instance WH.FromHttpApiData E'EnumQueryInteger where + parseQueryParam o = + WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger + +instance MimeRender MimeMultipartFormData E'EnumQueryInteger where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumQueryInteger' enum fromE'EnumQueryInteger :: E'EnumQueryInteger -> Int -fromE'EnumQueryInteger = \case - E'EnumQueryInteger'Num1 -> 1 - E'EnumQueryInteger'NumMinus_2 -> -2 +fromE'EnumQueryInteger = + \case + E'EnumQueryInteger'Num1 -> 1 + E'EnumQueryInteger'NumMinus_2 -> -2 -- | parse 'E'EnumQueryInteger' enum toE'EnumQueryInteger :: Int -> P.Either String E'EnumQueryInteger -toE'EnumQueryInteger = \case - 1 -> P.Right E'EnumQueryInteger'Num1 - -2 -> P.Right E'EnumQueryInteger'NumMinus_2 - s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s - +toE'EnumQueryInteger = + \case + 1 -> P.Right E'EnumQueryInteger'Num1 + -2 -> P.Right E'EnumQueryInteger'NumMinus_2 + s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s -- ** E'EnumString - -- | Enum of 'Text' data E'EnumString = E'EnumString'UPPER -- ^ @"UPPER"@ @@ -1608,87 +1525,114 @@ data E'EnumString | E'EnumString'Empty -- ^ @""@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumString where toJSON = A.toJSON . fromE'EnumString -instance A.FromJSON E'EnumString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o -instance WH.ToHttpApiData E'EnumString where toQueryParam = WH.toQueryParam . fromE'EnumString -instance WH.FromHttpApiData E'EnumString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString -instance MimeRender MimeMultipartFormData E'EnumString where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumString where + toJSON = A.toJSON . fromE'EnumString + +instance A.FromJSON E'EnumString where + parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o + +instance WH.ToHttpApiData E'EnumString where + toQueryParam = WH.toQueryParam . fromE'EnumString + +instance WH.FromHttpApiData E'EnumString where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString + +instance MimeRender MimeMultipartFormData E'EnumString where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumString' enum fromE'EnumString :: E'EnumString -> Text -fromE'EnumString = \case - E'EnumString'UPPER -> "UPPER" - E'EnumString'Lower -> "lower" - E'EnumString'Empty -> "" +fromE'EnumString = + \case + E'EnumString'UPPER -> "UPPER" + E'EnumString'Lower -> "lower" + E'EnumString'Empty -> "" -- | parse 'E'EnumString' enum toE'EnumString :: Text -> P.Either String E'EnumString -toE'EnumString = \case - "UPPER" -> P.Right E'EnumString'UPPER - "lower" -> P.Right E'EnumString'Lower - "" -> P.Right E'EnumString'Empty - s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s - +toE'EnumString = + \case + "UPPER" -> P.Right E'EnumString'UPPER + "lower" -> P.Right E'EnumString'Lower + "" -> P.Right E'EnumString'Empty + s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s -- ** E'Inner - -- | Enum of 'Text' data E'Inner = E'Inner'UPPER -- ^ @"UPPER"@ | E'Inner'Lower -- ^ @"lower"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Inner where toJSON = A.toJSON . fromE'Inner -instance A.FromJSON E'Inner where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o -instance WH.ToHttpApiData E'Inner where toQueryParam = WH.toQueryParam . fromE'Inner -instance WH.FromHttpApiData E'Inner where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner -instance MimeRender MimeMultipartFormData E'Inner where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Inner where + toJSON = A.toJSON . fromE'Inner + +instance A.FromJSON E'Inner where + parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o + +instance WH.ToHttpApiData E'Inner where + toQueryParam = WH.toQueryParam . fromE'Inner + +instance WH.FromHttpApiData E'Inner where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner + +instance MimeRender MimeMultipartFormData E'Inner where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Inner' enum fromE'Inner :: E'Inner -> Text -fromE'Inner = \case - E'Inner'UPPER -> "UPPER" - E'Inner'Lower -> "lower" +fromE'Inner = + \case + E'Inner'UPPER -> "UPPER" + E'Inner'Lower -> "lower" -- | parse 'E'Inner' enum toE'Inner :: Text -> P.Either String E'Inner -toE'Inner = \case - "UPPER" -> P.Right E'Inner'UPPER - "lower" -> P.Right E'Inner'Lower - s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s - +toE'Inner = + \case + "UPPER" -> P.Right E'Inner'UPPER + "lower" -> P.Right E'Inner'Lower + s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s -- ** E'JustSymbol - -- | Enum of 'Text' data E'JustSymbol = E'JustSymbol'Greater_Than_Or_Equal_To -- ^ @">="@ | E'JustSymbol'Dollar -- ^ @"$"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'JustSymbol where toJSON = A.toJSON . fromE'JustSymbol -instance A.FromJSON E'JustSymbol where parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o -instance WH.ToHttpApiData E'JustSymbol where toQueryParam = WH.toQueryParam . fromE'JustSymbol -instance WH.FromHttpApiData E'JustSymbol where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol -instance MimeRender MimeMultipartFormData E'JustSymbol where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'JustSymbol where + toJSON = A.toJSON . fromE'JustSymbol + +instance A.FromJSON E'JustSymbol where + parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o + +instance WH.ToHttpApiData E'JustSymbol where + toQueryParam = WH.toQueryParam . fromE'JustSymbol + +instance WH.FromHttpApiData E'JustSymbol where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol + +instance MimeRender MimeMultipartFormData E'JustSymbol where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'JustSymbol' enum fromE'JustSymbol :: E'JustSymbol -> Text -fromE'JustSymbol = \case - E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" - E'JustSymbol'Dollar -> "$" +fromE'JustSymbol = + \case + E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" + E'JustSymbol'Dollar -> "$" -- | parse 'E'JustSymbol' enum toE'JustSymbol :: Text -> P.Either String E'JustSymbol -toE'JustSymbol = \case - ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To - "$" -> P.Right E'JustSymbol'Dollar - s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s - +toE'JustSymbol = + \case + ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To + "$" -> P.Right E'JustSymbol'Dollar + s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s -- ** E'Status - --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Order Status data E'Status = E'Status'Placed -- ^ @"placed"@ @@ -1696,31 +1640,40 @@ data E'Status | E'Status'Delivered -- ^ @"delivered"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Status where toJSON = A.toJSON . fromE'Status -instance A.FromJSON E'Status where parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o -instance WH.ToHttpApiData E'Status where toQueryParam = WH.toQueryParam . fromE'Status -instance WH.FromHttpApiData E'Status where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status -instance MimeRender MimeMultipartFormData E'Status where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Status where + toJSON = A.toJSON . fromE'Status + +instance A.FromJSON E'Status where + parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o + +instance WH.ToHttpApiData E'Status where + toQueryParam = WH.toQueryParam . fromE'Status + +instance WH.FromHttpApiData E'Status where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status + +instance MimeRender MimeMultipartFormData E'Status where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Status' enum fromE'Status :: E'Status -> Text -fromE'Status = \case - E'Status'Placed -> "placed" - E'Status'Approved -> "approved" - E'Status'Delivered -> "delivered" +fromE'Status = + \case + E'Status'Placed -> "placed" + E'Status'Approved -> "approved" + E'Status'Delivered -> "delivered" -- | parse 'E'Status' enum toE'Status :: Text -> P.Either String E'Status -toE'Status = \case - "placed" -> P.Right E'Status'Placed - "approved" -> P.Right E'Status'Approved - "delivered" -> P.Right E'Status'Delivered - s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s - +toE'Status = + \case + "placed" -> P.Right E'Status'Placed + "approved" -> P.Right E'Status'Approved + "delivered" -> P.Right E'Status'Delivered + s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s -- ** E'Status2 - --- | Enum of 'Text' . +-- | Enum of 'Text' . -- pet status in the store data E'Status2 = E'Status2'Available -- ^ @"available"@ @@ -1728,30 +1681,39 @@ data E'Status2 | E'Status2'Sold -- ^ @"sold"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Status2 where toJSON = A.toJSON . fromE'Status2 -instance A.FromJSON E'Status2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o -instance WH.ToHttpApiData E'Status2 where toQueryParam = WH.toQueryParam . fromE'Status2 -instance WH.FromHttpApiData E'Status2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 -instance MimeRender MimeMultipartFormData E'Status2 where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Status2 where + toJSON = A.toJSON . fromE'Status2 + +instance A.FromJSON E'Status2 where + parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o + +instance WH.ToHttpApiData E'Status2 where + toQueryParam = WH.toQueryParam . fromE'Status2 + +instance WH.FromHttpApiData E'Status2 where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 + +instance MimeRender MimeMultipartFormData E'Status2 where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Status2' enum fromE'Status2 :: E'Status2 -> Text -fromE'Status2 = \case - E'Status2'Available -> "available" - E'Status2'Pending -> "pending" - E'Status2'Sold -> "sold" +fromE'Status2 = + \case + E'Status2'Available -> "available" + E'Status2'Pending -> "pending" + E'Status2'Sold -> "sold" -- | parse 'E'Status2' enum toE'Status2 :: Text -> P.Either String E'Status2 -toE'Status2 = \case - "available" -> P.Right E'Status2'Available - "pending" -> P.Right E'Status2'Pending - "sold" -> P.Right E'Status2'Sold - s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s - +toE'Status2 = + \case + "available" -> P.Right E'Status2'Available + "pending" -> P.Right E'Status2'Pending + "sold" -> P.Right E'Status2'Sold + s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s -- ** EnumClass - -- | Enum of 'Text' data EnumClass = EnumClass'_abc -- ^ @"_abc"@ @@ -1759,30 +1721,39 @@ data EnumClass | EnumClass'_xyz -- ^ @"(xyz)"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON EnumClass where toJSON = A.toJSON . fromEnumClass -instance A.FromJSON EnumClass where parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o -instance WH.ToHttpApiData EnumClass where toQueryParam = WH.toQueryParam . fromEnumClass -instance WH.FromHttpApiData EnumClass where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass -instance MimeRender MimeMultipartFormData EnumClass where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON EnumClass where + toJSON = A.toJSON . fromEnumClass + +instance A.FromJSON EnumClass where + parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o + +instance WH.ToHttpApiData EnumClass where + toQueryParam = WH.toQueryParam . fromEnumClass + +instance WH.FromHttpApiData EnumClass where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass + +instance MimeRender MimeMultipartFormData EnumClass where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'EnumClass' enum fromEnumClass :: EnumClass -> Text -fromEnumClass = \case - EnumClass'_abc -> "_abc" - EnumClass'_efg -> "-efg" - EnumClass'_xyz -> "(xyz)" +fromEnumClass = + \case + EnumClass'_abc -> "_abc" + EnumClass'_efg -> "-efg" + EnumClass'_xyz -> "(xyz)" -- | parse 'EnumClass' enum toEnumClass :: Text -> P.Either String EnumClass -toEnumClass = \case - "_abc" -> P.Right EnumClass'_abc - "-efg" -> P.Right EnumClass'_efg - "(xyz)" -> P.Right EnumClass'_xyz - s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s - +toEnumClass = + \case + "_abc" -> P.Right EnumClass'_abc + "-efg" -> P.Right EnumClass'_efg + "(xyz)" -> P.Right EnumClass'_xyz + s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s -- ** OuterEnum - -- | Enum of 'Text' data OuterEnum = OuterEnum'Placed -- ^ @"placed"@ @@ -1790,30 +1761,39 @@ data OuterEnum | OuterEnum'Delivered -- ^ @"delivered"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON OuterEnum where toJSON = A.toJSON . fromOuterEnum -instance A.FromJSON OuterEnum where parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o -instance WH.ToHttpApiData OuterEnum where toQueryParam = WH.toQueryParam . fromOuterEnum -instance WH.FromHttpApiData OuterEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum -instance MimeRender MimeMultipartFormData OuterEnum where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON OuterEnum where + toJSON = A.toJSON . fromOuterEnum + +instance A.FromJSON OuterEnum where + parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o + +instance WH.ToHttpApiData OuterEnum where + toQueryParam = WH.toQueryParam . fromOuterEnum + +instance WH.FromHttpApiData OuterEnum where + parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum + +instance MimeRender MimeMultipartFormData OuterEnum where + mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'OuterEnum' enum fromOuterEnum :: OuterEnum -> Text -fromOuterEnum = \case - OuterEnum'Placed -> "placed" - OuterEnum'Approved -> "approved" - OuterEnum'Delivered -> "delivered" +fromOuterEnum = + \case + OuterEnum'Placed -> "placed" + OuterEnum'Approved -> "approved" + OuterEnum'Delivered -> "delivered" -- | parse 'OuterEnum' enum toOuterEnum :: Text -> P.Either String OuterEnum -toOuterEnum = \case - "placed" -> P.Right OuterEnum'Placed - "approved" -> P.Right OuterEnum'Approved - "delivered" -> P.Right OuterEnum'Delivered - s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s - +toOuterEnum = + \case + "placed" -> P.Right OuterEnum'Placed + "approved" -> P.Right OuterEnum'Approved + "delivered" -> P.Right OuterEnum'Delivered + s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s -- * Auth Methods - -- ** AuthApiKeyApiKey data AuthApiKeyApiKey = AuthApiKeyApiKey Text -- ^ secret @@ -1823,8 +1803,8 @@ instance AuthMethod AuthApiKeyApiKey where applyAuthMethod _ a@(AuthApiKeyApiKey secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("api_key", secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("api_key", secret) & + L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req -- ** AuthApiKeyApiKeyQuery @@ -1836,23 +1816,25 @@ instance AuthMethod AuthApiKeyApiKeyQuery where applyAuthMethod _ a@(AuthApiKeyApiKeyQuery secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setQuery` toQuery ("api_key_query", Just secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setQuery` toQuery ("api_key_query", Just secret) & + L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req -- ** AuthBasicHttpBasicTest data AuthBasicHttpBasicTest = - AuthBasicHttpBasicTest B.ByteString B.ByteString -- ^ username password + AuthBasicHttpBasicTest B.ByteString + B.ByteString -- ^ username password deriving (P.Eq, P.Show, P.Typeable) instance AuthMethod AuthBasicHttpBasicTest where applyAuthMethod _ a@(AuthBasicHttpBasicTest user pw) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) & + L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req - where cred = BC.append "Basic " (B64.encode $ BC.concat [ user, ":", pw ]) + where + cred = BC.append "Basic " (B64.encode $ BC.concat [user, ":", pw]) -- ** AuthOAuthPetstoreAuth data AuthOAuthPetstoreAuth = @@ -1863,7 +1845,6 @@ instance AuthMethod AuthOAuthPetstoreAuth where applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) - & L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) & + L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req - diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index 2fd47679ee3..8ce41ab1362 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -7,660 +7,708 @@ 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 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 #-} +{-# 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 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 Prelude (($), (.),(<$>),(<*>),(=<<),Maybe(..),Bool(..),Char,Double,FilePath,Float,Int,Integer,String,fmap,undefined,mempty,maybe,pure,Monad,Applicative,Functor) -import qualified Prelude as P +import Data.Text (Text) -import OpenAPIPetstore.Model -import OpenAPIPetstore.Core +import Prelude (Applicative, Bool (..), Char, Double, + FilePath, Float, Functor, Int, Integer, + Maybe (..), Monad, String, fmap, maybe, + mempty, pure, undefined, ($), (.), + (<$>), (<*>), (=<<)) +import qualified Prelude as P +import OpenAPIPetstore.Core +import OpenAPIPetstore.Model -- * AdditionalPropertiesClass - -- | 'additionalPropertiesClassMapProperty' Lens -additionalPropertiesClassMapPropertyL :: Lens_' AdditionalPropertiesClass (Maybe (Map.Map String Text)) -additionalPropertiesClassMapPropertyL f AdditionalPropertiesClass{..} = (\additionalPropertiesClassMapProperty -> AdditionalPropertiesClass { additionalPropertiesClassMapProperty, ..} ) <$> f additionalPropertiesClassMapProperty -{-# INLINE additionalPropertiesClassMapPropertyL #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} - - +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 #-} - - +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 #-} - - +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} - - +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 #-} - - +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - - +enumTestOuterEnumL f EnumTest {..} = + (\enumTestOuterEnum -> EnumTest {enumTestOuterEnum, ..}) <$> + f enumTestOuterEnum +{-# INLINE enumTestOuterEnumL #-} -- * File - -- | 'fileSourceUri' Lens fileSourceUriL :: Lens_' File (Maybe Text) -fileSourceUriL f File{..} = (\fileSourceUri -> File { fileSourceUri, ..} ) <$> f fileSourceUri -{-# INLINE fileSourceUriL #-} - - +fileSourceUriL f File {..} = + (\fileSourceUri -> File {fileSourceUri, ..}) <$> f fileSourceUri +{-# INLINE fileSourceUriL #-} -- * FileSchemaTestClass - -- | 'fileSchemaTestClassFile' Lens fileSchemaTestClassFileL :: Lens_' FileSchemaTestClass (Maybe File) -fileSchemaTestClassFileL f FileSchemaTestClass{..} = (\fileSchemaTestClassFile -> FileSchemaTestClass { fileSchemaTestClassFile, ..} ) <$> f fileSchemaTestClassFile -{-# INLINE fileSchemaTestClassFileL #-} +fileSchemaTestClassFileL f FileSchemaTestClass {..} = + (\fileSchemaTestClassFile -> FileSchemaTestClass {fileSchemaTestClassFile, ..}) <$> + f fileSchemaTestClassFile +{-# INLINE fileSchemaTestClassFileL #-} -- | 'fileSchemaTestClassFiles' Lens fileSchemaTestClassFilesL :: Lens_' FileSchemaTestClass (Maybe [File]) -fileSchemaTestClassFilesL f FileSchemaTestClass{..} = (\fileSchemaTestClassFiles -> FileSchemaTestClass { fileSchemaTestClassFiles, ..} ) <$> f fileSchemaTestClassFiles -{-# INLINE fileSchemaTestClassFilesL #-} - - +fileSchemaTestClassFilesL f FileSchemaTestClass {..} = + (\fileSchemaTestClassFiles -> + FileSchemaTestClass {fileSchemaTestClassFiles, ..}) <$> + f fileSchemaTestClassFiles +{-# INLINE fileSchemaTestClassFilesL #-} -- * FormatTest - -- | 'formatTestInteger' Lens formatTestIntegerL :: Lens_' FormatTest (Maybe Int) -formatTestIntegerL f FormatTest{..} = (\formatTestInteger -> FormatTest { formatTestInteger, ..} ) <$> f formatTestInteger -{-# INLINE formatTestIntegerL #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} +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 #-} +mapTestMapOfEnumStringL f MapTest {..} = + (\mapTestMapOfEnumString -> MapTest {mapTestMapOfEnumString, ..}) <$> + f mapTestMapOfEnumString +{-# INLINE mapTestMapOfEnumStringL #-} -- | 'mapTestDirectMap' Lens mapTestDirectMapL :: Lens_' MapTest (Maybe (Map.Map String Bool)) -mapTestDirectMapL f MapTest{..} = (\mapTestDirectMap -> MapTest { mapTestDirectMap, ..} ) <$> f mapTestDirectMap -{-# INLINE mapTestDirectMapL #-} +mapTestDirectMapL f MapTest {..} = + (\mapTestDirectMap -> MapTest {mapTestDirectMap, ..}) <$> f mapTestDirectMap +{-# INLINE mapTestDirectMapL #-} -- | 'mapTestIndirectMap' Lens mapTestIndirectMapL :: Lens_' MapTest (Maybe StringBooleanMap) -mapTestIndirectMapL f MapTest{..} = (\mapTestIndirectMap -> MapTest { mapTestIndirectMap, ..} ) <$> f mapTestIndirectMap -{-# INLINE mapTestIndirectMapL #-} - - +mapTestIndirectMapL f MapTest {..} = + (\mapTestIndirectMap -> MapTest {mapTestIndirectMap, ..}) <$> + f mapTestIndirectMap +{-# INLINE mapTestIndirectMapL #-} -- * MixedPropertiesAndAdditionalPropertiesClass - -- | 'mixedPropertiesAndAdditionalPropertiesClassUuid' Lens -mixedPropertiesAndAdditionalPropertiesClassUuidL :: Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe Text) -mixedPropertiesAndAdditionalPropertiesClassUuidL f MixedPropertiesAndAdditionalPropertiesClass{..} = (\mixedPropertiesAndAdditionalPropertiesClassUuid -> MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid, ..} ) <$> f mixedPropertiesAndAdditionalPropertiesClassUuid -{-# INLINE mixedPropertiesAndAdditionalPropertiesClassUuidL #-} +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 #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} - - +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} - - +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - - +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 #-} +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 #-} - - +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 #-} - - +specialModelNameSpecialPropertyNameL f SpecialModelName {..} = + (\specialModelNameSpecialPropertyName -> + SpecialModelName {specialModelNameSpecialPropertyName, ..}) <$> + f specialModelNameSpecialPropertyName +{-# INLINE specialModelNameSpecialPropertyNameL #-} -- * StringBooleanMap - - - -- * Tag - -- | 'tagId' Lens tagIdL :: Lens_' Tag (Maybe Integer) -tagIdL f Tag{..} = (\tagId -> Tag { tagId, ..} ) <$> f tagId -{-# INLINE tagIdL #-} +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 #-} - - +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} +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 #-} - +userUserStatusL f User {..} = + (\userUserStatus -> User {userUserStatus, ..}) <$> f userUserStatus +{-# INLINE userUserStatusL #-} diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 14cef8e188c..d00ec59c2bf 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -2,23 +2,23 @@ module Instances where -import OpenAPIPetstore.Model -import OpenAPIPetstore.Core +import OpenAPIPetstore.Core +import OpenAPIPetstore.Model -import qualified Data.Aeson as A -import qualified Data.ByteString.Lazy as BL -import qualified Data.HashMap.Strict as HM -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Time as TI -import qualified Data.Vector as V +import qualified Data.Aeson as A +import qualified Data.ByteString.Lazy as BL +import qualified Data.HashMap.Strict as HM +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Time as TI +import qualified Data.Vector as V -import Control.Monad -import Data.Char (isSpace) -import Data.List (sort) -import Test.QuickCheck +import Control.Monad +import Data.Char (isSpace) +import Data.List (sort) +import Test.QuickCheck -import ApproxEq +import ApproxEq instance Arbitrary T.Text where arbitrary = T.pack <$> arbitrary @@ -32,24 +32,24 @@ instance Arbitrary TI.UTCTime where TI.UTCTime <$> arbitrary <*> (TI.secondsToDiffTime <$> choose (0, 86401)) instance Arbitrary BL.ByteString where - arbitrary = BL.pack <$> arbitrary - shrink xs = BL.pack <$> shrink (BL.unpack xs) + arbitrary = BL.pack <$> arbitrary + shrink xs = BL.pack <$> shrink (BL.unpack xs) instance Arbitrary ByteArray where - arbitrary = ByteArray <$> arbitrary - shrink (ByteArray xs) = ByteArray <$> shrink xs + arbitrary = ByteArray <$> arbitrary + shrink (ByteArray xs) = ByteArray <$> shrink xs instance Arbitrary Binary where - arbitrary = Binary <$> arbitrary - shrink (Binary xs) = Binary <$> shrink xs + arbitrary = Binary <$> arbitrary + shrink (Binary xs) = Binary <$> shrink xs instance Arbitrary DateTime where - arbitrary = DateTime <$> arbitrary - shrink (DateTime xs) = DateTime <$> shrink xs + arbitrary = DateTime <$> arbitrary + shrink (DateTime xs) = DateTime <$> shrink xs instance Arbitrary Date where - arbitrary = Date <$> arbitrary - shrink (Date xs) = Date <$> shrink xs + arbitrary = Date <$> arbitrary + shrink (Date xs) = Date <$> shrink xs -- | A naive Arbitrary instance for A.Value: instance Arbitrary A.Value where @@ -71,11 +71,9 @@ instance Arbitrary A.Value where sizedObject n = liftM (A.object . map mapF) $ replicateM n $ (,) <$> (arbitrary :: Gen String) <*> simpleAndArrays - + -- | Checks if a given list has no duplicates in _O(n log n)_. -hasNoDups - :: (Ord a) - => [a] -> Bool +hasNoDups :: (Ord a) => [a] -> Bool hasNoDups = go Set.empty where go _ [] = True @@ -88,244 +86,269 @@ instance ApproxEq TI.Day where (=~) = (==) -- * Models - instance Arbitrary AdditionalPropertiesClass where arbitrary = - AdditionalPropertiesClass - <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) - <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) - + AdditionalPropertiesClass <$> + arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) + <*> + arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) + instance Arbitrary Animal where arbitrary = - Animal - <$> arbitrary -- animalClassName :: Text - <*> arbitrary -- animalColor :: Maybe Text - + Animal <$> arbitrary -- animalClassName :: Text + <*> + arbitrary -- animalColor :: Maybe Text + instance Arbitrary AnimalFarm where - arbitrary = - - pure AnimalFarm - + arbitrary = pure AnimalFarm + instance Arbitrary ApiResponse where arbitrary = - ApiResponse - <$> arbitrary -- apiResponseCode :: Maybe Int - <*> arbitrary -- apiResponseType :: Maybe Text - <*> arbitrary -- apiResponseMessage :: Maybe Text - + ApiResponse <$> arbitrary -- apiResponseCode :: Maybe Int + <*> + arbitrary -- apiResponseType :: Maybe Text + <*> + arbitrary -- apiResponseMessage :: Maybe Text + instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = - ArrayOfArrayOfNumberOnly - <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] - + ArrayOfArrayOfNumberOnly <$> + arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] + instance Arbitrary ArrayOfNumberOnly where arbitrary = - ArrayOfNumberOnly - <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] - + ArrayOfNumberOnly <$> + arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] + instance Arbitrary ArrayTest where arbitrary = - ArrayTest - <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] - <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] - <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] - + ArrayTest <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] + <*> + arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] + <*> + arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] + instance Arbitrary Capitalization where arbitrary = - Capitalization - <$> arbitrary -- capitalizationSmallCamel :: Maybe Text - <*> arbitrary -- capitalizationCapitalCamel :: Maybe Text - <*> arbitrary -- capitalizationSmallSnake :: Maybe Text - <*> arbitrary -- capitalizationCapitalSnake :: Maybe Text - <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text - <*> arbitrary -- capitalizationAttName :: Maybe Text - + Capitalization <$> arbitrary -- capitalizationSmallCamel :: Maybe Text + <*> + arbitrary -- capitalizationCapitalCamel :: Maybe Text + <*> + arbitrary -- capitalizationSmallSnake :: Maybe Text + <*> + arbitrary -- capitalizationCapitalSnake :: Maybe Text + <*> + arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text + <*> + arbitrary -- capitalizationAttName :: Maybe Text + instance Arbitrary Cat where arbitrary = - Cat - <$> arbitrary -- catClassName :: Text - <*> arbitrary -- catColor :: Maybe Text - <*> arbitrary -- catDeclawed :: Maybe Bool - + Cat <$> arbitrary -- catClassName :: Text + <*> + arbitrary -- catColor :: Maybe Text + <*> + arbitrary -- catDeclawed :: Maybe Bool + instance Arbitrary Category where arbitrary = - Category - <$> arbitrary -- categoryId :: Maybe Integer - <*> arbitrary -- categoryName :: Maybe Text - + Category <$> arbitrary -- categoryId :: Maybe Integer + <*> + arbitrary -- categoryName :: Maybe Text + instance Arbitrary ClassModel where - arbitrary = - ClassModel - <$> arbitrary -- classModelClass :: Maybe Text - + arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text + instance Arbitrary Client where - arbitrary = - Client - <$> arbitrary -- clientClient :: Maybe Text - + arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text + instance Arbitrary Dog where arbitrary = - Dog - <$> arbitrary -- dogClassName :: Text - <*> arbitrary -- dogColor :: Maybe Text - <*> arbitrary -- dogBreed :: Maybe Text - + Dog <$> arbitrary -- dogClassName :: Text + <*> + arbitrary -- dogColor :: Maybe Text + <*> + arbitrary -- dogBreed :: Maybe Text + instance Arbitrary EnumArrays where arbitrary = - EnumArrays - <$> arbitrary -- enumArraysJustSymbol :: Maybe Text - <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] - + EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text + <*> + arbitrary -- enumArraysArrayEnum :: Maybe [Text] + instance Arbitrary EnumTest where arbitrary = - EnumTest - <$> arbitrary -- enumTestEnumString :: Maybe Text - <*> arbitrary -- enumTestEnumStringRequired :: Text - <*> arbitrary -- enumTestEnumInteger :: Maybe Int - <*> arbitrary -- enumTestEnumNumber :: Maybe Double - <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum - + EnumTest <$> arbitrary -- enumTestEnumString :: Maybe Text + <*> + arbitrary -- enumTestEnumStringRequired :: Text + <*> + arbitrary -- enumTestEnumInteger :: Maybe Int + <*> + arbitrary -- enumTestEnumNumber :: Maybe Double + <*> + arbitrary -- enumTestOuterEnum :: Maybe OuterEnum + instance Arbitrary File where - arbitrary = - File - <$> arbitrary -- fileSourceUri :: Maybe Text - + arbitrary = File <$> arbitrary -- fileSourceUri :: Maybe Text + instance Arbitrary FileSchemaTestClass where arbitrary = - FileSchemaTestClass - <$> arbitrary -- fileSchemaTestClassFile :: Maybe File - <*> arbitrary -- fileSchemaTestClassFiles :: Maybe [File] - + FileSchemaTestClass <$> arbitrary -- fileSchemaTestClassFile :: Maybe File + <*> + arbitrary -- fileSchemaTestClassFiles :: Maybe [File] + instance Arbitrary FormatTest where arbitrary = - FormatTest - <$> arbitrary -- formatTestInteger :: Maybe Int - <*> arbitrary -- formatTestInt32 :: Maybe Int - <*> arbitrary -- formatTestInt64 :: Maybe Integer - <*> arbitrary -- formatTestNumber :: Double - <*> arbitrary -- formatTestFloat :: Maybe Float - <*> arbitrary -- formatTestDouble :: Maybe Double - <*> arbitrary -- formatTestString :: Maybe Text - <*> arbitrary -- formatTestByte :: ByteArray - <*> arbitrary -- formatTestBinary :: Maybe FilePath - <*> arbitrary -- formatTestDate :: Date - <*> arbitrary -- formatTestDateTime :: Maybe DateTime - <*> arbitrary -- formatTestUuid :: Maybe Text - <*> arbitrary -- formatTestPassword :: Text - + FormatTest <$> arbitrary -- formatTestInteger :: Maybe Int + <*> + arbitrary -- formatTestInt32 :: Maybe Int + <*> + arbitrary -- formatTestInt64 :: Maybe Integer + <*> + arbitrary -- formatTestNumber :: Double + <*> + arbitrary -- formatTestFloat :: Maybe Float + <*> + arbitrary -- formatTestDouble :: Maybe Double + <*> + arbitrary -- formatTestString :: Maybe Text + <*> + arbitrary -- formatTestByte :: ByteArray + <*> + arbitrary -- formatTestBinary :: Maybe FilePath + <*> + arbitrary -- formatTestDate :: Date + <*> + arbitrary -- formatTestDateTime :: Maybe DateTime + <*> + arbitrary -- formatTestUuid :: Maybe Text + <*> + arbitrary -- formatTestPassword :: Text + instance Arbitrary HasOnlyReadOnly where arbitrary = - HasOnlyReadOnly - <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text - <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text - + HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text + <*> + arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text + instance Arbitrary MapTest where arbitrary = - MapTest - <$> arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text)) - <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) - <*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) - <*> arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap - + MapTest <$> + arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text)) + <*> + arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) + <*> + arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) + <*> + arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap + instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = - MixedPropertiesAndAdditionalPropertiesClass - <$> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text - <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime - <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) - + MixedPropertiesAndAdditionalPropertiesClass <$> + arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text + <*> + arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime + <*> + arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) + instance Arbitrary Model200Response where arbitrary = - Model200Response - <$> arbitrary -- model200ResponseName :: Maybe Int - <*> arbitrary -- model200ResponseClass :: Maybe Text - + Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int + <*> + arbitrary -- model200ResponseClass :: Maybe Text + instance Arbitrary ModelList where - arbitrary = - ModelList - <$> arbitrary -- modelList123list :: Maybe Text - + arbitrary = ModelList <$> arbitrary -- modelList123list :: Maybe Text + instance Arbitrary ModelReturn where - arbitrary = - ModelReturn - <$> arbitrary -- modelReturnReturn :: Maybe Int - + arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int + instance Arbitrary Name where arbitrary = - Name - <$> arbitrary -- nameName :: Int - <*> arbitrary -- nameSnakeCase :: Maybe Int - <*> arbitrary -- nameProperty :: Maybe Text - <*> arbitrary -- name123number :: Maybe Int - + Name <$> arbitrary -- nameName :: Int + <*> + arbitrary -- nameSnakeCase :: Maybe Int + <*> + arbitrary -- nameProperty :: Maybe Text + <*> + arbitrary -- name123number :: Maybe Int + instance Arbitrary NumberOnly where - arbitrary = - NumberOnly - <$> arbitrary -- numberOnlyJustNumber :: Maybe Double - + arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double + instance Arbitrary Order where arbitrary = - Order - <$> arbitrary -- orderId :: Maybe Integer - <*> arbitrary -- orderPetId :: Maybe Integer - <*> arbitrary -- orderQuantity :: Maybe Int - <*> arbitrary -- orderShipDate :: Maybe DateTime - <*> arbitrary -- orderStatus :: Maybe Text - <*> arbitrary -- orderComplete :: Maybe Bool - + Order <$> arbitrary -- orderId :: Maybe Integer + <*> + arbitrary -- orderPetId :: Maybe Integer + <*> + arbitrary -- orderQuantity :: Maybe Int + <*> + arbitrary -- orderShipDate :: Maybe DateTime + <*> + arbitrary -- orderStatus :: Maybe Text + <*> + arbitrary -- orderComplete :: Maybe Bool + instance Arbitrary OuterComposite where arbitrary = - OuterComposite - <$> arbitrary -- outerCompositeMyNumber :: Maybe Double - <*> arbitrary -- outerCompositeMyString :: Maybe Text - <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool - + OuterComposite <$> arbitrary -- outerCompositeMyNumber :: Maybe Double + <*> + arbitrary -- outerCompositeMyString :: Maybe Text + <*> + arbitrary -- outerCompositeMyBoolean :: Maybe Bool + instance Arbitrary Pet where arbitrary = - Pet - <$> arbitrary -- petId :: Maybe Integer - <*> arbitrary -- petCategory :: Maybe Category - <*> arbitrary -- petName :: Text - <*> arbitrary -- petPhotoUrls :: [Text] - <*> arbitrary -- petTags :: Maybe [Tag] - <*> arbitrary -- petStatus :: Maybe Text - + Pet <$> arbitrary -- petId :: Maybe Integer + <*> + arbitrary -- petCategory :: Maybe Category + <*> + arbitrary -- petName :: Text + <*> + arbitrary -- petPhotoUrls :: [Text] + <*> + arbitrary -- petTags :: Maybe [Tag] + <*> + arbitrary -- petStatus :: Maybe Text + instance Arbitrary ReadOnlyFirst where arbitrary = - ReadOnlyFirst - <$> arbitrary -- readOnlyFirstBar :: Maybe Text - <*> arbitrary -- readOnlyFirstBaz :: Maybe Text - + ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text + <*> + arbitrary -- readOnlyFirstBaz :: Maybe Text + instance Arbitrary SpecialModelName where arbitrary = - SpecialModelName - <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer - + SpecialModelName <$> + arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer + instance Arbitrary StringBooleanMap where - arbitrary = - - pure StringBooleanMap - + arbitrary = pure StringBooleanMap + instance Arbitrary Tag where arbitrary = - Tag - <$> arbitrary -- tagId :: Maybe Integer - <*> arbitrary -- tagName :: Maybe Text - + Tag <$> arbitrary -- tagId :: Maybe Integer + <*> + arbitrary -- tagName :: Maybe Text + instance Arbitrary User where arbitrary = - User - <$> arbitrary -- userId :: Maybe Integer - <*> arbitrary -- userUsername :: Maybe Text - <*> arbitrary -- userFirstName :: Maybe Text - <*> arbitrary -- userLastName :: Maybe Text - <*> arbitrary -- userEmail :: Maybe Text - <*> arbitrary -- userPassword :: Maybe Text - <*> arbitrary -- userPhone :: Maybe Text - <*> arbitrary -- userUserStatus :: Maybe Int - - - + User <$> arbitrary -- userId :: Maybe Integer + <*> + arbitrary -- userUsername :: Maybe Text + <*> + arbitrary -- userFirstName :: Maybe Text + <*> + arbitrary -- userLastName :: Maybe Text + <*> + arbitrary -- userEmail :: Maybe Text + <*> + arbitrary -- userPassword :: Maybe Text + <*> + arbitrary -- userPhone :: Maybe Text + <*> + arbitrary -- userUserStatus :: Maybe Int instance Arbitrary E'ArrayEnum where arbitrary = arbitraryBoundedEnum diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index ea6fff251e3..99aa846de8f 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -1,23 +1,24 @@ -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} module Main where -import Data.Typeable (Proxy(..)) -import Test.Hspec -import Test.Hspec.QuickCheck +import Data.Typeable (Proxy (..)) +import Test.Hspec +import Test.Hspec.QuickCheck -import PropMime -import Instances () +import Instances () +import PropMime -import OpenAPIPetstore.Model -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model main :: IO () main = - hspec $ modifyMaxSize (const 5) $ do + hspec $ + modifyMaxSize (const 5) $ do describe "JSON instances" $ do pure () propMimeEq MimeJSON (Proxy :: Proxy AdditionalPropertiesClass) @@ -41,7 +42,9 @@ main = propMimeEq MimeJSON (Proxy :: Proxy FormatTest) propMimeEq MimeJSON (Proxy :: Proxy HasOnlyReadOnly) propMimeEq MimeJSON (Proxy :: Proxy MapTest) - propMimeEq MimeJSON (Proxy :: Proxy MixedPropertiesAndAdditionalPropertiesClass) + propMimeEq + MimeJSON + (Proxy :: Proxy MixedPropertiesAndAdditionalPropertiesClass) propMimeEq MimeJSON (Proxy :: Proxy Model200Response) propMimeEq MimeJSON (Proxy :: Proxy ModelList) propMimeEq MimeJSON (Proxy :: Proxy ModelReturn) @@ -56,4 +59,3 @@ main = propMimeEq MimeJSON (Proxy :: Proxy StringBooleanMap) propMimeEq MimeJSON (Proxy :: Proxy Tag) propMimeEq MimeJSON (Proxy :: Proxy User) - -- GitLab From 5d1dbde90abde3dcfc7b2a049da7f47913584423 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Thu, 13 Sep 2018 15:29:46 +0800 Subject: [PATCH 03/10] add code format option to haskell servant, minor bug fixes --- .../languages/HaskellHttpClientCodegen.java | 16 +-- .../languages/HaskellServantCodegen.java | 118 ++++++++++++------ 2 files changed, 88 insertions(+), 46 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 24814d62c0e..0679c5a5abe 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -136,10 +136,6 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public HaskellHttpClientCodegen() { super(); - if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { - LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); - } - this.prependFormOrBodyParameters = true; // override the mapping to keep the original mapping in Haskell @@ -366,6 +362,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public void processOpts() { super.processOpts(); + if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { + LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); + } + if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) { setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS)); } else { @@ -1356,7 +1356,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC if (file == null) { return; } - String hfmtPath = System.getenv("HFMT_PATH"); + String hfmtPath = System.getenv("HFMT_PATH"); if (StringUtils.isEmpty(hfmtPath)) { return; // skip if HFMT_PATH env variable is not defined } @@ -1368,12 +1368,12 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC Process p = Runtime.getRuntime().exec(command); p.waitFor(); if (p.exitValue() != 0) { - LOGGER.error("Error running the command ({}): {}", command, p.exitValue()); + LOGGER.error("Error running the command ({}). Exit value: {}", command, p.exitValue()); } + LOGGER.info("Successfully executed: " + command); } catch (Exception e) { - LOGGER.error("Error running the command ({}): {}", command, e.getMessage()); + LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); } - LOGGER.info("Successfully executed: " + command); } } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java index 62029b6065a..dabc8c9dd0b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java @@ -21,6 +21,7 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CodegenConfig; @@ -36,6 +37,7 @@ import org.openapitools.codegen.utils.ModelUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -100,20 +102,20 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf // set the output folder here outputFolder = "generated-code/haskell-servant"; - /* - * Template Location. This is the location which templates will be read from. The generator - * will use the resource stream to attempt to read the templates. - */ + /* + * Template Location. This is the location which templates will be read from. The generator + * will use the resource stream to attempt to read the templates. + */ embeddedTemplateDir = templateDir = "haskell-servant"; - /* - * Api Package. Optional, if needed, this can be used in templates - */ + /* + * Api Package. Optional, if needed, this can be used in templates + */ apiPackage = "API"; - /* - * Model Package. Optional, if needed, this can be used in templates - */ + /* + * Model Package. Optional, if needed, this can be used in templates + */ modelPackage = "Types"; // Haskell keywords and reserved function names, taken mostly from https://wiki.haskell.org/Keywords @@ -133,25 +135,25 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf ) ); - /* - * Additional Properties. These values can be passed to the templates and - * are available in models, apis, and supporting files - */ + /* + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ additionalProperties.put("apiVersion", apiVersion); - /* - * Supporting Files. You can write single files for the generator with the - * entire object tree available. If the input file has a suffix of `.mustache - * it will be processed by the template engine. Otherwise, it will be copied - */ + /* + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("stack.mustache", "", "stack.yaml")); supportingFiles.add(new SupportingFile("Setup.mustache", "", "Setup.hs")); - /* - * Language Specific Primitives. These types will not trigger imports by - * the client generator - */ + /* + * Language Specific Primitives. These types will not trigger imports by + * the client generator + */ languageSpecificPrimitives = new HashSet<String>( Arrays.asList( "Bool", @@ -179,6 +181,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf typeMapping.put("double", "Double"); typeMapping.put("DateTime", "Integer"); typeMapping.put("file", "FilePath"); + typeMapping.put("binary", "FilePath"); typeMapping.put("number", "Double"); typeMapping.put("any", "Value"); typeMapping.put("UUID", "Text"); @@ -192,6 +195,15 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); } + @Override + public void processOpts() { + super.processOpts(); + + if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { + LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); + } + } + /** * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping * those terms here. This logic is only called if a variable matches the reserved words @@ -200,7 +212,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf */ @Override public String escapeReservedWord(String name) { - if(this.reservedWordsMappings().containsKey(name)) { + if (this.reservedWordsMappings().containsKey(name)) { return this.reservedWordsMappings().get(name); } return "_" + name; @@ -232,7 +244,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf String title = openAPI.getInfo().getTitle(); // Drop any API suffix - if(title == null) { + if (title == null) { title = "OpenAPI"; } else { title = title.trim(); @@ -272,7 +284,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf List<Map<String, Object>> replacements = new ArrayList<>(); Object[] replacementChars = specialCharReplacements.keySet().toArray(); - for(int i = 0; i < replacementChars.length; i++) { + for (int i = 0; i < replacementChars.length; i++) { String c = (String) replacementChars[i]; Map<String, Object> o = new HashMap<>(); o.put("char", c); @@ -321,7 +333,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf return type; //if (languageSpecificPrimitives.contains(type)) // return toModelName(type); - } else if(typeMapping.containsValue(schemaType)) { + } else if (typeMapping.containsValue(schemaType)) { // TODO what's this case for? type = schemaType + "_"; } else { @@ -452,7 +464,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf path.add("ReqBody '[JSON] " + param.dataType); bodyType = param.dataType; } - } else if(op.getHasFormParams()) { + } else if (op.getHasFormParams()) { // Use the FormX data type, where X is the conglomerate of all things being passed String formName = "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId); bodyType = formName; @@ -496,7 +508,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path)); op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type)); op.vendorExtensions.put("x-formName", "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId)); - for(CodegenParameter param : op.formParams) { + for (CodegenParameter param : op.formParams) { param.vendorExtensions.put("x-formPrefix", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId, true)); } return op; @@ -504,12 +516,17 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf private String makeQueryListType(String type, String collectionFormat) { type = type.substring(1, type.length() - 1); - switch(collectionFormat) { - case "csv": return "(QueryList 'CommaSeparated (" + type + "))"; - case "tsv": return "(QueryList 'TabSeparated (" + type + "))"; - case "ssv": return "(QueryList 'SpaceSeparated (" + type + "))"; - case "pipes": return "(QueryList 'PipeSeparated (" + type + "))"; - case "multi": return "(QueryList 'MultiParamArray (" + type + "))"; + switch (collectionFormat) { + case "csv": + return "(QueryList 'CommaSeparated (" + type + "))"; + case "tsv": + return "(QueryList 'TabSeparated (" + type + "))"; + case "ssv": + return "(QueryList 'SpaceSeparated (" + type + "))"; + case "pipes": + return "(QueryList 'PipeSeparated (" + type + "))"; + case "multi": + return "(QueryList 'MultiParamArray (" + type + "))"; default: throw new UnsupportedOperationException(); } @@ -550,19 +567,19 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf // Clean up the class name to remove invalid characters model.classname = fixModelChars(model.classname); - if(typeMapping.containsValue(model.classname)) { + if (typeMapping.containsValue(model.classname)) { model.classname += "_"; } // From the model name, compute the prefix for the fields. String prefix = org.openapitools.codegen.utils.StringUtils.camelize(model.classname, true); - for(CodegenProperty prop : model.vars) { + for (CodegenProperty prop : model.vars) { prop.name = toVarName(prefix + org.openapitools.codegen.utils.StringUtils.camelize(fixOperatorChars(prop.name))); } // Create newtypes for things with non-object types String dataOrNewtype = "data"; - if(model.dataType != "object" && typeMapping.containsKey(model.dataType)) { + if (!"object".equals(model.dataType) && typeMapping.containsKey(model.dataType)) { String newtype = typeMapping.get(model.dataType); model.vendorExtensions.put("x-customNewtype", newtype); } @@ -585,4 +602,29 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf return input.replace("{-", "{_-").replace("-}", "-_}"); } + @Override + public void postProcessFile(File file, String fileType) { + if (file == null) { + return; + } + String hfmtPath = System.getenv("HFMT_PATH"); + if (StringUtils.isEmpty(hfmtPath)) { + return; // skip if HFMT_PATH env variable is not defined + } + + // only process files with hs extension + if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { + String command = hfmtPath + " -w " + file.toString(); + try { + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + if (p.exitValue() != 0) { + LOGGER.error("Error running the command ({}). Exit value: {}", command, p.exitValue()); + } + LOGGER.info("Successfully executed: " + command); + } catch (Exception e) { + LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); + } + } + } } -- GitLab From 01035b30b2eef5db1d7402586982a6b157a6e334 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Thu, 13 Sep 2018 15:31:51 +0800 Subject: [PATCH 04/10] update code samples with hfmt --- .../.openapi-generator/VERSION | 2 +- .../server/petstore/haskell-servant/Setup.hs | 3 +- .../lib/OpenAPIPetstore/API.hs | 265 +++++++++--------- .../lib/OpenAPIPetstore/Types.hs | 105 +++---- 4 files changed, 197 insertions(+), 178 deletions(-) diff --git a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION index 096bf47efe3..6d94c9c2e12 100644 --- a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION +++ b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/haskell-servant/Setup.hs b/samples/server/petstore/haskell-servant/Setup.hs index 9a994af677b..ebdc00e6461 100644 --- a/samples/server/petstore/haskell-servant/Setup.hs +++ b/samples/server/petstore/haskell-servant/Setup.hs @@ -1,2 +1,3 @@ -import Distribution.Simple +import Distribution.Simple + main = defaultMain diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs index be52403f5c7..254e77a4b28 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs @@ -1,14 +1,14 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports -fcontext-stack=328 #-} @@ -25,52 +25,56 @@ module OpenAPIPetstore.API , OpenAPIPetstoreAPI ) where -import OpenAPIPetstore.Types - -import Control.Monad.Except (ExceptT) -import Control.Monad.IO.Class -import Data.Aeson (Value) -import Data.Coerce (coerce) -import Data.Function ((&)) -import qualified Data.Map as Map -import Data.Monoid ((<>)) -import Data.Proxy (Proxy(..)) -import Data.Text (Text) -import qualified Data.Text as T -import GHC.Exts (IsString(..)) -import GHC.Generics (Generic) -import Network.HTTP.Client (Manager, defaultManagerSettings, newManager) -import Network.HTTP.Types.Method (methodOptions) -import qualified Network.Wai.Handler.Warp as Warp -import Servant (ServantErr, serve) -import Servant.API -import Servant.API.Verbs (StdMethod(..), Verb) -import Servant.Client (Scheme(Http), ServantError, client) -import Servant.Common.BaseUrl (BaseUrl(..)) -import Web.HttpApiData - - +import OpenAPIPetstore.Types + +import Control.Monad.Except (ExceptT) +import Control.Monad.IO.Class +import Data.Aeson (Value) +import Data.Coerce (coerce) +import Data.Function ((&)) +import qualified Data.Map as Map +import Data.Monoid ((<>)) +import Data.Proxy (Proxy (..)) +import Data.Text (Text) +import qualified Data.Text as T +import GHC.Exts (IsString (..)) +import GHC.Generics (Generic) +import Network.HTTP.Client (Manager, defaultManagerSettings, + newManager) +import Network.HTTP.Types.Method (methodOptions) +import qualified Network.Wai.Handler.Warp as Warp +import Servant (ServantErr, serve) +import Servant.API +import Servant.API.Verbs (StdMethod (..), Verb) +import Servant.Client (Scheme (Http), ServantError, client) +import Servant.Common.BaseUrl (BaseUrl (..)) +import Web.HttpApiData data FormUpdatePetWithForm = FormUpdatePetWithForm - { updatePetWithFormName :: Text + { updatePetWithFormName :: Text , updatePetWithFormStatus :: Text } deriving (Show, Eq, Generic) instance FromFormUrlEncoded FormUpdatePetWithForm where - fromFormUrlEncoded inputs = FormUpdatePetWithForm <$> lookupEither "name" inputs <*> lookupEither "status" inputs + fromFormUrlEncoded inputs = + FormUpdatePetWithForm <$> lookupEither "name" inputs <*> + lookupEither "status" inputs instance ToFormUrlEncoded FormUpdatePetWithForm where toFormUrlEncoded value = [ ("name", toQueryParam $ updatePetWithFormName value) , ("status", toQueryParam $ updatePetWithFormStatus value) ] + data FormUploadFile = FormUploadFile { uploadFileAdditionalMetadata :: Text - , uploadFileFile :: FilePath + , uploadFileFile :: FilePath } deriving (Show, Eq, Generic) instance FromFormUrlEncoded FormUploadFile where - fromFormUrlEncoded inputs = FormUploadFile <$> lookupEither "additionalMetadata" inputs <*> lookupEither "file" inputs + fromFormUrlEncoded inputs = + FormUploadFile <$> lookupEither "additionalMetadata" inputs <*> + lookupEither "file" inputs instance ToFormUrlEncoded FormUploadFile where toFormUrlEncoded value = @@ -82,39 +86,40 @@ instance ToFormUrlEncoded FormUploadFile where lookupEither :: FromHttpApiData b => Text -> [(Text, Text)] -> Either String b lookupEither key assocs = case lookup key assocs of - Nothing -> Left $ "Could not find parameter " <> (T.unpack key) <> " in form data" + Nothing -> + Left $ "Could not find parameter " <> (T.unpack key) <> " in form data" Just value -> case parseQueryParam value of - Left result -> Left $ T.unpack result + Left result -> Left $ T.unpack result Right result -> Right $ result -- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore. type OpenAPIPetstoreAPI - = "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route - :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' route - :<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByStatus' route - :<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route - :<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route - :<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route - :<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' route - :<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[JSON] ApiResponse -- 'uploadFile' route - :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteOrder' route - :<|> "store" :> "inventory" :> Verb 'GET 200 '[JSON] (Map.Map String Int) -- 'getInventory' route - :<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[JSON] Order -- 'getOrderById' route - :<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route - :<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] () -- 'createUser' route - :<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithArrayInput' route - :<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithListInput' route - :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteUser' route - :<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[JSON] User -- 'getUserByName' route - :<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[JSON] Text -- 'loginUser' route - :<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] () -- 'logoutUser' route - :<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] () -- 'updateUser' route + = "pet" :> ReqBody '[ JSON] Pet :> Verb 'POST 200 '[ JSON] () -- 'addPet' route + :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deletePet' route + :<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[ JSON] [Pet] -- 'findPetsByStatus' route + :<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[ JSON] [Pet] -- 'findPetsByTags' route + :<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[ JSON] Pet -- 'getPetById' route + :<|> "pet" :> ReqBody '[ JSON] Pet :> Verb 'PUT 200 '[ JSON] () -- 'updatePet' route + :<|> "pet" :> Capture "petId" Integer :> ReqBody '[ FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[ JSON] () -- 'updatePetWithForm' route + :<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[ FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[ JSON] ApiResponse -- 'uploadFile' route + :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deleteOrder' route + :<|> "store" :> "inventory" :> Verb 'GET 200 '[ JSON] (Map.Map String Int) -- 'getInventory' route + :<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[ JSON] Order -- 'getOrderById' route + :<|> "store" :> "order" :> ReqBody '[ JSON] Order :> Verb 'POST 200 '[ JSON] Order -- 'placeOrder' route + :<|> "user" :> ReqBody '[ JSON] User :> Verb 'POST 200 '[ JSON] () -- 'createUser' route + :<|> "user" :> "createWithArray" :> ReqBody '[ JSON] [User] :> Verb 'POST 200 '[ JSON] () -- 'createUsersWithArrayInput' route + :<|> "user" :> "createWithList" :> ReqBody '[ JSON] [User] :> Verb 'POST 200 '[ JSON] () -- 'createUsersWithListInput' route + :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deleteUser' route + :<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[ JSON] User -- 'getUserByName' route + :<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[ JSON] Text -- 'loginUser' route + :<|> "user" :> "logout" :> Verb 'GET 200 '[ JSON] () -- 'logoutUser' route + :<|> "user" :> Capture "username" Text :> ReqBody '[ JSON] User :> Verb 'PUT 200 '[ JSON] () -- 'updateUser' route -- | Server or client configuration, specifying the host and port to query or serve on. data ServerConfig = ServerConfig - { configHost :: String -- ^ Hostname to serve on, e.g. "127.0.0.1" - , configPort :: Int -- ^ Port to serve on, e.g. 8080 + { configHost :: String -- ^ Hostname to serve on, e.g. "127.0.0.1" + , configPort :: Int -- ^ Port to serve on, e.g. 8080 } deriving (Eq, Ord, Show, Read) -- | List of elements parsed from a query. @@ -130,23 +135,29 @@ data CollectionFormat | PipeSeparated -- ^ `value1|value2|value2` | MultiParamArray -- ^ Using multiple GET parameters, e.g. `foo=bar&foo=baz`. Only for GET params. -instance FromHttpApiData a => FromHttpApiData (QueryList 'CommaSeparated a) where +instance FromHttpApiData a => + FromHttpApiData (QueryList 'CommaSeparated a) where parseQueryParam = parseSeparatedQueryList ',' instance FromHttpApiData a => FromHttpApiData (QueryList 'TabSeparated a) where parseQueryParam = parseSeparatedQueryList '\t' -instance FromHttpApiData a => FromHttpApiData (QueryList 'SpaceSeparated a) where +instance FromHttpApiData a => + FromHttpApiData (QueryList 'SpaceSeparated a) where parseQueryParam = parseSeparatedQueryList ' ' instance FromHttpApiData a => FromHttpApiData (QueryList 'PipeSeparated a) where parseQueryParam = parseSeparatedQueryList '|' -instance FromHttpApiData a => FromHttpApiData (QueryList 'MultiParamArray a) where - parseQueryParam = error "unimplemented FromHttpApiData for MultiParamArray collection format" +instance FromHttpApiData a => + FromHttpApiData (QueryList 'MultiParamArray a) where + parseQueryParam = + error "unimplemented FromHttpApiData for MultiParamArray collection format" -parseSeparatedQueryList :: FromHttpApiData a => Char -> Text -> Either Text (QueryList p a) -parseSeparatedQueryList char = fmap QueryList . mapM parseQueryParam . T.split (== char) +parseSeparatedQueryList :: + FromHttpApiData a => Char -> Text -> Either Text (QueryList p a) +parseSeparatedQueryList char = + fmap QueryList . mapM parseQueryParam . T.split (== char) instance ToHttpApiData a => ToHttpApiData (QueryList 'CommaSeparated a) where toQueryParam = formatSeparatedQueryList ',' @@ -161,42 +172,43 @@ instance ToHttpApiData a => ToHttpApiData (QueryList 'PipeSeparated a) where toQueryParam = formatSeparatedQueryList '|' instance ToHttpApiData a => ToHttpApiData (QueryList 'MultiParamArray a) where - toQueryParam = error "unimplemented ToHttpApiData for MultiParamArray collection format" - -formatSeparatedQueryList :: ToHttpApiData a => Char -> QueryList p a -> Text -formatSeparatedQueryList char = T.intercalate (T.singleton char) . map toQueryParam . fromQueryList + toQueryParam = + error "unimplemented ToHttpApiData for MultiParamArray collection format" +formatSeparatedQueryList :: ToHttpApiData a => Char -> QueryList p a -> Text +formatSeparatedQueryList char = + T.intercalate (T.singleton char) . map toQueryParam . fromQueryList -- | Backend for OpenAPIPetstore. -- The backend can be used both for the client and the server. The client generated from the OpenAPIPetstore OpenAPI spec -- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided -- a backend, the API can be served using @runOpenAPIPetstoreServer@. data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend - { addPet :: Pet -> m (){- ^ -} - , deletePet :: Integer -> Maybe Text -> m (){- ^ -} - , findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -} - , findPetsByTags :: Maybe [Text] -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -} - , getPetById :: Integer -> m Pet{- ^ Returns a single pet -} - , updatePet :: Pet -> m (){- ^ -} - , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -} - , uploadFile :: Integer -> FormUploadFile -> m ApiResponse{- ^ -} - , deleteOrder :: Text -> m (){- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} - , getInventory :: m (Map.Map String Int){- ^ Returns a map of status codes to quantities -} - , getOrderById :: Integer -> m Order{- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -} - , placeOrder :: Order -> m Order{- ^ -} - , createUser :: User -> m (){- ^ This can only be done by the logged in user. -} - , createUsersWithArrayInput :: [User] -> m (){- ^ -} - , createUsersWithListInput :: [User] -> m (){- ^ -} - , deleteUser :: Text -> m (){- ^ This can only be done by the logged in user. -} - , getUserByName :: Text -> m User{- ^ -} - , loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -} - , logoutUser :: m (){- ^ -} - , updateUser :: Text -> User -> m (){- ^ This can only be done by the logged in user. -} + { addPet :: Pet -> m () {- ^ -} + , deletePet :: Integer -> Maybe Text -> m () {- ^ -} + , findPetsByStatus :: Maybe [Text] -> m [Pet] {- ^ Multiple status values can be provided with comma separated strings -} + , findPetsByTags :: Maybe [Text] -> m [Pet] {- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -} + , getPetById :: Integer -> m Pet {- ^ Returns a single pet -} + , updatePet :: Pet -> m () {- ^ -} + , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m () {- ^ -} + , uploadFile :: Integer -> FormUploadFile -> m ApiResponse {- ^ -} + , deleteOrder :: Text -> m () {- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} + , getInventory :: m (Map.Map String Int) {- ^ Returns a map of status codes to quantities -} + , getOrderById :: Integer -> m Order {- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -} + , placeOrder :: Order -> m Order {- ^ -} + , createUser :: User -> m () {- ^ This can only be done by the logged in user. -} + , createUsersWithArrayInput :: [User] -> m () {- ^ -} + , createUsersWithListInput :: [User] -> m () {- ^ -} + , deleteUser :: Text -> m () {- ^ This can only be done by the logged in user. -} + , getUserByName :: Text -> m User {- ^ -} + , loginUser :: Maybe Text -> Maybe Text -> m Text {- ^ -} + , logoutUser :: m () {- ^ -} + , updateUser :: Text -> User -> m () {- ^ This can only be done by the logged in user. -} } newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient { runClient :: Manager -> BaseUrl -> ExceptT ServantError IO a - } deriving Functor + } deriving (Functor) instance Applicative OpenAPIPetstoreClient where pure x = OpenAPIPetstoreClient (\_ _ -> pure x) @@ -205,58 +217,53 @@ instance Applicative OpenAPIPetstoreClient where instance Monad OpenAPIPetstoreClient where (OpenAPIPetstoreClient a) >>= f = - OpenAPIPetstoreClient (\manager url -> do - value <- a manager url - runClient (f value) manager url) + OpenAPIPetstoreClient + (\manager url -> do + value <- a manager url + runClient (f value) manager url) instance MonadIO OpenAPIPetstoreClient where liftIO io = OpenAPIPetstoreClient (\_ _ -> liftIO io) createOpenAPIPetstoreClient :: OpenAPIPetstoreBackend OpenAPIPetstoreClient -createOpenAPIPetstoreClient = OpenAPIPetstoreBackend{..} +createOpenAPIPetstoreClient = OpenAPIPetstoreBackend {..} where - ((coerce -> addPet) :<|> - (coerce -> deletePet) :<|> - (coerce -> findPetsByStatus) :<|> - (coerce -> findPetsByTags) :<|> - (coerce -> getPetById) :<|> - (coerce -> updatePet) :<|> - (coerce -> updatePetWithForm) :<|> - (coerce -> uploadFile) :<|> - (coerce -> deleteOrder) :<|> - (coerce -> getInventory) :<|> - (coerce -> getOrderById) :<|> - (coerce -> placeOrder) :<|> - (coerce -> createUser) :<|> - (coerce -> createUsersWithArrayInput) :<|> - (coerce -> createUsersWithListInput) :<|> - (coerce -> deleteUser) :<|> - (coerce -> getUserByName) :<|> - (coerce -> loginUser) :<|> - (coerce -> logoutUser) :<|> - (coerce -> updateUser)) = client (Proxy :: Proxy OpenAPIPetstoreAPI) + ((coerce -> addPet) :<|> (coerce -> deletePet) :<|> (coerce -> findPetsByStatus) :<|> (coerce -> findPetsByTags) :<|> (coerce -> getPetById) :<|> (coerce -> updatePet) :<|> (coerce -> updatePetWithForm) :<|> (coerce -> uploadFile) :<|> (coerce -> deleteOrder) :<|> (coerce -> getInventory) :<|> (coerce -> getOrderById) :<|> (coerce -> placeOrder) :<|> (coerce -> createUser) :<|> (coerce -> createUsersWithArrayInput) :<|> (coerce -> createUsersWithListInput) :<|> (coerce -> deleteUser) :<|> (coerce -> getUserByName) :<|> (coerce -> loginUser) :<|> (coerce -> logoutUser) :<|> (coerce -> updateUser)) = + client (Proxy :: Proxy OpenAPIPetstoreAPI) -- | Run requests in the OpenAPIPetstoreClient monad. -runOpenAPIPetstoreClient :: ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a +runOpenAPIPetstoreClient :: + ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a runOpenAPIPetstoreClient clientConfig cl = do manager <- liftIO $ newManager defaultManagerSettings runOpenAPIPetstoreClientWithManager manager clientConfig cl -- | Run requests in the OpenAPIPetstoreClient monad using a custom manager. -runOpenAPIPetstoreClientWithManager :: Manager -> ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a +runOpenAPIPetstoreClientWithManager :: + Manager + -> ServerConfig + -> OpenAPIPetstoreClient a + -> ExceptT ServantError IO a runOpenAPIPetstoreClientWithManager manager clientConfig cl = - runClient cl manager $ BaseUrl Http (configHost clientConfig) (configPort clientConfig) "" + runClient cl manager $ + BaseUrl Http (configHost clientConfig) (configPort clientConfig) "" -- | Run the OpenAPIPetstore server at the provided host and port. -runOpenAPIPetstoreServer :: MonadIO m => ServerConfig -> OpenAPIPetstoreBackend (ExceptT ServantErr IO) -> m () -runOpenAPIPetstoreServer ServerConfig{..} backend = - liftIO $ Warp.runSettings warpSettings $ serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) +runOpenAPIPetstoreServer :: + MonadIO m + => ServerConfig + -> OpenAPIPetstoreBackend (ExceptT ServantErr IO) + -> m () +runOpenAPIPetstoreServer ServerConfig {..} backend = + liftIO $ + Warp.runSettings warpSettings $ + serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) where - warpSettings = Warp.defaultSettings & Warp.setPort configPort & Warp.setHost (fromString configHost) - serverFromBackend OpenAPIPetstoreBackend{..} = - (coerce addPet :<|> - coerce deletePet :<|> - coerce findPetsByStatus :<|> + warpSettings = + Warp.defaultSettings & Warp.setPort configPort & + Warp.setHost (fromString configHost) + serverFromBackend OpenAPIPetstoreBackend {..} = + (coerce addPet :<|> coerce deletePet :<|> coerce findPetsByStatus :<|> coerce findPetsByTags :<|> coerce getPetById :<|> coerce updatePet :<|> diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs index 542556438d2..96f2faa0335 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs @@ -1,105 +1,111 @@ -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} -module OpenAPIPetstore.Types ( - ApiResponse (..), - Category (..), - Order (..), - Pet (..), - Tag (..), - User (..), +module OpenAPIPetstore.Types + ( ApiResponse(..) + , Category(..) + , Order(..) + , Pet(..) + , Tag(..) + , User(..) ) where -import Data.List (stripPrefix) -import Data.Maybe (fromMaybe) -import Data.Aeson (Value, FromJSON(..), ToJSON(..), genericToJSON, genericParseJSON) -import Data.Aeson.Types (Options(..), defaultOptions) -import Data.Text (Text) -import qualified Data.Text as T -import qualified Data.Map as Map -import GHC.Generics (Generic) -import Data.Function ((&)) - +import Data.Aeson (FromJSON (..), ToJSON (..), Value, + genericParseJSON, genericToJSON) +import Data.Aeson.Types (Options (..), defaultOptions) +import Data.Function ((&)) +import Data.List (stripPrefix) +import qualified Data.Map as Map +import Data.Maybe (fromMaybe) +import Data.Text (Text) +import qualified Data.Text as T +import GHC.Generics (Generic) -- | Describes the result of uploading an image resource data ApiResponse = ApiResponse - { apiResponseCode :: Int -- ^ - , apiResponseType :: Text -- ^ - , apiResponseMessage :: Text -- ^ + { apiResponseCode :: Int -- ^ + , apiResponseType :: Text -- ^ + , apiResponseMessage :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON ApiResponse where parseJSON = genericParseJSON (removeFieldLabelPrefix True "apiResponse") + instance ToJSON ApiResponse where toJSON = genericToJSON (removeFieldLabelPrefix False "apiResponse") -- | A category for a pet data Category = Category - { categoryId :: Integer -- ^ - , categoryName :: Text -- ^ + { categoryId :: Integer -- ^ + , categoryName :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON Category where parseJSON = genericParseJSON (removeFieldLabelPrefix True "category") + instance ToJSON Category where toJSON = genericToJSON (removeFieldLabelPrefix False "category") -- | An order for a pets from the pet store data Order = Order - { orderId :: Integer -- ^ - , orderPetId :: Integer -- ^ - , orderQuantity :: Int -- ^ - , orderShipDate :: Integer -- ^ - , orderStatus :: Text -- ^ Order Status - , orderComplete :: Bool -- ^ + { orderId :: Integer -- ^ + , orderPetId :: Integer -- ^ + , orderQuantity :: Int -- ^ + , orderShipDate :: Integer -- ^ + , orderStatus :: Text -- ^ Order Status + , orderComplete :: Bool -- ^ } deriving (Show, Eq, Generic) instance FromJSON Order where parseJSON = genericParseJSON (removeFieldLabelPrefix True "order") + instance ToJSON Order where toJSON = genericToJSON (removeFieldLabelPrefix False "order") -- | A pet for sale in the pet store data Pet = Pet - { petId :: Integer -- ^ - , petCategory :: Category -- ^ - , petName :: Text -- ^ - , petPhotoUrls :: [Text] -- ^ - , petTags :: [Tag] -- ^ - , petStatus :: Text -- ^ pet status in the store + { petId :: Integer -- ^ + , petCategory :: Category -- ^ + , petName :: Text -- ^ + , petPhotoUrls :: [Text] -- ^ + , petTags :: [Tag] -- ^ + , petStatus :: Text -- ^ pet status in the store } deriving (Show, Eq, Generic) instance FromJSON Pet where parseJSON = genericParseJSON (removeFieldLabelPrefix True "pet") + instance ToJSON Pet where toJSON = genericToJSON (removeFieldLabelPrefix False "pet") -- | A tag for a pet data Tag = Tag - { tagId :: Integer -- ^ - , tagName :: Text -- ^ + { tagId :: Integer -- ^ + , tagName :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON Tag where parseJSON = genericParseJSON (removeFieldLabelPrefix True "tag") + instance ToJSON Tag where toJSON = genericToJSON (removeFieldLabelPrefix False "tag") -- | A User who is purchasing from the pet store data User = User - { userId :: Integer -- ^ - , userUsername :: Text -- ^ - , userFirstName :: Text -- ^ - , userLastName :: Text -- ^ - , userEmail :: Text -- ^ - , userPassword :: Text -- ^ - , userPhone :: Text -- ^ + { userId :: Integer -- ^ + , userUsername :: Text -- ^ + , userFirstName :: Text -- ^ + , userLastName :: Text -- ^ + , userEmail :: Text -- ^ + , userPassword :: Text -- ^ + , userPhone :: Text -- ^ , userUserStatus :: Int -- ^ User Status } deriving (Show, Eq, Generic) instance FromJSON User where parseJSON = genericParseJSON (removeFieldLabelPrefix True "user") + instance ToJSON User where toJSON = genericToJSON (removeFieldLabelPrefix False "user") @@ -108,9 +114,13 @@ instance ToJSON User where removeFieldLabelPrefix :: Bool -> String -> Options removeFieldLabelPrefix forParsing prefix = defaultOptions - {fieldLabelModifier = fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix . replaceSpecialChars} + { fieldLabelModifier = + fromMaybe (error ("did not find prefix " ++ prefix)) . + stripPrefix prefix . replaceSpecialChars + } where - replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars) + replaceSpecialChars field = + foldl (&) field (map mkCharReplacement specialChars) specialChars = [ ("@", "'At") , ("\\", "'Back_Slash") @@ -147,7 +157,8 @@ removeFieldLabelPrefix forParsing prefix = , ("?", "'Question_Mark") , (">=", "'Greater_Than_Or_Equal_To") ] - mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack + mkCharReplacement (replaceStr, searchStr) = + T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack replacer = if forParsing then flip T.replace -- GitLab From 1f19a5fdd35808e5215bc9e10089c122cf7332f2 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Fri, 14 Sep 2018 22:33:58 +0800 Subject: [PATCH 05/10] update samples using stylish-haskell --- .../languages/HaskellHttpClientCodegen.java | 2 +- .../petstore/haskell-http-client/Setup.hs | 1 - .../lib/OpenAPIPetstore.hs | 4 +- .../lib/OpenAPIPetstore/API.hs | 2 + .../lib/OpenAPIPetstore/API/AnotherFake.hs | 17 +- .../lib/OpenAPIPetstore/API/Fake.hs | 153 +- .../API/FakeClassnameTags123.hs | 20 +- .../lib/OpenAPIPetstore/API/Pet.hs | 139 +- .../lib/OpenAPIPetstore/API/Store.hs | 48 +- .../lib/OpenAPIPetstore/API/User.hs | 93 +- .../lib/OpenAPIPetstore/Client.hs | 72 +- .../lib/OpenAPIPetstore/Core.hs | 172 +- .../lib/OpenAPIPetstore/Logging.hs | 32 +- .../lib/OpenAPIPetstore/MimeTypes.hs | 53 +- .../lib/OpenAPIPetstore/Model.hs | 1387 +++++++++-------- .../lib/OpenAPIPetstore/ModelLens.hs | 668 ++++---- .../haskell-http-client/tests/ApproxEq.hs | 14 +- .../haskell-http-client/tests/Instances.hs | 339 ++-- .../haskell-http-client/tests/PropMime.hs | 24 +- .../haskell-http-client/tests/Test.hs | 8 +- 20 files changed, 1661 insertions(+), 1587 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 0679c5a5abe..8c64f959531 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -1363,7 +1363,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC // only process files with hs extension if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { - String command = hfmtPath + " -w " + file.toString(); + String command = hfmtPath + " -i " + file.toString(); try { Process p = Runtime.getRuntime().exec(command); p.waitFor(); diff --git a/samples/client/petstore/haskell-http-client/Setup.hs b/samples/client/petstore/haskell-http-client/Setup.hs index ebdc00e6461..44671092b28 100644 --- a/samples/client/petstore/haskell-http-client/Setup.hs +++ b/samples/client/petstore/haskell-http-client/Setup.hs @@ -1,3 +1,2 @@ import Distribution.Simple - main = defaultMain diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index ca94dec0b43..0f416bdb5f7 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -7,11 +7,13 @@ OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} + {-| Module : OpenAPIPetstore -} + module OpenAPIPetstore - ( module OpenAPIPetstore.API + ( module OpenAPIPetstore.API , module OpenAPIPetstore.Client , module OpenAPIPetstore.Core , module OpenAPIPetstore.Logging diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 2cd3be61554..5a97db25a66 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -7,9 +7,11 @@ 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 diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index 13908b80c25..6d532ae69fc 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.AnotherFake where @@ -61,20 +62,25 @@ import Prelude (Applicative, Bool (..), import qualified Prelude as P -- * Operations + + -- ** AnotherFake + -- *** op123testSpecialTags + -- | @PATCH \/another-fake\/dummy@ -- -- To test special tags -- -- To test special tags and operation ID starting with number -- -op123testSpecialTags :: - (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) +op123testSpecialTags + :: (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest Op123testSpecialTags MimeJSON Client MimeJSON op123testSpecialTags client = - _mkRequest "PATCH" ["/another-fake/dummy"] `setBodyParam` client + _mkRequest "PATCH" ["/another-fake/dummy"] + `setBodyParam` client data Op123testSpecialTags @@ -86,3 +92,4 @@ instance Consumes Op123testSpecialTags MimeJSON -- | @application/json@ instance Produces Op123testSpecialTags MimeJSON + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index 3e8181a2880..f2e7f89c413 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.Fake where @@ -61,18 +62,23 @@ import Prelude (Applicative, Bool (..), import qualified Prelude as P -- * Operations + + -- ** Fake + -- *** fakeOuterBooleanSerialize + -- | @POST \/fake\/outer\/boolean@ -- -- Test serialization of outer boolean types -- -fakeOuterBooleanSerialize :: - (Consumes FakeOuterBooleanSerialize contentType) +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"] +fakeOuterBooleanSerialize _ _ = + _mkRequest "POST" ["/fake/outer/boolean"] data FakeOuterBooleanSerialize @@ -82,17 +88,20 @@ 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) +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"] +fakeOuterCompositeSerialize _ _ = + _mkRequest "POST" ["/fake/outer/composite"] data FakeOuterCompositeSerialize @@ -102,17 +111,20 @@ 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) +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"] +fakeOuterNumberSerialize _ _ = + _mkRequest "POST" ["/fake/outer/number"] data FakeOuterNumberSerialize @@ -122,17 +134,20 @@ 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) +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"] +fakeOuterStringSerialize _ _ = + _mkRequest "POST" ["/fake/outer/string"] data FakeOuterStringSerialize @@ -142,23 +157,22 @@ instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype + -- *** testBodyWithFileSchema + -- | @PUT \/fake\/body-with-file-schema@ -- -- For this test, the body for this request much reference a schema named `File`. -- -testBodyWithFileSchema :: - ( Consumes TestBodyWithFileSchema MimeJSON - , MimeRender MimeJSON FileSchemaTestClass - ) +testBodyWithFileSchema + :: (Consumes TestBodyWithFileSchema MimeJSON, MimeRender MimeJSON FileSchemaTestClass) => FileSchemaTestClass -- ^ "fileSchemaTestClass" -> OpenAPIPetstoreRequest TestBodyWithFileSchema MimeJSON NoContent MimeNoContent testBodyWithFileSchema fileSchemaTestClass = - _mkRequest "PUT" ["/fake/body-with-file-schema"] `setBodyParam` - fileSchemaTestClass + _mkRequest "PUT" ["/fake/body-with-file-schema"] + `setBodyParam` fileSchemaTestClass data TestBodyWithFileSchema - instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass -- | @application/json@ @@ -166,20 +180,22 @@ instance Consumes TestBodyWithFileSchema MimeJSON instance Produces TestBodyWithFileSchema MimeNoContent + -- *** testBodyWithQueryParams + -- | @PUT \/fake\/body-with-query-params@ -- -testBodyWithQueryParams :: - (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) +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) + _mkRequest "PUT" ["/fake/body-with-query-params"] + `setBodyParam` user + `setQuery` toQuery ("query", Just query) data TestBodyWithQueryParams - instance HasBodyParam TestBodyWithQueryParams User -- | @application/json@ @@ -187,18 +203,22 @@ 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) +testClientModel + :: (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON -testClientModel client = _mkRequest "PATCH" ["/fake"] `setBodyParam` client +testClientModel client = + _mkRequest "PATCH" ["/fake"] + `setBodyParam` client data TestClientModel @@ -211,7 +231,9 @@ instance Consumes TestClientModel MimeJSON -- | @application/json@ instance Produces TestClientModel MimeJSON + -- *** testEndpointParameters + -- | @POST \/fake@ -- -- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ @@ -220,20 +242,20 @@ instance Produces TestClientModel MimeJSON -- -- AuthMethod: 'AuthBasicHttpBasicTest' -- -testEndpointParameters :: - (Consumes TestEndpointParameters MimeFormUrlEncoded) +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) + _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 @@ -244,19 +266,23 @@ instance HasOptionalParam TestEndpointParameters ParamInteger where -- | /Optional Param/ "int32" - None instance HasOptionalParam TestEndpointParameters Int32 where - applyOptionalParam req (Int32 xs) = req `addForm` toForm ("int32", xs) + 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) + 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) + 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) + applyOptionalParam req (ParamString xs) = + req `addForm` toForm ("string", xs) -- | /Optional Param/ "binary" - None instance HasOptionalParam TestEndpointParameters ParamBinary where @@ -265,7 +291,8 @@ instance HasOptionalParam TestEndpointParameters ParamBinary where -- | /Optional Param/ "date" - None instance HasOptionalParam TestEndpointParameters ParamDate where - applyOptionalParam req (ParamDate xs) = req `addForm` toForm ("date", xs) + applyOptionalParam req (ParamDate xs) = + req `addForm` toForm ("date", xs) -- | /Optional Param/ "dateTime" - None instance HasOptionalParam TestEndpointParameters ParamDateTime where @@ -274,28 +301,33 @@ instance HasOptionalParam TestEndpointParameters ParamDateTime where -- | /Optional Param/ "password" - None instance HasOptionalParam TestEndpointParameters Password where - applyOptionalParam req (Password xs) = req `addForm` toForm ("password", xs) + 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) + 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) +testEnumParameters + :: (Consumes TestEnumParameters MimeFormUrlEncoded) => OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent -testEnumParameters = _mkRequest "GET" ["/fake"] +testEnumParameters = + _mkRequest "GET" ["/fake"] data TestEnumParameters @@ -322,8 +354,7 @@ instance HasOptionalParam TestEnumParameters EnumHeaderString where -- | /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) + 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 @@ -345,20 +376,20 @@ instance Consumes TestEnumParameters MimeFormUrlEncoded instance Produces TestEnumParameters MimeNoContent + -- *** testInlineAdditionalProperties + -- | @POST \/fake\/inline-additionalProperties@ -- -- test inline additionalProperties -- -testInlineAdditionalProperties :: - ( Consumes TestInlineAdditionalProperties MimeJSON - , MimeRender MimeJSON RequestBody - ) +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 + _mkRequest "POST" ["/fake/inline-additionalProperties"] + `setBodyParam` requestBody data TestInlineAdditionalProperties @@ -370,19 +401,22 @@ instance Consumes TestInlineAdditionalProperties MimeJSON instance Produces TestInlineAdditionalProperties MimeNoContent + -- *** testJsonFormData + -- | @GET \/fake\/jsonFormData@ -- -- test json serialization of form data -- -testJsonFormData :: - (Consumes TestJsonFormData MimeFormUrlEncoded) +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) + _mkRequest "GET" ["/fake/jsonFormData"] + `addForm` toForm ("param", param) + `addForm` toForm ("param2", param2) data TestJsonFormData @@ -390,3 +424,4 @@ data TestJsonFormData instance Consumes TestJsonFormData MimeFormUrlEncoded instance Produces TestJsonFormData MimeNoContent + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index 85867102d1c..6ffc6f39aff 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.FakeClassnameTags123 where @@ -61,8 +62,12 @@ import Prelude (Applicative, Bool (..), import qualified Prelude as P -- * Operations + + -- ** FakeClassnameTags123 + -- *** testClassname + -- | @PATCH \/fake_classname_test@ -- -- To test class name in snake case @@ -71,14 +76,14 @@ import qualified Prelude as P -- -- AuthMethod: 'AuthApiKeyApiKeyQuery' -- -testClassname :: - (Consumes TestClassname MimeJSON, MimeRender MimeJSON Client) +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 + _mkRequest "PATCH" ["/fake_classname_test"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) + `setBodyParam` client data TestClassname @@ -90,3 +95,4 @@ instance Consumes TestClassname MimeJSON -- | @application/json@ instance Produces TestClassname MimeJSON + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 1b3c1f1df24..0e127d4e849 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.Pet where @@ -61,23 +62,27 @@ import Prelude (Applicative, Bool (..), 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) +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 + _mkRequest "POST" ["/pet"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setBodyParam` pet data AddPet @@ -86,34 +91,37 @@ 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 +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) + _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) + applyOptionalParam req (ApiKey xs) = + req `setHeader` toHeader ("api_key", xs) instance Produces DeletePet MimeNoContent + -- *** findPetsByStatus + -- | @GET \/pet\/findByStatus@ -- -- Finds Pets by status @@ -122,24 +130,25 @@ instance Produces DeletePet MimeNoContent -- -- AuthMethod: 'AuthOAuthPetstoreAuth' -- -findPetsByStatus :: - Accept accept -- ^ request accept ('MimeType') +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) +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 @@ -148,28 +157,27 @@ instance Produces FindPetsByStatus MimeJSON -- -- AuthMethod: 'AuthOAuthPetstoreAuth' -- -findPetsByTags :: - Accept accept -- ^ request accept ('MimeType') +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) +findPetsByTags _ (Tags tags) = + _mkRequest "GET" ["/pet/findByTags"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setQuery` toQueryColl CommaSeparated ("tags", Just tags) -{-# DEPRECATED -findPetsByTags "" - #-} +{-# DEPRECATED findPetsByTags "" #-} data FindPetsByTags -- | @application/xml@ instance Produces FindPetsByTags MimeXML - -- | @application/json@ instance Produces FindPetsByTags MimeJSON + -- *** getPetById + -- | @GET \/pet\/{petId}@ -- -- Find pet by ID @@ -178,38 +186,39 @@ instance Produces FindPetsByTags MimeJSON -- -- AuthMethod: 'AuthApiKeyApiKey' -- -getPetById :: - Accept accept -- ^ request accept ('MimeType') +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) +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) +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 + _mkRequest "PUT" ["/pet"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `setBodyParam` pet data UpdatePet @@ -218,64 +227,68 @@ 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) +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) + _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) + 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) + 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) +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) + _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) + req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) -- | /Optional Param/ "file" - file to upload instance HasOptionalParam UploadFile File2 where @@ -288,33 +301,35 @@ instance Consumes UploadFile MimeMultipartFormData -- | @application/json@ instance Produces UploadFile MimeJSON + -- *** uploadFileWithRequiredFile + -- | @POST \/fake\/{petId}\/uploadImageWithRequiredFile@ -- -- uploads an image (required) -- -- AuthMethod: 'AuthOAuthPetstoreAuth' -- -uploadFileWithRequiredFile :: - (Consumes UploadFileWithRequiredFile MimeMultipartFormData) +uploadFileWithRequiredFile + :: (Consumes UploadFileWithRequiredFile MimeMultipartFormData) => RequiredFile -- ^ "requiredFile" - file to upload -> PetId -- ^ "petId" - ID of pet to update -> OpenAPIPetstoreRequest UploadFileWithRequiredFile MimeMultipartFormData ApiResponse MimeJSON uploadFileWithRequiredFile (RequiredFile requiredFile) (PetId petId) = - _mkRequest "POST" ["/fake/", toPath petId, "/uploadImageWithRequiredFile"] `_hasAuthType` - (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `_addMultiFormPart` - NH.partFileSource "requiredFile" requiredFile + _mkRequest "POST" ["/fake/",toPath petId,"/uploadImageWithRequiredFile"] + `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) + `_addMultiFormPart` NH.partFileSource "requiredFile" requiredFile data UploadFileWithRequiredFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFileWithRequiredFile AdditionalMetadata where applyOptionalParam req (AdditionalMetadata xs) = - req `_addMultiFormPart` - NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) + req `_addMultiFormPart` NH.partLBS "additionalMetadata" (mimeRender' MimeMultipartFormData xs) -- | @multipart/form-data@ instance Consumes UploadFileWithRequiredFile MimeMultipartFormData -- | @application/json@ instance Produces UploadFileWithRequiredFile MimeJSON + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index d4e7b353eab..ef549c44c80 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.Store where @@ -61,25 +62,31 @@ import Prelude (Applicative, Bool (..), 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 +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] + _mkRequest "DELETE" ["/store/order/",toPath orderId] data DeleteOrder instance Produces DeleteOrder MimeNoContent + -- *** getInventory + -- | @GET \/store\/inventory@ -- -- Returns pet inventories by status @@ -88,51 +95,56 @@ instance Produces DeleteOrder MimeNoContent -- -- AuthMethod: 'AuthApiKeyApiKey' -- -getInventory :: - OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON +getInventory + :: OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON getInventory = - _mkRequest "GET" ["/store/inventory"] `_hasAuthType` - (P.Proxy :: P.Proxy AuthApiKeyApiKey) + _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') +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] +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) +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 +placeOrder _ _ order = + _mkRequest "POST" ["/store/order"] + `setBodyParam` order data PlaceOrder @@ -141,6 +153,6 @@ instance HasBodyParam PlaceOrder Order -- | @application/xml@ instance Produces PlaceOrder MimeXML - -- | @application/json@ instance Produces PlaceOrder MimeJSON + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index e97fec08a03..87e0724d02f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -7,16 +7,17 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.API.User where @@ -61,20 +62,26 @@ import Prelude (Applicative, Bool (..), 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) +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 +createUser _ user = + _mkRequest "POST" ["/user"] + `setBodyParam` user data CreateUser @@ -83,20 +90,21 @@ 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 - ) +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 + _mkRequest "POST" ["/user/createWithArray"] + `setBodyParam` user data CreateUsersWithArrayInput @@ -105,20 +113,21 @@ 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 - ) +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 + _mkRequest "POST" ["/user/createWithList"] + `setBodyParam` user data CreateUsersWithListInput @@ -127,93 +136,104 @@ 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 +deleteUser + :: Username -- ^ "username" - The name that needs to be deleted -> OpenAPIPetstoreRequest DeleteUser MimeNoContent NoContent MimeNoContent -deleteUser (Username username) = _mkRequest "DELETE" ["/user/", toPath username] +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') +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] +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') +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) +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"] +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) +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 + _mkRequest "PUT" ["/user/",toPath username] + `setBodyParam` user data UpdateUser @@ -221,3 +241,4 @@ data UpdateUser instance HasBodyParam UpdateUser User instance Produces UpdateUser MimeNoContent + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs index 31cd12f7ada..d8e0caf8a98 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs @@ -12,42 +12,42 @@ Module : OpenAPIPetstore.Client -} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RecordWildCards #-} {-# 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 OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes + +import qualified Control.Exception.Safe as E +import qualified Control.Monad as P +import qualified Control.Monad.IO.Class 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 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(..)) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import GHC.Exts (IsString (..)) -- * Dispatch @@ -68,16 +68,16 @@ dispatchLbs manager config request = do -- | 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 + 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 + mimeError :: String -- ^ unrender/parser error + , mimeErrorResponse :: NH.Response BCL.ByteString -- ^ http response } deriving (Eq, Show) -- | send a request returning the 'MimeResult' @@ -153,7 +153,7 @@ dispatchInitUnsafe manager config (InitRequest req) = do "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> (case NH.requestBody req of NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) - _ -> "<RequestBody>") + _ -> "<RequestBody>") responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus responseLogMsg res = "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" @@ -171,7 +171,7 @@ _toInitRequest => OpenAPIPetstoreConfig -- ^ config -> OpenAPIPetstoreRequest req contentType res accept -- ^ request -> IO (InitRequest req contentType res accept) -- ^ initialized request -_toInitRequest config req0 = +_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 @@ -202,7 +202,7 @@ modifyInitRequest (InitRequest req) f = InitRequest (f req) 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 +-- ** Logging -- | Run a block using the configured logger instance runConfigLog diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs index 6fbc9899d34..f01a5542a69 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs @@ -12,70 +12,76 @@ Module : OpenAPIPetstore.Core -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# 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 OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes + +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, TypeRep, + Typeable, 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) +import qualified Network.HTTP.Types as NH +import qualified Prelude as P +import qualified Text.Printf as T +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Foldable (foldlM) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import Prelude (Bool (..), Char, + Functor, IO, Maybe (..), + Monad, String, fmap, + mempty, pure, return, + show, ($), (.), (<$>), + (<*>)) -- * 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 + { 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 } @@ -107,7 +113,7 @@ newConfig = do , configLogContext = logCxt , configAuthMethods = [] , configValidateAuthMethods = True - } + } -- | updates config use AuthMethod on matching requests addAuthMethod :: AuthMethod auth => OpenAPIPetstoreConfig -> auth -> OpenAPIPetstoreConfig @@ -129,7 +135,7 @@ withStderrLogging p = do -- | updates the config to disable logging withNoLogging :: OpenAPIPetstoreConfig -> OpenAPIPetstoreConfig withNoLogging p = p { configLogExecWithContext = runNullLogExec} - + -- * OpenAPIPetstoreRequest -- | Represents a request. @@ -141,9 +147,9 @@ withNoLogging p = p { configLogExecWithContext = runNullLogExec} -- * 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 + { 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) @@ -196,9 +202,9 @@ infixl 2 -&- -- | Request Params data Params = Params - { paramsQuery :: NH.Query + { paramsQuery :: NH.Query , paramsHeaders :: NH.RequestHeaders - , paramsBody :: ParamBody + , paramsBody :: ParamBody } deriving (P.Show) @@ -228,7 +234,7 @@ data ParamBody -- ** OpenAPIPetstoreRequest Utils -_mkRequest :: NH.Method -- ^ Method +_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 [] @@ -253,18 +259,18 @@ removeHeader req header = _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)] + 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)] + 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 = +setQuery req query = req & L.over (rParamsL . paramsQueryL) @@ -273,25 +279,25 @@ setQuery req query = cifst = CI.mk . P.fst addForm :: OpenAPIPetstoreRequest req contentType res accept -> WH.Form -> OpenAPIPetstoreRequest req contentType res accept -addForm req newform = +addForm req newform = let form = case paramsBody (rParams req) of ParamBodyFormUrlEncoded _form -> _form - _ -> mempty + _ -> 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 = +_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 = +_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 = +_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 @@ -347,10 +353,10 @@ _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 '|') + CommaSeparated -> go (one ',') + SpaceSeparated -> go (one ' ') + TabSeparated -> go (one '\t') + PipeSeparated -> go (one '|') MultiParamArray -> expandList where go sep = @@ -360,7 +366,7 @@ _toCollA' c encode one xs = case c of {-# INLINE go #-} {-# INLINE expandList #-} {-# INLINE combine #-} - + -- * AuthMethods -- | Provides a method to apply auth methods to requests @@ -391,7 +397,7 @@ _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) @@ -399,7 +405,7 @@ _omitNulls :: [(Text, A.Value)] -> A.Value _omitNulls = A.object . P.filter notNull where notNull (_, A.Null) = False - notNull _ = True + notNull _ = True -- | Encodes fields using WH.toQueryParam _toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) @@ -408,13 +414,13 @@ _toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x -- | Collapse (Just "") to Nothing _emptyToNothing :: Maybe String -> Maybe String _emptyToNothing (Just "") = Nothing -_emptyToNothing x = x +_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 +_memptyToNothing x = x {-# INLINE _memptyToNothing #-} -- * DateTime Formatting @@ -485,7 +491,7 @@ _showDate = -- * Byte/Binary Formatting - + -- | base64 encoded characters newtype ByteArray = ByteArray { unByteArray :: BL.ByteString } deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index 35eeff12114..cd76f7789db 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -7,10 +7,12 @@ 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 #-} @@ -30,10 +32,10 @@ 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 +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 @@ -45,6 +47,7 @@ type LogContext = LG.LogEnv type LogLevel = LG.Severity -- * default logger + -- | the default log environment initLogContext :: IO LogContext initLogContext = LG.initLogEnv "OpenAPIPetstore" "dev" @@ -54,6 +57,7 @@ runDefaultLogExecWithContext :: LogExecWithContext runDefaultLogExecWithContext = LG.runKatipT -- * stdout logger + -- | Runs a Katip logging block with the Log environment stdoutLoggingExec :: LogExecWithContext stdoutLoggingExec = runDefaultLogExecWithContext @@ -61,10 +65,11 @@ 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 + 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 @@ -72,25 +77,28 @@ 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 + 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) +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 + :: (LG.Katip m, E.MonadCatch m, Applicative m) + => Text -> m a -> m a logExceptions src = E.handle (\(e :: E.SomeException) -> do @@ -98,6 +106,7 @@ logExceptions src = E.throw e) -- * Log Level + levelInfo :: LogLevel levelInfo = LG.InfoS @@ -106,3 +115,4 @@ levelError = LG.ErrorS levelDebug :: LogLevel levelDebug = LG.DebugS + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs index 0da4b6310f0..e9bfbd8babb 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs @@ -12,35 +12,38 @@ Module : OpenAPIPetstore.MimeTypes -} -{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# 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 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 +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 (Bool (..), Char, Double, FilePath, + Float, Int, Integer, Maybe (..), + String, fmap, mempty, undefined, + ($), (.), (<$>), (<*>)) +import qualified Prelude as P -- * ContentType MimeType @@ -82,13 +85,13 @@ class P.Typeable mtype => MimeType mtype where mimeTypes :: P.Proxy mtype -> [ME.MediaType] mimeTypes p = case mimeType p of - Just x -> [x] + Just x -> [x] Nothing -> [] mimeType :: P.Proxy mtype -> Maybe ME.MediaType mimeType p = case mimeTypes p of - [] -> Nothing + [] -> Nothing (x:_) -> Just x mimeType' :: mtype -> Maybe ME.MediaType diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index bf901e19eed..0f25aaae94d 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -7,9 +7,11 @@ OpenAPI Petstore API version: 1.0.0 Generated by OpenAPI Generator (https://openapi-generator.tech) -} + {-| Module : OpenAPIPetstore.Model -} + {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveGeneric #-} @@ -22,8 +24,7 @@ Module : OpenAPIPetstore.Model {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeFamilies #-} -{-# OPTIONS_GHC - -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} +{-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.Model where @@ -66,218 +67,140 @@ import Prelude (Applicative, Bool (..), Char, import qualified Prelude as P + + -- * Parameter newtypes + + -- ** AdditionalMetadata -newtype AdditionalMetadata = AdditionalMetadata - { unAdditionalMetadata :: Text - } deriving (P.Eq, P.Show) +newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } deriving (P.Eq, P.Show) -- ** ApiKey -newtype ApiKey = ApiKey - { unApiKey :: Text - } deriving (P.Eq, P.Show) +newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) -- ** Body -newtype Body = Body - { unBody :: Double - } deriving (P.Eq, P.Show, A.ToJSON) +newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON) -- ** BodyBool -newtype BodyBool = BodyBool - { unBodyBool :: Bool - } deriving (P.Eq, P.Show, A.ToJSON) +newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON) -- ** BodyText -newtype BodyText = BodyText - { unBodyText :: Text - } deriving (P.Eq, P.Show, A.ToJSON) +newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON) -- ** Byte -newtype Byte = Byte - { unByte :: ByteArray - } deriving (P.Eq, P.Show) +newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) -- ** Callback -newtype Callback = Callback - { unCallback :: Text - } deriving (P.Eq, P.Show) +newtype Callback = Callback { unCallback :: Text } deriving (P.Eq, P.Show) -- ** EnumFormString -newtype EnumFormString = EnumFormString - { unEnumFormString :: E'EnumFormString - } deriving (P.Eq, P.Show) +newtype EnumFormString = EnumFormString { unEnumFormString :: E'EnumFormString } deriving (P.Eq, P.Show) -- ** EnumFormStringArray -newtype EnumFormStringArray = EnumFormStringArray - { unEnumFormStringArray :: [E'EnumFormStringArray] - } deriving (P.Eq, P.Show) +newtype EnumFormStringArray = EnumFormStringArray { unEnumFormStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) -- ** EnumHeaderString -newtype EnumHeaderString = EnumHeaderString - { unEnumHeaderString :: E'EnumFormString - } deriving (P.Eq, P.Show) +newtype EnumHeaderString = EnumHeaderString { unEnumHeaderString :: E'EnumFormString } deriving (P.Eq, P.Show) -- ** EnumHeaderStringArray -newtype EnumHeaderStringArray = EnumHeaderStringArray - { unEnumHeaderStringArray :: [E'EnumFormStringArray] - } deriving (P.Eq, P.Show) +newtype EnumHeaderStringArray = EnumHeaderStringArray { unEnumHeaderStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) -- ** EnumQueryDouble -newtype EnumQueryDouble = EnumQueryDouble - { unEnumQueryDouble :: E'EnumNumber - } deriving (P.Eq, P.Show) +newtype EnumQueryDouble = EnumQueryDouble { unEnumQueryDouble :: E'EnumNumber } deriving (P.Eq, P.Show) -- ** EnumQueryInteger -newtype EnumQueryInteger = EnumQueryInteger - { unEnumQueryInteger :: E'EnumQueryInteger - } deriving (P.Eq, P.Show) +newtype EnumQueryInteger = EnumQueryInteger { unEnumQueryInteger :: E'EnumQueryInteger } deriving (P.Eq, P.Show) -- ** EnumQueryString -newtype EnumQueryString = EnumQueryString - { unEnumQueryString :: E'EnumFormString - } deriving (P.Eq, P.Show) +newtype EnumQueryString = EnumQueryString { unEnumQueryString :: E'EnumFormString } deriving (P.Eq, P.Show) -- ** EnumQueryStringArray -newtype EnumQueryStringArray = EnumQueryStringArray - { unEnumQueryStringArray :: [E'EnumFormStringArray] - } deriving (P.Eq, P.Show) +newtype EnumQueryStringArray = EnumQueryStringArray { unEnumQueryStringArray :: [E'EnumFormStringArray] } deriving (P.Eq, P.Show) -- ** File2 -newtype File2 = File2 - { unFile2 :: FilePath - } deriving (P.Eq, P.Show) +newtype File2 = File2 { unFile2 :: FilePath } deriving (P.Eq, P.Show) -- ** Int32 -newtype Int32 = Int32 - { unInt32 :: Int - } deriving (P.Eq, P.Show) +newtype Int32 = Int32 { unInt32 :: Int } deriving (P.Eq, P.Show) -- ** Int64 -newtype Int64 = Int64 - { unInt64 :: Integer - } deriving (P.Eq, P.Show) +newtype Int64 = Int64 { unInt64 :: Integer } deriving (P.Eq, P.Show) -- ** Name2 -newtype Name2 = Name2 - { unName2 :: Text - } deriving (P.Eq, P.Show) +newtype Name2 = Name2 { unName2 :: Text } deriving (P.Eq, P.Show) -- ** Number -newtype Number = Number - { unNumber :: Double - } deriving (P.Eq, P.Show) +newtype Number = Number { unNumber :: Double } deriving (P.Eq, P.Show) -- ** OrderId -newtype OrderId = OrderId - { unOrderId :: Integer - } deriving (P.Eq, P.Show) +newtype OrderId = OrderId { unOrderId :: Integer } deriving (P.Eq, P.Show) -- ** OrderIdText -newtype OrderIdText = OrderIdText - { unOrderIdText :: Text - } deriving (P.Eq, P.Show) +newtype OrderIdText = OrderIdText { unOrderIdText :: Text } deriving (P.Eq, P.Show) -- ** Param -newtype Param = Param - { unParam :: Text - } deriving (P.Eq, P.Show) +newtype Param = Param { unParam :: Text } deriving (P.Eq, P.Show) -- ** Param2 -newtype Param2 = Param2 - { unParam2 :: Text - } deriving (P.Eq, P.Show) +newtype Param2 = Param2 { unParam2 :: Text } deriving (P.Eq, P.Show) -- ** ParamBinary -newtype ParamBinary = ParamBinary - { unParamBinary :: FilePath - } deriving (P.Eq, P.Show) +newtype ParamBinary = ParamBinary { unParamBinary :: FilePath } deriving (P.Eq, P.Show) -- ** ParamDate -newtype ParamDate = ParamDate - { unParamDate :: Date - } deriving (P.Eq, P.Show) +newtype ParamDate = ParamDate { unParamDate :: Date } deriving (P.Eq, P.Show) -- ** ParamDateTime -newtype ParamDateTime = ParamDateTime - { unParamDateTime :: DateTime - } deriving (P.Eq, P.Show) +newtype ParamDateTime = ParamDateTime { unParamDateTime :: DateTime } deriving (P.Eq, P.Show) -- ** ParamDouble -newtype ParamDouble = ParamDouble - { unParamDouble :: Double - } deriving (P.Eq, P.Show) +newtype ParamDouble = ParamDouble { unParamDouble :: Double } deriving (P.Eq, P.Show) -- ** ParamFloat -newtype ParamFloat = ParamFloat - { unParamFloat :: Float - } deriving (P.Eq, P.Show) +newtype ParamFloat = ParamFloat { unParamFloat :: Float } deriving (P.Eq, P.Show) -- ** ParamInteger -newtype ParamInteger = ParamInteger - { unParamInteger :: Int - } deriving (P.Eq, P.Show) +newtype ParamInteger = ParamInteger { unParamInteger :: Int } deriving (P.Eq, P.Show) -- ** ParamString -newtype ParamString = ParamString - { unParamString :: Text - } deriving (P.Eq, P.Show) +newtype ParamString = ParamString { unParamString :: Text } deriving (P.Eq, P.Show) -- ** Password -newtype Password = Password - { unPassword :: Text - } deriving (P.Eq, P.Show) +newtype Password = Password { unPassword :: Text } deriving (P.Eq, P.Show) -- ** PatternWithoutDelimiter -newtype PatternWithoutDelimiter = PatternWithoutDelimiter - { unPatternWithoutDelimiter :: Text - } deriving (P.Eq, P.Show) +newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDelimiter :: Text } deriving (P.Eq, P.Show) -- ** PetId -newtype PetId = PetId - { unPetId :: Integer - } deriving (P.Eq, P.Show) +newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) -- ** Query -newtype Query = Query - { unQuery :: Text - } deriving (P.Eq, P.Show) +newtype Query = Query { unQuery :: Text } deriving (P.Eq, P.Show) -- ** RequestBody -newtype RequestBody = RequestBody - { unRequestBody :: (Map.Map String Text) - } deriving (P.Eq, P.Show, A.ToJSON) +newtype RequestBody = RequestBody { unRequestBody :: (Map.Map String Text) } deriving (P.Eq, P.Show, A.ToJSON) -- ** RequiredFile -newtype RequiredFile = RequiredFile - { unRequiredFile :: FilePath - } deriving (P.Eq, P.Show) +newtype RequiredFile = RequiredFile { unRequiredFile :: FilePath } deriving (P.Eq, P.Show) -- ** Status -newtype Status = Status - { unStatus :: [E'Status2] - } deriving (P.Eq, P.Show) +newtype Status = Status { unStatus :: [E'Status2] } deriving (P.Eq, P.Show) -- ** StatusText -newtype StatusText = StatusText - { unStatusText :: Text - } deriving (P.Eq, P.Show) +newtype StatusText = StatusText { unStatusText :: Text } deriving (P.Eq, P.Show) -- ** Tags -newtype Tags = Tags - { unTags :: [Text] - } deriving (P.Eq, P.Show) +newtype Tags = Tags { unTags :: [Text] } deriving (P.Eq, P.Show) -- ** User2 -newtype User2 = User2 - { unUser2 :: [User] - } deriving (P.Eq, P.Show, A.ToJSON) +newtype User2 = User2 { unUser2 :: [User] } deriving (P.Eq, P.Show, A.ToJSON) -- ** Username -newtype Username = Username - { unUsername :: Text - } deriving (P.Eq, P.Show) +newtype Username = Username { unUsername :: Text } deriving (P.Eq, P.Show) -- * Models + + -- ** AdditionalPropertiesClass -- | AdditionalPropertiesClass data AdditionalPropertiesClass = AdditionalPropertiesClass @@ -287,21 +210,23 @@ data AdditionalPropertiesClass = AdditionalPropertiesClass -- | FromJSON AdditionalPropertiesClass instance A.FromJSON AdditionalPropertiesClass where - parseJSON = - A.withObject "AdditionalPropertiesClass" $ \o -> - AdditionalPropertiesClass <$> (o .:? "map_property") <*> - (o .:? "map_of_map_property") + parseJSON = A.withObject "AdditionalPropertiesClass" $ \o -> + AdditionalPropertiesClass + <$> (o .:? "map_property") + <*> (o .:? "map_of_map_property") -- | ToJSON AdditionalPropertiesClass instance A.ToJSON AdditionalPropertiesClass where toJSON AdditionalPropertiesClass {..} = - _omitNulls + _omitNulls [ "map_property" .= additionalPropertiesClassMapProperty , "map_of_map_property" .= additionalPropertiesClassMapOfMapProperty ] + -- | Construct a value of type 'AdditionalPropertiesClass' (by applying it's required fields, if any) -mkAdditionalPropertiesClass :: AdditionalPropertiesClass +mkAdditionalPropertiesClass + :: AdditionalPropertiesClass mkAdditionalPropertiesClass = AdditionalPropertiesClass { additionalPropertiesClassMapProperty = Nothing @@ -317,20 +242,29 @@ data Animal = Animal -- | FromJSON Animal instance A.FromJSON Animal where - parseJSON = - A.withObject "Animal" $ \o -> - Animal <$> (o .: "className") <*> (o .:? "color") + parseJSON = A.withObject "Animal" $ \o -> + Animal + <$> (o .: "className") + <*> (o .:? "color") -- | ToJSON Animal instance A.ToJSON Animal where toJSON Animal {..} = - _omitNulls ["className" .= animalClassName, "color" .= animalColor] + _omitNulls + [ "className" .= animalClassName + , "color" .= animalColor + ] + -- | Construct a value of type 'Animal' (by applying it's required fields, if any) -mkAnimal :: - Text -- ^ 'animalClassName' +mkAnimal + :: Text -- ^ 'animalClassName' -> Animal -mkAnimal animalClassName = Animal {animalClassName, animalColor = Nothing} +mkAnimal animalClassName = + Animal + { animalClassName + , animalColor = Nothing + } -- ** AnimalFarm -- | AnimalFarm @@ -340,15 +274,25 @@ data AnimalFarm = AnimalFarm -- | FromJSON AnimalFarm instance A.FromJSON AnimalFarm where - parseJSON = A.withObject "AnimalFarm" $ \o -> pure AnimalFarm + parseJSON = A.withObject "AnimalFarm" $ \o -> + pure AnimalFarm + -- | ToJSON AnimalFarm instance A.ToJSON AnimalFarm where - toJSON AnimalFarm = _omitNulls [] + toJSON AnimalFarm = + _omitNulls + [ + ] + -- | Construct a value of type 'AnimalFarm' (by applying it's required fields, if any) -mkAnimalFarm :: AnimalFarm -mkAnimalFarm = AnimalFarm {} +mkAnimalFarm + :: AnimalFarm +mkAnimalFarm = + AnimalFarm + { + } -- ** ApiResponse -- | ApiResponse @@ -360,21 +304,25 @@ data ApiResponse = ApiResponse -- | FromJSON ApiResponse instance A.FromJSON ApiResponse where - parseJSON = - A.withObject "ApiResponse" $ \o -> - ApiResponse <$> (o .:? "code") <*> (o .:? "type") <*> (o .:? "message") + parseJSON = A.withObject "ApiResponse" $ \o -> + ApiResponse + <$> (o .:? "code") + <*> (o .:? "type") + <*> (o .:? "message") -- | ToJSON ApiResponse instance A.ToJSON ApiResponse where toJSON ApiResponse {..} = - _omitNulls + _omitNulls [ "code" .= apiResponseCode , "type" .= apiResponseType , "message" .= apiResponseMessage ] + -- | Construct a value of type 'ApiResponse' (by applying it's required fields, if any) -mkApiResponse :: ApiResponse +mkApiResponse + :: ApiResponse mkApiResponse = ApiResponse { apiResponseCode = Nothing @@ -390,19 +338,25 @@ data ArrayOfArrayOfNumberOnly = ArrayOfArrayOfNumberOnly -- | FromJSON ArrayOfArrayOfNumberOnly instance A.FromJSON ArrayOfArrayOfNumberOnly where - parseJSON = - A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> - ArrayOfArrayOfNumberOnly <$> (o .:? "ArrayArrayNumber") + parseJSON = A.withObject "ArrayOfArrayOfNumberOnly" $ \o -> + ArrayOfArrayOfNumberOnly + <$> (o .:? "ArrayArrayNumber") -- | ToJSON ArrayOfArrayOfNumberOnly instance A.ToJSON ArrayOfArrayOfNumberOnly where toJSON ArrayOfArrayOfNumberOnly {..} = - _omitNulls ["ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber] + _omitNulls + [ "ArrayArrayNumber" .= arrayOfArrayOfNumberOnlyArrayArrayNumber + ] + -- | Construct a value of type 'ArrayOfArrayOfNumberOnly' (by applying it's required fields, if any) -mkArrayOfArrayOfNumberOnly :: ArrayOfArrayOfNumberOnly +mkArrayOfArrayOfNumberOnly + :: ArrayOfArrayOfNumberOnly mkArrayOfArrayOfNumberOnly = - ArrayOfArrayOfNumberOnly {arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing} + ArrayOfArrayOfNumberOnly + { arrayOfArrayOfNumberOnlyArrayArrayNumber = Nothing + } -- ** ArrayOfNumberOnly -- | ArrayOfNumberOnly @@ -412,18 +366,25 @@ data ArrayOfNumberOnly = ArrayOfNumberOnly -- | FromJSON ArrayOfNumberOnly instance A.FromJSON ArrayOfNumberOnly where - parseJSON = - A.withObject "ArrayOfNumberOnly" $ \o -> - ArrayOfNumberOnly <$> (o .:? "ArrayNumber") + parseJSON = A.withObject "ArrayOfNumberOnly" $ \o -> + ArrayOfNumberOnly + <$> (o .:? "ArrayNumber") -- | ToJSON ArrayOfNumberOnly instance A.ToJSON ArrayOfNumberOnly where toJSON ArrayOfNumberOnly {..} = - _omitNulls ["ArrayNumber" .= arrayOfNumberOnlyArrayNumber] + _omitNulls + [ "ArrayNumber" .= arrayOfNumberOnlyArrayNumber + ] + -- | Construct a value of type 'ArrayOfNumberOnly' (by applying it's required fields, if any) -mkArrayOfNumberOnly :: ArrayOfNumberOnly -mkArrayOfNumberOnly = ArrayOfNumberOnly {arrayOfNumberOnlyArrayNumber = Nothing} +mkArrayOfNumberOnly + :: ArrayOfNumberOnly +mkArrayOfNumberOnly = + ArrayOfNumberOnly + { arrayOfNumberOnlyArrayNumber = Nothing + } -- ** ArrayTest -- | ArrayTest @@ -435,23 +396,25 @@ data ArrayTest = ArrayTest -- | FromJSON ArrayTest instance A.FromJSON ArrayTest where - parseJSON = - A.withObject "ArrayTest" $ \o -> - ArrayTest <$> (o .:? "array_of_string") <*> - (o .:? "array_array_of_integer") <*> - (o .:? "array_array_of_model") + parseJSON = A.withObject "ArrayTest" $ \o -> + ArrayTest + <$> (o .:? "array_of_string") + <*> (o .:? "array_array_of_integer") + <*> (o .:? "array_array_of_model") -- | ToJSON ArrayTest instance A.ToJSON ArrayTest where toJSON ArrayTest {..} = - _omitNulls + _omitNulls [ "array_of_string" .= arrayTestArrayOfString , "array_array_of_integer" .= arrayTestArrayArrayOfInteger , "array_array_of_model" .= arrayTestArrayArrayOfModel ] + -- | Construct a value of type 'ArrayTest' (by applying it's required fields, if any) -mkArrayTest :: ArrayTest +mkArrayTest + :: ArrayTest mkArrayTest = ArrayTest { arrayTestArrayOfString = Nothing @@ -472,18 +435,19 @@ data Capitalization = Capitalization -- | FromJSON Capitalization instance A.FromJSON Capitalization where - parseJSON = - A.withObject "Capitalization" $ \o -> - Capitalization <$> (o .:? "smallCamel") <*> (o .:? "CapitalCamel") <*> - (o .:? "small_Snake") <*> - (o .:? "Capital_Snake") <*> - (o .:? "SCA_ETH_Flow_Points") <*> - (o .:? "ATT_NAME") + parseJSON = A.withObject "Capitalization" $ \o -> + Capitalization + <$> (o .:? "smallCamel") + <*> (o .:? "CapitalCamel") + <*> (o .:? "small_Snake") + <*> (o .:? "Capital_Snake") + <*> (o .:? "SCA_ETH_Flow_Points") + <*> (o .:? "ATT_NAME") -- | ToJSON Capitalization instance A.ToJSON Capitalization where toJSON Capitalization {..} = - _omitNulls + _omitNulls [ "smallCamel" .= capitalizationSmallCamel , "CapitalCamel" .= capitalizationCapitalCamel , "small_Snake" .= capitalizationSmallSnake @@ -492,8 +456,10 @@ instance A.ToJSON Capitalization where , "ATT_NAME" .= capitalizationAttName ] + -- | Construct a value of type 'Capitalization' (by applying it's required fields, if any) -mkCapitalization :: Capitalization +mkCapitalization + :: Capitalization mkCapitalization = Capitalization { capitalizationSmallCamel = Nothing @@ -514,25 +480,32 @@ data Cat = Cat -- | FromJSON Cat instance A.FromJSON Cat where - parseJSON = - A.withObject "Cat" $ \o -> - Cat <$> (o .: "className") <*> (o .:? "color") <*> (o .:? "declawed") + parseJSON = A.withObject "Cat" $ \o -> + Cat + <$> (o .: "className") + <*> (o .:? "color") + <*> (o .:? "declawed") -- | ToJSON Cat instance A.ToJSON Cat where toJSON Cat {..} = - _omitNulls + _omitNulls [ "className" .= catClassName , "color" .= catColor , "declawed" .= catDeclawed ] + -- | Construct a value of type 'Cat' (by applying it's required fields, if any) -mkCat :: - Text -- ^ 'catClassName' +mkCat + :: Text -- ^ 'catClassName' -> Cat mkCat catClassName = - Cat {catClassName, catColor = Nothing, catDeclawed = Nothing} + Cat + { catClassName + , catColor = Nothing + , catDeclawed = Nothing + } -- ** Category -- | Category @@ -543,16 +516,28 @@ data Category = Category -- | FromJSON Category instance A.FromJSON Category where - parseJSON = - A.withObject "Category" $ \o -> Category <$> (o .:? "id") <*> (o .:? "name") + parseJSON = A.withObject "Category" $ \o -> + Category + <$> (o .:? "id") + <*> (o .:? "name") -- | ToJSON Category instance A.ToJSON Category where - toJSON Category {..} = _omitNulls ["id" .= categoryId, "name" .= categoryName] + toJSON Category {..} = + _omitNulls + [ "id" .= categoryId + , "name" .= categoryName + ] + -- | Construct a value of type 'Category' (by applying it's required fields, if any) -mkCategory :: Category -mkCategory = Category {categoryId = Nothing, categoryName = Nothing} +mkCategory + :: Category +mkCategory = + Category + { categoryId = Nothing + , categoryName = Nothing + } -- ** ClassModel -- | ClassModel @@ -563,15 +548,25 @@ data ClassModel = ClassModel -- | FromJSON ClassModel instance A.FromJSON ClassModel where - parseJSON = A.withObject "ClassModel" $ \o -> ClassModel <$> (o .:? "_class") + parseJSON = A.withObject "ClassModel" $ \o -> + ClassModel + <$> (o .:? "_class") -- | ToJSON ClassModel instance A.ToJSON ClassModel where - toJSON ClassModel {..} = _omitNulls ["_class" .= classModelClass] + toJSON ClassModel {..} = + _omitNulls + [ "_class" .= classModelClass + ] + -- | Construct a value of type 'ClassModel' (by applying it's required fields, if any) -mkClassModel :: ClassModel -mkClassModel = ClassModel {classModelClass = Nothing} +mkClassModel + :: ClassModel +mkClassModel = + ClassModel + { classModelClass = Nothing + } -- ** Client -- | Client @@ -581,15 +576,25 @@ data Client = Client -- | FromJSON Client instance A.FromJSON Client where - parseJSON = A.withObject "Client" $ \o -> Client <$> (o .:? "client") + parseJSON = A.withObject "Client" $ \o -> + Client + <$> (o .:? "client") -- | ToJSON Client instance A.ToJSON Client where - toJSON Client {..} = _omitNulls ["client" .= clientClient] + toJSON Client {..} = + _omitNulls + [ "client" .= clientClient + ] + -- | Construct a value of type 'Client' (by applying it's required fields, if any) -mkClient :: Client -mkClient = Client {clientClient = Nothing} +mkClient + :: Client +mkClient = + Client + { clientClient = Nothing + } -- ** Dog -- | Dog @@ -601,21 +606,32 @@ data Dog = Dog -- | FromJSON Dog instance A.FromJSON Dog where - parseJSON = - A.withObject "Dog" $ \o -> - Dog <$> (o .: "className") <*> (o .:? "color") <*> (o .:? "breed") + parseJSON = A.withObject "Dog" $ \o -> + Dog + <$> (o .: "className") + <*> (o .:? "color") + <*> (o .:? "breed") -- | ToJSON Dog instance A.ToJSON Dog where toJSON Dog {..} = - _omitNulls - ["className" .= dogClassName, "color" .= dogColor, "breed" .= dogBreed] + _omitNulls + [ "className" .= dogClassName + , "color" .= dogColor + , "breed" .= dogBreed + ] + -- | Construct a value of type 'Dog' (by applying it's required fields, if any) -mkDog :: - Text -- ^ 'dogClassName' +mkDog + :: Text -- ^ 'dogClassName' -> Dog -mkDog dogClassName = Dog {dogClassName, dogColor = Nothing, dogBreed = Nothing} +mkDog dogClassName = + Dog + { dogClassName + , dogColor = Nothing + , dogBreed = Nothing + } -- ** EnumArrays -- | EnumArrays @@ -626,22 +642,28 @@ data EnumArrays = EnumArrays -- | FromJSON EnumArrays instance A.FromJSON EnumArrays where - parseJSON = - A.withObject "EnumArrays" $ \o -> - EnumArrays <$> (o .:? "just_symbol") <*> (o .:? "array_enum") + parseJSON = A.withObject "EnumArrays" $ \o -> + EnumArrays + <$> (o .:? "just_symbol") + <*> (o .:? "array_enum") -- | ToJSON EnumArrays instance A.ToJSON EnumArrays where toJSON EnumArrays {..} = - _omitNulls + _omitNulls [ "just_symbol" .= enumArraysJustSymbol , "array_enum" .= enumArraysArrayEnum ] + -- | Construct a value of type 'EnumArrays' (by applying it's required fields, if any) -mkEnumArrays :: EnumArrays +mkEnumArrays + :: EnumArrays mkEnumArrays = - EnumArrays {enumArraysJustSymbol = Nothing, enumArraysArrayEnum = Nothing} + EnumArrays + { enumArraysJustSymbol = Nothing + , enumArraysArrayEnum = Nothing + } -- ** EnumTest -- | EnumTest @@ -655,17 +677,18 @@ data EnumTest = EnumTest -- | FromJSON EnumTest instance A.FromJSON EnumTest where - parseJSON = - A.withObject "EnumTest" $ \o -> - EnumTest <$> (o .:? "enum_string") <*> (o .: "enum_string_required") <*> - (o .:? "enum_integer") <*> - (o .:? "enum_number") <*> - (o .:? "outerEnum") + parseJSON = A.withObject "EnumTest" $ \o -> + EnumTest + <$> (o .:? "enum_string") + <*> (o .: "enum_string_required") + <*> (o .:? "enum_integer") + <*> (o .:? "enum_number") + <*> (o .:? "outerEnum") -- | ToJSON EnumTest instance A.ToJSON EnumTest where toJSON EnumTest {..} = - _omitNulls + _omitNulls [ "enum_string" .= enumTestEnumString , "enum_string_required" .= enumTestEnumStringRequired , "enum_integer" .= enumTestEnumInteger @@ -673,9 +696,10 @@ instance A.ToJSON EnumTest where , "outerEnum" .= enumTestOuterEnum ] + -- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) -mkEnumTest :: - E'EnumString -- ^ 'enumTestEnumStringRequired' +mkEnumTest + :: E'EnumString -- ^ 'enumTestEnumStringRequired' -> EnumTest mkEnumTest enumTestEnumStringRequired = EnumTest @@ -695,15 +719,25 @@ data File = File -- | FromJSON File instance A.FromJSON File where - parseJSON = A.withObject "File" $ \o -> File <$> (o .:? "sourceURI") + parseJSON = A.withObject "File" $ \o -> + File + <$> (o .:? "sourceURI") -- | ToJSON File instance A.ToJSON File where - toJSON File {..} = _omitNulls ["sourceURI" .= fileSourceUri] + toJSON File {..} = + _omitNulls + [ "sourceURI" .= fileSourceUri + ] + -- | Construct a value of type 'File' (by applying it's required fields, if any) -mkFile :: File -mkFile = File {fileSourceUri = Nothing} +mkFile + :: File +mkFile = + File + { fileSourceUri = Nothing + } -- ** FileSchemaTestClass -- | FileSchemaTestClass @@ -714,21 +748,28 @@ data FileSchemaTestClass = FileSchemaTestClass -- | FromJSON FileSchemaTestClass instance A.FromJSON FileSchemaTestClass where - parseJSON = - A.withObject "FileSchemaTestClass" $ \o -> - FileSchemaTestClass <$> (o .:? "file") <*> (o .:? "files") + parseJSON = A.withObject "FileSchemaTestClass" $ \o -> + FileSchemaTestClass + <$> (o .:? "file") + <*> (o .:? "files") -- | ToJSON FileSchemaTestClass instance A.ToJSON FileSchemaTestClass where toJSON FileSchemaTestClass {..} = - _omitNulls - ["file" .= fileSchemaTestClassFile, "files" .= fileSchemaTestClassFiles] + _omitNulls + [ "file" .= fileSchemaTestClassFile + , "files" .= fileSchemaTestClassFiles + ] + -- | Construct a value of type 'FileSchemaTestClass' (by applying it's required fields, if any) -mkFileSchemaTestClass :: FileSchemaTestClass +mkFileSchemaTestClass + :: FileSchemaTestClass mkFileSchemaTestClass = FileSchemaTestClass - {fileSchemaTestClassFile = Nothing, fileSchemaTestClassFiles = Nothing} + { fileSchemaTestClassFile = Nothing + , fileSchemaTestClassFiles = Nothing + } -- ** FormatTest -- | FormatTest @@ -750,24 +791,26 @@ data FormatTest = FormatTest -- | FromJSON FormatTest instance A.FromJSON FormatTest where - parseJSON = - A.withObject "FormatTest" $ \o -> - FormatTest <$> (o .:? "integer") <*> (o .:? "int32") <*> (o .:? "int64") <*> - (o .: "number") <*> - (o .:? "float") <*> - (o .:? "double") <*> - (o .:? "string") <*> - (o .: "byte") <*> - (o .:? "binary") <*> - (o .: "date") <*> - (o .:? "dateTime") <*> - (o .:? "uuid") <*> - (o .: "password") + parseJSON = A.withObject "FormatTest" $ \o -> + FormatTest + <$> (o .:? "integer") + <*> (o .:? "int32") + <*> (o .:? "int64") + <*> (o .: "number") + <*> (o .:? "float") + <*> (o .:? "double") + <*> (o .:? "string") + <*> (o .: "byte") + <*> (o .:? "binary") + <*> (o .: "date") + <*> (o .:? "dateTime") + <*> (o .:? "uuid") + <*> (o .: "password") -- | ToJSON FormatTest instance A.ToJSON FormatTest where toJSON FormatTest {..} = - _omitNulls + _omitNulls [ "integer" .= formatTestInteger , "int32" .= formatTestInt32 , "int64" .= formatTestInt64 @@ -783,9 +826,10 @@ instance A.ToJSON FormatTest where , "password" .= formatTestPassword ] + -- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) -mkFormatTest :: - Double -- ^ 'formatTestNumber' +mkFormatTest + :: Double -- ^ 'formatTestNumber' -> ByteArray -- ^ 'formatTestByte' -> Date -- ^ 'formatTestDate' -> Text -- ^ 'formatTestPassword' @@ -816,19 +860,28 @@ data HasOnlyReadOnly = HasOnlyReadOnly -- | FromJSON HasOnlyReadOnly instance A.FromJSON HasOnlyReadOnly where - parseJSON = - A.withObject "HasOnlyReadOnly" $ \o -> - HasOnlyReadOnly <$> (o .:? "bar") <*> (o .:? "foo") + parseJSON = A.withObject "HasOnlyReadOnly" $ \o -> + HasOnlyReadOnly + <$> (o .:? "bar") + <*> (o .:? "foo") -- | ToJSON HasOnlyReadOnly instance A.ToJSON HasOnlyReadOnly where toJSON HasOnlyReadOnly {..} = - _omitNulls ["bar" .= hasOnlyReadOnlyBar, "foo" .= hasOnlyReadOnlyFoo] + _omitNulls + [ "bar" .= hasOnlyReadOnlyBar + , "foo" .= hasOnlyReadOnlyFoo + ] + -- | Construct a value of type 'HasOnlyReadOnly' (by applying it's required fields, if any) -mkHasOnlyReadOnly :: HasOnlyReadOnly +mkHasOnlyReadOnly + :: HasOnlyReadOnly mkHasOnlyReadOnly = - HasOnlyReadOnly {hasOnlyReadOnlyBar = Nothing, hasOnlyReadOnlyFoo = Nothing} + HasOnlyReadOnly + { hasOnlyReadOnlyBar = Nothing + , hasOnlyReadOnlyFoo = Nothing + } -- ** MapTest -- | MapTest @@ -841,24 +894,27 @@ data MapTest = MapTest -- | FromJSON MapTest instance A.FromJSON MapTest where - parseJSON = - A.withObject "MapTest" $ \o -> - MapTest <$> (o .:? "map_map_of_string") <*> (o .:? "map_of_enum_string") <*> - (o .:? "direct_map") <*> - (o .:? "indirect_map") + parseJSON = A.withObject "MapTest" $ \o -> + MapTest + <$> (o .:? "map_map_of_string") + <*> (o .:? "map_of_enum_string") + <*> (o .:? "direct_map") + <*> (o .:? "indirect_map") -- | ToJSON MapTest instance A.ToJSON MapTest where toJSON MapTest {..} = - _omitNulls + _omitNulls [ "map_map_of_string" .= mapTestMapMapOfString , "map_of_enum_string" .= mapTestMapOfEnumString , "direct_map" .= mapTestDirectMap , "indirect_map" .= mapTestIndirectMap ] + -- | Construct a value of type 'MapTest' (by applying it's required fields, if any) -mkMapTest :: MapTest +mkMapTest + :: MapTest mkMapTest = MapTest { mapTestMapMapOfString = Nothing @@ -877,24 +933,25 @@ data MixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalP -- | FromJSON MixedPropertiesAndAdditionalPropertiesClass instance A.FromJSON MixedPropertiesAndAdditionalPropertiesClass where - parseJSON = - A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> - MixedPropertiesAndAdditionalPropertiesClass <$> (o .:? "uuid") <*> - (o .:? "dateTime") <*> - (o .:? "map") + parseJSON = A.withObject "MixedPropertiesAndAdditionalPropertiesClass" $ \o -> + MixedPropertiesAndAdditionalPropertiesClass + <$> (o .:? "uuid") + <*> (o .:? "dateTime") + <*> (o .:? "map") -- | ToJSON MixedPropertiesAndAdditionalPropertiesClass instance A.ToJSON MixedPropertiesAndAdditionalPropertiesClass where toJSON MixedPropertiesAndAdditionalPropertiesClass {..} = - _omitNulls + _omitNulls [ "uuid" .= mixedPropertiesAndAdditionalPropertiesClassUuid , "dateTime" .= mixedPropertiesAndAdditionalPropertiesClassDateTime , "map" .= mixedPropertiesAndAdditionalPropertiesClassMap ] + -- | Construct a value of type 'MixedPropertiesAndAdditionalPropertiesClass' (by applying it's required fields, if any) -mkMixedPropertiesAndAdditionalPropertiesClass :: - MixedPropertiesAndAdditionalPropertiesClass +mkMixedPropertiesAndAdditionalPropertiesClass + :: MixedPropertiesAndAdditionalPropertiesClass mkMixedPropertiesAndAdditionalPropertiesClass = MixedPropertiesAndAdditionalPropertiesClass { mixedPropertiesAndAdditionalPropertiesClassUuid = Nothing @@ -912,21 +969,28 @@ data Model200Response = Model200Response -- | FromJSON Model200Response instance A.FromJSON Model200Response where - parseJSON = - A.withObject "Model200Response" $ \o -> - Model200Response <$> (o .:? "name") <*> (o .:? "class") + parseJSON = A.withObject "Model200Response" $ \o -> + Model200Response + <$> (o .:? "name") + <*> (o .:? "class") -- | ToJSON Model200Response instance A.ToJSON Model200Response where toJSON Model200Response {..} = - _omitNulls - ["name" .= model200ResponseName, "class" .= model200ResponseClass] + _omitNulls + [ "name" .= model200ResponseName + , "class" .= model200ResponseClass + ] + -- | Construct a value of type 'Model200Response' (by applying it's required fields, if any) -mkModel200Response :: Model200Response +mkModel200Response + :: Model200Response mkModel200Response = Model200Response - {model200ResponseName = Nothing, model200ResponseClass = Nothing} + { model200ResponseName = Nothing + , model200ResponseClass = Nothing + } -- ** ModelList -- | ModelList @@ -936,15 +1000,25 @@ data ModelList = ModelList -- | FromJSON ModelList instance A.FromJSON ModelList where - parseJSON = A.withObject "ModelList" $ \o -> ModelList <$> (o .:? "123-list") + parseJSON = A.withObject "ModelList" $ \o -> + ModelList + <$> (o .:? "123-list") -- | ToJSON ModelList instance A.ToJSON ModelList where - toJSON ModelList {..} = _omitNulls ["123-list" .= modelList123list] + toJSON ModelList {..} = + _omitNulls + [ "123-list" .= modelList123list + ] + -- | Construct a value of type 'ModelList' (by applying it's required fields, if any) -mkModelList :: ModelList -mkModelList = ModelList {modelList123list = Nothing} +mkModelList + :: ModelList +mkModelList = + ModelList + { modelList123list = Nothing + } -- ** ModelReturn -- | ModelReturn @@ -955,16 +1029,25 @@ data ModelReturn = ModelReturn -- | FromJSON ModelReturn instance A.FromJSON ModelReturn where - parseJSON = - A.withObject "ModelReturn" $ \o -> ModelReturn <$> (o .:? "return") + parseJSON = A.withObject "ModelReturn" $ \o -> + ModelReturn + <$> (o .:? "return") -- | ToJSON ModelReturn instance A.ToJSON ModelReturn where - toJSON ModelReturn {..} = _omitNulls ["return" .= modelReturnReturn] + toJSON ModelReturn {..} = + _omitNulls + [ "return" .= modelReturnReturn + ] + -- | Construct a value of type 'ModelReturn' (by applying it's required fields, if any) -mkModelReturn :: ModelReturn -mkModelReturn = ModelReturn {modelReturnReturn = Nothing} +mkModelReturn + :: ModelReturn +mkModelReturn = + ModelReturn + { modelReturnReturn = Nothing + } -- ** Name -- | Name @@ -978,24 +1061,27 @@ data Name = Name -- | FromJSON Name instance A.FromJSON Name where - parseJSON = - A.withObject "Name" $ \o -> - Name <$> (o .: "name") <*> (o .:? "snake_case") <*> (o .:? "property") <*> - (o .:? "123Number") + parseJSON = A.withObject "Name" $ \o -> + Name + <$> (o .: "name") + <*> (o .:? "snake_case") + <*> (o .:? "property") + <*> (o .:? "123Number") -- | ToJSON Name instance A.ToJSON Name where toJSON Name {..} = - _omitNulls + _omitNulls [ "name" .= nameName , "snake_case" .= nameSnakeCase , "property" .= nameProperty , "123Number" .= name123number ] + -- | Construct a value of type 'Name' (by applying it's required fields, if any) -mkName :: - Int -- ^ 'nameName' +mkName + :: Int -- ^ 'nameName' -> Name mkName nameName = Name @@ -1013,16 +1099,25 @@ data NumberOnly = NumberOnly -- | FromJSON NumberOnly instance A.FromJSON NumberOnly where - parseJSON = - A.withObject "NumberOnly" $ \o -> NumberOnly <$> (o .:? "JustNumber") + parseJSON = A.withObject "NumberOnly" $ \o -> + NumberOnly + <$> (o .:? "JustNumber") -- | ToJSON NumberOnly instance A.ToJSON NumberOnly where - toJSON NumberOnly {..} = _omitNulls ["JustNumber" .= numberOnlyJustNumber] + toJSON NumberOnly {..} = + _omitNulls + [ "JustNumber" .= numberOnlyJustNumber + ] + -- | Construct a value of type 'NumberOnly' (by applying it's required fields, if any) -mkNumberOnly :: NumberOnly -mkNumberOnly = NumberOnly {numberOnlyJustNumber = Nothing} +mkNumberOnly + :: NumberOnly +mkNumberOnly = + NumberOnly + { numberOnlyJustNumber = Nothing + } -- ** Order -- | Order @@ -1037,17 +1132,19 @@ data Order = Order -- | FromJSON Order instance A.FromJSON Order where - parseJSON = - A.withObject "Order" $ \o -> - Order <$> (o .:? "id") <*> (o .:? "petId") <*> (o .:? "quantity") <*> - (o .:? "shipDate") <*> - (o .:? "status") <*> - (o .:? "complete") + parseJSON = A.withObject "Order" $ \o -> + Order + <$> (o .:? "id") + <*> (o .:? "petId") + <*> (o .:? "quantity") + <*> (o .:? "shipDate") + <*> (o .:? "status") + <*> (o .:? "complete") -- | ToJSON Order instance A.ToJSON Order where toJSON Order {..} = - _omitNulls + _omitNulls [ "id" .= orderId , "petId" .= orderPetId , "quantity" .= orderQuantity @@ -1056,8 +1153,10 @@ instance A.ToJSON Order where , "complete" .= orderComplete ] + -- | Construct a value of type 'Order' (by applying it's required fields, if any) -mkOrder :: Order +mkOrder + :: Order mkOrder = Order { orderId = Nothing @@ -1078,22 +1177,25 @@ data OuterComposite = OuterComposite -- | FromJSON OuterComposite instance A.FromJSON OuterComposite where - parseJSON = - A.withObject "OuterComposite" $ \o -> - OuterComposite <$> (o .:? "my_number") <*> (o .:? "my_string") <*> - (o .:? "my_boolean") + parseJSON = A.withObject "OuterComposite" $ \o -> + OuterComposite + <$> (o .:? "my_number") + <*> (o .:? "my_string") + <*> (o .:? "my_boolean") -- | ToJSON OuterComposite instance A.ToJSON OuterComposite where toJSON OuterComposite {..} = - _omitNulls + _omitNulls [ "my_number" .= outerCompositeMyNumber , "my_string" .= outerCompositeMyString , "my_boolean" .= outerCompositeMyBoolean ] + -- | Construct a value of type 'OuterComposite' (by applying it's required fields, if any) -mkOuterComposite :: OuterComposite +mkOuterComposite + :: OuterComposite mkOuterComposite = OuterComposite { outerCompositeMyNumber = Nothing @@ -1114,17 +1216,19 @@ data Pet = Pet -- | FromJSON Pet instance A.FromJSON Pet where - parseJSON = - A.withObject "Pet" $ \o -> - Pet <$> (o .:? "id") <*> (o .:? "category") <*> (o .: "name") <*> - (o .: "photoUrls") <*> - (o .:? "tags") <*> - (o .:? "status") + parseJSON = A.withObject "Pet" $ \o -> + Pet + <$> (o .:? "id") + <*> (o .:? "category") + <*> (o .: "name") + <*> (o .: "photoUrls") + <*> (o .:? "tags") + <*> (o .:? "status") -- | ToJSON Pet instance A.ToJSON Pet where toJSON Pet {..} = - _omitNulls + _omitNulls [ "id" .= petId , "category" .= petCategory , "name" .= petName @@ -1133,9 +1237,10 @@ instance A.ToJSON Pet where , "status" .= petStatus ] + -- | Construct a value of type 'Pet' (by applying it's required fields, if any) -mkPet :: - Text -- ^ 'petName' +mkPet + :: Text -- ^ 'petName' -> [Text] -- ^ 'petPhotoUrls' -> Pet mkPet petName petPhotoUrls = @@ -1157,19 +1262,28 @@ data ReadOnlyFirst = ReadOnlyFirst -- | FromJSON ReadOnlyFirst instance A.FromJSON ReadOnlyFirst where - parseJSON = - A.withObject "ReadOnlyFirst" $ \o -> - ReadOnlyFirst <$> (o .:? "bar") <*> (o .:? "baz") + parseJSON = A.withObject "ReadOnlyFirst" $ \o -> + ReadOnlyFirst + <$> (o .:? "bar") + <*> (o .:? "baz") -- | ToJSON ReadOnlyFirst instance A.ToJSON ReadOnlyFirst where toJSON ReadOnlyFirst {..} = - _omitNulls ["bar" .= readOnlyFirstBar, "baz" .= readOnlyFirstBaz] + _omitNulls + [ "bar" .= readOnlyFirstBar + , "baz" .= readOnlyFirstBaz + ] + -- | Construct a value of type 'ReadOnlyFirst' (by applying it's required fields, if any) -mkReadOnlyFirst :: ReadOnlyFirst +mkReadOnlyFirst + :: ReadOnlyFirst mkReadOnlyFirst = - ReadOnlyFirst {readOnlyFirstBar = Nothing, readOnlyFirstBaz = Nothing} + ReadOnlyFirst + { readOnlyFirstBar = Nothing + , readOnlyFirstBaz = Nothing + } -- ** SpecialModelName -- | SpecialModelName @@ -1179,20 +1293,25 @@ data SpecialModelName = SpecialModelName -- | FromJSON SpecialModelName instance A.FromJSON SpecialModelName where - parseJSON = - A.withObject "SpecialModelName" $ \o -> - SpecialModelName <$> (o .:? "$special[property.name]") + parseJSON = A.withObject "SpecialModelName" $ \o -> + SpecialModelName + <$> (o .:? "$special[property.name]") -- | ToJSON SpecialModelName instance A.ToJSON SpecialModelName where toJSON SpecialModelName {..} = - _omitNulls - ["$special[property.name]" .= specialModelNameSpecialPropertyName] + _omitNulls + [ "$special[property.name]" .= specialModelNameSpecialPropertyName + ] + -- | Construct a value of type 'SpecialModelName' (by applying it's required fields, if any) -mkSpecialModelName :: SpecialModelName +mkSpecialModelName + :: SpecialModelName mkSpecialModelName = - SpecialModelName {specialModelNameSpecialPropertyName = Nothing} + SpecialModelName + { specialModelNameSpecialPropertyName = Nothing + } -- ** StringBooleanMap -- | StringBooleanMap @@ -1202,15 +1321,25 @@ data StringBooleanMap = StringBooleanMap -- | FromJSON StringBooleanMap instance A.FromJSON StringBooleanMap where - parseJSON = A.withObject "StringBooleanMap" $ \o -> pure StringBooleanMap + parseJSON = A.withObject "StringBooleanMap" $ \o -> + pure StringBooleanMap + -- | ToJSON StringBooleanMap instance A.ToJSON StringBooleanMap where - toJSON StringBooleanMap = _omitNulls [] + toJSON StringBooleanMap = + _omitNulls + [ + ] + -- | Construct a value of type 'StringBooleanMap' (by applying it's required fields, if any) -mkStringBooleanMap :: StringBooleanMap -mkStringBooleanMap = StringBooleanMap {} +mkStringBooleanMap + :: StringBooleanMap +mkStringBooleanMap = + StringBooleanMap + { + } -- ** Tag -- | Tag @@ -1221,15 +1350,28 @@ data Tag = Tag -- | FromJSON Tag instance A.FromJSON Tag where - parseJSON = A.withObject "Tag" $ \o -> Tag <$> (o .:? "id") <*> (o .:? "name") + parseJSON = A.withObject "Tag" $ \o -> + Tag + <$> (o .:? "id") + <*> (o .:? "name") -- | ToJSON Tag instance A.ToJSON Tag where - toJSON Tag {..} = _omitNulls ["id" .= tagId, "name" .= tagName] + toJSON Tag {..} = + _omitNulls + [ "id" .= tagId + , "name" .= tagName + ] + -- | Construct a value of type 'Tag' (by applying it's required fields, if any) -mkTag :: Tag -mkTag = Tag {tagId = Nothing, tagName = Nothing} +mkTag + :: Tag +mkTag = + Tag + { tagId = Nothing + , tagName = Nothing + } -- ** User -- | User @@ -1246,19 +1388,21 @@ data User = User -- | FromJSON User instance A.FromJSON User where - parseJSON = - A.withObject "User" $ \o -> - User <$> (o .:? "id") <*> (o .:? "username") <*> (o .:? "firstName") <*> - (o .:? "lastName") <*> - (o .:? "email") <*> - (o .:? "password") <*> - (o .:? "phone") <*> - (o .:? "userStatus") + parseJSON = A.withObject "User" $ \o -> + User + <$> (o .:? "id") + <*> (o .:? "username") + <*> (o .:? "firstName") + <*> (o .:? "lastName") + <*> (o .:? "email") + <*> (o .:? "password") + <*> (o .:? "phone") + <*> (o .:? "userStatus") -- | ToJSON User instance A.ToJSON User where toJSON User {..} = - _omitNulls + _omitNulls [ "id" .= userId , "username" .= userUsername , "firstName" .= userFirstName @@ -1269,8 +1413,10 @@ instance A.ToJSON User where , "userStatus" .= userUserStatus ] + -- | Construct a value of type 'User' (by applying it's required fields, if any) -mkUser :: User +mkUser + :: User mkUser = User { userId = Nothing @@ -1283,45 +1429,40 @@ mkUser = , userUserStatus = Nothing } + -- * Enums + + -- ** E'ArrayEnum + -- | Enum of 'Text' data E'ArrayEnum = E'ArrayEnum'Fish -- ^ @"fish"@ | E'ArrayEnum'Crab -- ^ @"crab"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'ArrayEnum where - toJSON = A.toJSON . fromE'ArrayEnum - -instance A.FromJSON E'ArrayEnum where - parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o - -instance WH.ToHttpApiData E'ArrayEnum where - toQueryParam = WH.toQueryParam . fromE'ArrayEnum - -instance WH.FromHttpApiData E'ArrayEnum where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum - -instance MimeRender MimeMultipartFormData E'ArrayEnum where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'ArrayEnum where toJSON = A.toJSON . fromE'ArrayEnum +instance A.FromJSON E'ArrayEnum where parseJSON o = P.either P.fail (pure . P.id) . toE'ArrayEnum =<< A.parseJSON o +instance WH.ToHttpApiData E'ArrayEnum where toQueryParam = WH.toQueryParam . fromE'ArrayEnum +instance WH.FromHttpApiData E'ArrayEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'ArrayEnum +instance MimeRender MimeMultipartFormData E'ArrayEnum where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'ArrayEnum' enum fromE'ArrayEnum :: E'ArrayEnum -> Text -fromE'ArrayEnum = - \case - E'ArrayEnum'Fish -> "fish" - E'ArrayEnum'Crab -> "crab" +fromE'ArrayEnum = \case + E'ArrayEnum'Fish -> "fish" + E'ArrayEnum'Crab -> "crab" -- | parse 'E'ArrayEnum' enum toE'ArrayEnum :: Text -> P.Either String E'ArrayEnum -toE'ArrayEnum = - \case - "fish" -> P.Right E'ArrayEnum'Fish - "crab" -> P.Right E'ArrayEnum'Crab - s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s +toE'ArrayEnum = \case + "fish" -> P.Right E'ArrayEnum'Fish + "crab" -> P.Right E'ArrayEnum'Crab + s -> P.Left $ "toE'ArrayEnum: enum parse failure: " P.++ P.show s + -- ** E'EnumFormString + -- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString @@ -1330,194 +1471,142 @@ data E'EnumFormString | E'EnumFormString'_xyz -- ^ @"(xyz)"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumFormString where - toJSON = A.toJSON . fromE'EnumFormString - -instance A.FromJSON E'EnumFormString where - parseJSON o = - P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumFormString where - toQueryParam = WH.toQueryParam . fromE'EnumFormString - -instance WH.FromHttpApiData E'EnumFormString where - parseQueryParam o = - WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString - -instance MimeRender MimeMultipartFormData E'EnumFormString where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumFormString where toJSON = A.toJSON . fromE'EnumFormString +instance A.FromJSON E'EnumFormString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumFormString where toQueryParam = WH.toQueryParam . fromE'EnumFormString +instance WH.FromHttpApiData E'EnumFormString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormString +instance MimeRender MimeMultipartFormData E'EnumFormString where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumFormString' enum fromE'EnumFormString :: E'EnumFormString -> Text -fromE'EnumFormString = - \case - E'EnumFormString'_abc -> "_abc" - E'EnumFormString'_efg -> "-efg" - E'EnumFormString'_xyz -> "(xyz)" +fromE'EnumFormString = \case + E'EnumFormString'_abc -> "_abc" + E'EnumFormString'_efg -> "-efg" + E'EnumFormString'_xyz -> "(xyz)" -- | parse 'E'EnumFormString' enum toE'EnumFormString :: Text -> P.Either String E'EnumFormString -toE'EnumFormString = - \case - "_abc" -> P.Right E'EnumFormString'_abc - "-efg" -> P.Right E'EnumFormString'_efg - "(xyz)" -> P.Right E'EnumFormString'_xyz - s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s +toE'EnumFormString = \case + "_abc" -> P.Right E'EnumFormString'_abc + "-efg" -> P.Right E'EnumFormString'_efg + "(xyz)" -> P.Right E'EnumFormString'_xyz + s -> P.Left $ "toE'EnumFormString: enum parse failure: " P.++ P.show s + -- ** E'EnumFormStringArray + -- | Enum of 'Text' data E'EnumFormStringArray = E'EnumFormStringArray'GreaterThan -- ^ @">"@ | E'EnumFormStringArray'Dollar -- ^ @"$"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumFormStringArray where - toJSON = A.toJSON . fromE'EnumFormStringArray - -instance A.FromJSON E'EnumFormStringArray where - parseJSON o = - P.either P.fail (pure . P.id) . toE'EnumFormStringArray =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumFormStringArray where - toQueryParam = WH.toQueryParam . fromE'EnumFormStringArray - -instance WH.FromHttpApiData E'EnumFormStringArray where - parseQueryParam o = - WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormStringArray - -instance MimeRender MimeMultipartFormData E'EnumFormStringArray where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumFormStringArray where toJSON = A.toJSON . fromE'EnumFormStringArray +instance A.FromJSON E'EnumFormStringArray where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumFormStringArray =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumFormStringArray where toQueryParam = WH.toQueryParam . fromE'EnumFormStringArray +instance WH.FromHttpApiData E'EnumFormStringArray where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumFormStringArray +instance MimeRender MimeMultipartFormData E'EnumFormStringArray where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumFormStringArray' enum fromE'EnumFormStringArray :: E'EnumFormStringArray -> Text -fromE'EnumFormStringArray = - \case - E'EnumFormStringArray'GreaterThan -> ">" - E'EnumFormStringArray'Dollar -> "$" +fromE'EnumFormStringArray = \case + E'EnumFormStringArray'GreaterThan -> ">" + E'EnumFormStringArray'Dollar -> "$" -- | parse 'E'EnumFormStringArray' enum toE'EnumFormStringArray :: Text -> P.Either String E'EnumFormStringArray -toE'EnumFormStringArray = - \case - ">" -> P.Right E'EnumFormStringArray'GreaterThan - "$" -> P.Right E'EnumFormStringArray'Dollar - s -> P.Left $ "toE'EnumFormStringArray: enum parse failure: " P.++ P.show s +toE'EnumFormStringArray = \case + ">" -> P.Right E'EnumFormStringArray'GreaterThan + "$" -> P.Right E'EnumFormStringArray'Dollar + s -> P.Left $ "toE'EnumFormStringArray: enum parse failure: " P.++ P.show s + -- ** E'EnumInteger + -- | Enum of 'Int' data E'EnumInteger = E'EnumInteger'Num1 -- ^ @1@ | E'EnumInteger'NumMinus_1 -- ^ @-1@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumInteger where - toJSON = A.toJSON . fromE'EnumInteger - -instance A.FromJSON E'EnumInteger where - parseJSON o = - P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumInteger where - toQueryParam = WH.toQueryParam . fromE'EnumInteger - -instance WH.FromHttpApiData E'EnumInteger where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger - -instance MimeRender MimeMultipartFormData E'EnumInteger where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumInteger where toJSON = A.toJSON . fromE'EnumInteger +instance A.FromJSON E'EnumInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumInteger where toQueryParam = WH.toQueryParam . fromE'EnumInteger +instance WH.FromHttpApiData E'EnumInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumInteger +instance MimeRender MimeMultipartFormData E'EnumInteger where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumInteger' enum fromE'EnumInteger :: E'EnumInteger -> Int -fromE'EnumInteger = - \case - E'EnumInteger'Num1 -> 1 - E'EnumInteger'NumMinus_1 -> -1 +fromE'EnumInteger = \case + E'EnumInteger'Num1 -> 1 + E'EnumInteger'NumMinus_1 -> -1 -- | parse 'E'EnumInteger' enum toE'EnumInteger :: Int -> P.Either String E'EnumInteger -toE'EnumInteger = - \case - 1 -> P.Right E'EnumInteger'Num1 - -1 -> P.Right E'EnumInteger'NumMinus_1 - s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s +toE'EnumInteger = \case + 1 -> P.Right E'EnumInteger'Num1 + -1 -> P.Right E'EnumInteger'NumMinus_1 + s -> P.Left $ "toE'EnumInteger: enum parse failure: " P.++ P.show s + -- ** E'EnumNumber + -- | Enum of 'Double' data E'EnumNumber = E'EnumNumber'Num1_Dot_1 -- ^ @1.1@ | E'EnumNumber'NumMinus_1_Dot_2 -- ^ @-1.2@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumNumber where - toJSON = A.toJSON . fromE'EnumNumber - -instance A.FromJSON E'EnumNumber where - parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumNumber where - toQueryParam = WH.toQueryParam . fromE'EnumNumber - -instance WH.FromHttpApiData E'EnumNumber where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber - -instance MimeRender MimeMultipartFormData E'EnumNumber where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumNumber where toJSON = A.toJSON . fromE'EnumNumber +instance A.FromJSON E'EnumNumber where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumNumber =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumNumber where toQueryParam = WH.toQueryParam . fromE'EnumNumber +instance WH.FromHttpApiData E'EnumNumber where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumNumber +instance MimeRender MimeMultipartFormData E'EnumNumber where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumNumber' enum fromE'EnumNumber :: E'EnumNumber -> Double -fromE'EnumNumber = - \case - E'EnumNumber'Num1_Dot_1 -> 1.1 - E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 +fromE'EnumNumber = \case + E'EnumNumber'Num1_Dot_1 -> 1.1 + E'EnumNumber'NumMinus_1_Dot_2 -> -1.2 -- | parse 'E'EnumNumber' enum toE'EnumNumber :: Double -> P.Either String E'EnumNumber -toE'EnumNumber = - \case - 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 - -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 - s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s +toE'EnumNumber = \case + 1.1 -> P.Right E'EnumNumber'Num1_Dot_1 + -1.2 -> P.Right E'EnumNumber'NumMinus_1_Dot_2 + s -> P.Left $ "toE'EnumNumber: enum parse failure: " P.++ P.show s + -- ** E'EnumQueryInteger + -- | Enum of 'Int' data E'EnumQueryInteger = E'EnumQueryInteger'Num1 -- ^ @1@ | E'EnumQueryInteger'NumMinus_2 -- ^ @-2@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumQueryInteger where - toJSON = A.toJSON . fromE'EnumQueryInteger - -instance A.FromJSON E'EnumQueryInteger where - parseJSON o = - P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumQueryInteger where - toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger - -instance WH.FromHttpApiData E'EnumQueryInteger where - parseQueryParam o = - WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger - -instance MimeRender MimeMultipartFormData E'EnumQueryInteger where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumQueryInteger where toJSON = A.toJSON . fromE'EnumQueryInteger +instance A.FromJSON E'EnumQueryInteger where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumQueryInteger =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumQueryInteger where toQueryParam = WH.toQueryParam . fromE'EnumQueryInteger +instance WH.FromHttpApiData E'EnumQueryInteger where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumQueryInteger +instance MimeRender MimeMultipartFormData E'EnumQueryInteger where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumQueryInteger' enum fromE'EnumQueryInteger :: E'EnumQueryInteger -> Int -fromE'EnumQueryInteger = - \case - E'EnumQueryInteger'Num1 -> 1 - E'EnumQueryInteger'NumMinus_2 -> -2 +fromE'EnumQueryInteger = \case + E'EnumQueryInteger'Num1 -> 1 + E'EnumQueryInteger'NumMinus_2 -> -2 -- | parse 'E'EnumQueryInteger' enum toE'EnumQueryInteger :: Int -> P.Either String E'EnumQueryInteger -toE'EnumQueryInteger = - \case - 1 -> P.Right E'EnumQueryInteger'Num1 - -2 -> P.Right E'EnumQueryInteger'NumMinus_2 - s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s +toE'EnumQueryInteger = \case + 1 -> P.Right E'EnumQueryInteger'Num1 + -2 -> P.Right E'EnumQueryInteger'NumMinus_2 + s -> P.Left $ "toE'EnumQueryInteger: enum parse failure: " P.++ P.show s + -- ** E'EnumString + -- | Enum of 'Text' data E'EnumString = E'EnumString'UPPER -- ^ @"UPPER"@ @@ -1525,113 +1614,86 @@ data E'EnumString | E'EnumString'Empty -- ^ @""@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'EnumString where - toJSON = A.toJSON . fromE'EnumString - -instance A.FromJSON E'EnumString where - parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o - -instance WH.ToHttpApiData E'EnumString where - toQueryParam = WH.toQueryParam . fromE'EnumString - -instance WH.FromHttpApiData E'EnumString where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString - -instance MimeRender MimeMultipartFormData E'EnumString where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'EnumString where toJSON = A.toJSON . fromE'EnumString +instance A.FromJSON E'EnumString where parseJSON o = P.either P.fail (pure . P.id) . toE'EnumString =<< A.parseJSON o +instance WH.ToHttpApiData E'EnumString where toQueryParam = WH.toQueryParam . fromE'EnumString +instance WH.FromHttpApiData E'EnumString where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'EnumString +instance MimeRender MimeMultipartFormData E'EnumString where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'EnumString' enum fromE'EnumString :: E'EnumString -> Text -fromE'EnumString = - \case - E'EnumString'UPPER -> "UPPER" - E'EnumString'Lower -> "lower" - E'EnumString'Empty -> "" +fromE'EnumString = \case + E'EnumString'UPPER -> "UPPER" + E'EnumString'Lower -> "lower" + E'EnumString'Empty -> "" -- | parse 'E'EnumString' enum toE'EnumString :: Text -> P.Either String E'EnumString -toE'EnumString = - \case - "UPPER" -> P.Right E'EnumString'UPPER - "lower" -> P.Right E'EnumString'Lower - "" -> P.Right E'EnumString'Empty - s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s +toE'EnumString = \case + "UPPER" -> P.Right E'EnumString'UPPER + "lower" -> P.Right E'EnumString'Lower + "" -> P.Right E'EnumString'Empty + s -> P.Left $ "toE'EnumString: enum parse failure: " P.++ P.show s + -- ** E'Inner + -- | Enum of 'Text' data E'Inner = E'Inner'UPPER -- ^ @"UPPER"@ | E'Inner'Lower -- ^ @"lower"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Inner where - toJSON = A.toJSON . fromE'Inner - -instance A.FromJSON E'Inner where - parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o - -instance WH.ToHttpApiData E'Inner where - toQueryParam = WH.toQueryParam . fromE'Inner - -instance WH.FromHttpApiData E'Inner where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner - -instance MimeRender MimeMultipartFormData E'Inner where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Inner where toJSON = A.toJSON . fromE'Inner +instance A.FromJSON E'Inner where parseJSON o = P.either P.fail (pure . P.id) . toE'Inner =<< A.parseJSON o +instance WH.ToHttpApiData E'Inner where toQueryParam = WH.toQueryParam . fromE'Inner +instance WH.FromHttpApiData E'Inner where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Inner +instance MimeRender MimeMultipartFormData E'Inner where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Inner' enum fromE'Inner :: E'Inner -> Text -fromE'Inner = - \case - E'Inner'UPPER -> "UPPER" - E'Inner'Lower -> "lower" +fromE'Inner = \case + E'Inner'UPPER -> "UPPER" + E'Inner'Lower -> "lower" -- | parse 'E'Inner' enum toE'Inner :: Text -> P.Either String E'Inner -toE'Inner = - \case - "UPPER" -> P.Right E'Inner'UPPER - "lower" -> P.Right E'Inner'Lower - s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s +toE'Inner = \case + "UPPER" -> P.Right E'Inner'UPPER + "lower" -> P.Right E'Inner'Lower + s -> P.Left $ "toE'Inner: enum parse failure: " P.++ P.show s + -- ** E'JustSymbol + -- | Enum of 'Text' data E'JustSymbol = E'JustSymbol'Greater_Than_Or_Equal_To -- ^ @">="@ | E'JustSymbol'Dollar -- ^ @"$"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'JustSymbol where - toJSON = A.toJSON . fromE'JustSymbol - -instance A.FromJSON E'JustSymbol where - parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o - -instance WH.ToHttpApiData E'JustSymbol where - toQueryParam = WH.toQueryParam . fromE'JustSymbol - -instance WH.FromHttpApiData E'JustSymbol where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol - -instance MimeRender MimeMultipartFormData E'JustSymbol where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'JustSymbol where toJSON = A.toJSON . fromE'JustSymbol +instance A.FromJSON E'JustSymbol where parseJSON o = P.either P.fail (pure . P.id) . toE'JustSymbol =<< A.parseJSON o +instance WH.ToHttpApiData E'JustSymbol where toQueryParam = WH.toQueryParam . fromE'JustSymbol +instance WH.FromHttpApiData E'JustSymbol where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'JustSymbol +instance MimeRender MimeMultipartFormData E'JustSymbol where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'JustSymbol' enum fromE'JustSymbol :: E'JustSymbol -> Text -fromE'JustSymbol = - \case - E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" - E'JustSymbol'Dollar -> "$" +fromE'JustSymbol = \case + E'JustSymbol'Greater_Than_Or_Equal_To -> ">=" + E'JustSymbol'Dollar -> "$" -- | parse 'E'JustSymbol' enum toE'JustSymbol :: Text -> P.Either String E'JustSymbol -toE'JustSymbol = - \case - ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To - "$" -> P.Right E'JustSymbol'Dollar - s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s +toE'JustSymbol = \case + ">=" -> P.Right E'JustSymbol'Greater_Than_Or_Equal_To + "$" -> P.Right E'JustSymbol'Dollar + s -> P.Left $ "toE'JustSymbol: enum parse failure: " P.++ P.show s + -- ** E'Status + -- | Enum of 'Text' . -- Order Status data E'Status @@ -1640,39 +1702,30 @@ data E'Status | E'Status'Delivered -- ^ @"delivered"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Status where - toJSON = A.toJSON . fromE'Status - -instance A.FromJSON E'Status where - parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o - -instance WH.ToHttpApiData E'Status where - toQueryParam = WH.toQueryParam . fromE'Status - -instance WH.FromHttpApiData E'Status where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status - -instance MimeRender MimeMultipartFormData E'Status where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Status where toJSON = A.toJSON . fromE'Status +instance A.FromJSON E'Status where parseJSON o = P.either P.fail (pure . P.id) . toE'Status =<< A.parseJSON o +instance WH.ToHttpApiData E'Status where toQueryParam = WH.toQueryParam . fromE'Status +instance WH.FromHttpApiData E'Status where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status +instance MimeRender MimeMultipartFormData E'Status where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Status' enum fromE'Status :: E'Status -> Text -fromE'Status = - \case - E'Status'Placed -> "placed" - E'Status'Approved -> "approved" - E'Status'Delivered -> "delivered" +fromE'Status = \case + E'Status'Placed -> "placed" + E'Status'Approved -> "approved" + E'Status'Delivered -> "delivered" -- | parse 'E'Status' enum toE'Status :: Text -> P.Either String E'Status -toE'Status = - \case - "placed" -> P.Right E'Status'Placed - "approved" -> P.Right E'Status'Approved - "delivered" -> P.Right E'Status'Delivered - s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s +toE'Status = \case + "placed" -> P.Right E'Status'Placed + "approved" -> P.Right E'Status'Approved + "delivered" -> P.Right E'Status'Delivered + s -> P.Left $ "toE'Status: enum parse failure: " P.++ P.show s + -- ** E'Status2 + -- | Enum of 'Text' . -- pet status in the store data E'Status2 @@ -1681,39 +1734,30 @@ data E'Status2 | E'Status2'Sold -- ^ @"sold"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON E'Status2 where - toJSON = A.toJSON . fromE'Status2 - -instance A.FromJSON E'Status2 where - parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o - -instance WH.ToHttpApiData E'Status2 where - toQueryParam = WH.toQueryParam . fromE'Status2 - -instance WH.FromHttpApiData E'Status2 where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 - -instance MimeRender MimeMultipartFormData E'Status2 where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON E'Status2 where toJSON = A.toJSON . fromE'Status2 +instance A.FromJSON E'Status2 where parseJSON o = P.either P.fail (pure . P.id) . toE'Status2 =<< A.parseJSON o +instance WH.ToHttpApiData E'Status2 where toQueryParam = WH.toQueryParam . fromE'Status2 +instance WH.FromHttpApiData E'Status2 where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toE'Status2 +instance MimeRender MimeMultipartFormData E'Status2 where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'E'Status2' enum fromE'Status2 :: E'Status2 -> Text -fromE'Status2 = - \case - E'Status2'Available -> "available" - E'Status2'Pending -> "pending" - E'Status2'Sold -> "sold" +fromE'Status2 = \case + E'Status2'Available -> "available" + E'Status2'Pending -> "pending" + E'Status2'Sold -> "sold" -- | parse 'E'Status2' enum toE'Status2 :: Text -> P.Either String E'Status2 -toE'Status2 = - \case - "available" -> P.Right E'Status2'Available - "pending" -> P.Right E'Status2'Pending - "sold" -> P.Right E'Status2'Sold - s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s +toE'Status2 = \case + "available" -> P.Right E'Status2'Available + "pending" -> P.Right E'Status2'Pending + "sold" -> P.Right E'Status2'Sold + s -> P.Left $ "toE'Status2: enum parse failure: " P.++ P.show s + -- ** EnumClass + -- | Enum of 'Text' data EnumClass = EnumClass'_abc -- ^ @"_abc"@ @@ -1721,39 +1765,30 @@ data EnumClass | EnumClass'_xyz -- ^ @"(xyz)"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON EnumClass where - toJSON = A.toJSON . fromEnumClass - -instance A.FromJSON EnumClass where - parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o - -instance WH.ToHttpApiData EnumClass where - toQueryParam = WH.toQueryParam . fromEnumClass - -instance WH.FromHttpApiData EnumClass where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass - -instance MimeRender MimeMultipartFormData EnumClass where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON EnumClass where toJSON = A.toJSON . fromEnumClass +instance A.FromJSON EnumClass where parseJSON o = P.either P.fail (pure . P.id) . toEnumClass =<< A.parseJSON o +instance WH.ToHttpApiData EnumClass where toQueryParam = WH.toQueryParam . fromEnumClass +instance WH.FromHttpApiData EnumClass where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toEnumClass +instance MimeRender MimeMultipartFormData EnumClass where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'EnumClass' enum fromEnumClass :: EnumClass -> Text -fromEnumClass = - \case - EnumClass'_abc -> "_abc" - EnumClass'_efg -> "-efg" - EnumClass'_xyz -> "(xyz)" +fromEnumClass = \case + EnumClass'_abc -> "_abc" + EnumClass'_efg -> "-efg" + EnumClass'_xyz -> "(xyz)" -- | parse 'EnumClass' enum toEnumClass :: Text -> P.Either String EnumClass -toEnumClass = - \case - "_abc" -> P.Right EnumClass'_abc - "-efg" -> P.Right EnumClass'_efg - "(xyz)" -> P.Right EnumClass'_xyz - s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s +toEnumClass = \case + "_abc" -> P.Right EnumClass'_abc + "-efg" -> P.Right EnumClass'_efg + "(xyz)" -> P.Right EnumClass'_xyz + s -> P.Left $ "toEnumClass: enum parse failure: " P.++ P.show s + -- ** OuterEnum + -- | Enum of 'Text' data OuterEnum = OuterEnum'Placed -- ^ @"placed"@ @@ -1761,39 +1796,30 @@ data OuterEnum | OuterEnum'Delivered -- ^ @"delivered"@ deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum) -instance A.ToJSON OuterEnum where - toJSON = A.toJSON . fromOuterEnum - -instance A.FromJSON OuterEnum where - parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o - -instance WH.ToHttpApiData OuterEnum where - toQueryParam = WH.toQueryParam . fromOuterEnum - -instance WH.FromHttpApiData OuterEnum where - parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum - -instance MimeRender MimeMultipartFormData OuterEnum where - mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON OuterEnum where toJSON = A.toJSON . fromOuterEnum +instance A.FromJSON OuterEnum where parseJSON o = P.either P.fail (pure . P.id) . toOuterEnum =<< A.parseJSON o +instance WH.ToHttpApiData OuterEnum where toQueryParam = WH.toQueryParam . fromOuterEnum +instance WH.FromHttpApiData OuterEnum where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . toOuterEnum +instance MimeRender MimeMultipartFormData OuterEnum where mimeRender _ = mimeRenderDefaultMultipartFormData -- | unwrap 'OuterEnum' enum fromOuterEnum :: OuterEnum -> Text -fromOuterEnum = - \case - OuterEnum'Placed -> "placed" - OuterEnum'Approved -> "approved" - OuterEnum'Delivered -> "delivered" +fromOuterEnum = \case + OuterEnum'Placed -> "placed" + OuterEnum'Approved -> "approved" + OuterEnum'Delivered -> "delivered" -- | parse 'OuterEnum' enum toOuterEnum :: Text -> P.Either String OuterEnum -toOuterEnum = - \case - "placed" -> P.Right OuterEnum'Placed - "approved" -> P.Right OuterEnum'Approved - "delivered" -> P.Right OuterEnum'Delivered - s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s +toOuterEnum = \case + "placed" -> P.Right OuterEnum'Placed + "approved" -> P.Right OuterEnum'Approved + "delivered" -> P.Right OuterEnum'Delivered + s -> P.Left $ "toOuterEnum: enum parse failure: " P.++ P.show s + -- * Auth Methods + -- ** AuthApiKeyApiKey data AuthApiKeyApiKey = AuthApiKeyApiKey Text -- ^ secret @@ -1803,8 +1829,8 @@ instance AuthMethod AuthApiKeyApiKey where applyAuthMethod _ a@(AuthApiKeyApiKey secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("api_key", secret) & - L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("api_key", secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req -- ** AuthApiKeyApiKeyQuery @@ -1816,25 +1842,23 @@ instance AuthMethod AuthApiKeyApiKeyQuery where applyAuthMethod _ a@(AuthApiKeyApiKeyQuery secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setQuery` toQuery ("api_key_query", Just secret) & - L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setQuery` toQuery ("api_key_query", Just secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req -- ** AuthBasicHttpBasicTest data AuthBasicHttpBasicTest = - AuthBasicHttpBasicTest B.ByteString - B.ByteString -- ^ username password + AuthBasicHttpBasicTest B.ByteString B.ByteString -- ^ username password deriving (P.Eq, P.Show, P.Typeable) instance AuthMethod AuthBasicHttpBasicTest where applyAuthMethod _ a@(AuthBasicHttpBasicTest user pw) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) & - L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("Authorization", T.decodeUtf8 cred) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req - where - cred = BC.append "Basic " (B64.encode $ BC.concat [user, ":", pw]) + where cred = BC.append "Basic " (B64.encode $ BC.concat [ user, ":", pw ]) -- ** AuthOAuthPetstoreAuth data AuthOAuthPetstoreAuth = @@ -1845,6 +1869,7 @@ instance AuthMethod AuthOAuthPetstoreAuth where applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) & - L.over rAuthTypesL (P.filter (/= P.typeOf a)) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) + & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req + diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index 8ce41ab1362..49e04148108 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -7,15 +7,16 @@ 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 #-} +{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.ModelLens where @@ -38,677 +39,632 @@ import qualified Prelude as P import OpenAPIPetstore.Core import OpenAPIPetstore.Model + -- * AdditionalPropertiesClass --- | 'additionalPropertiesClassMapProperty' Lens -additionalPropertiesClassMapPropertyL :: - Lens_' AdditionalPropertiesClass (Maybe (Map.Map String Text)) -additionalPropertiesClassMapPropertyL f AdditionalPropertiesClass {..} = - (\additionalPropertiesClassMapProperty -> - AdditionalPropertiesClass {additionalPropertiesClassMapProperty, ..}) <$> - f additionalPropertiesClassMapProperty +-- | '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 +-- | '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 - +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 - +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 - +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 - +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 - +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 +-- | '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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +enumTestOuterEnumL f EnumTest{..} = (\enumTestOuterEnum -> EnumTest { enumTestOuterEnum, ..} ) <$> f enumTestOuterEnum {-# INLINE enumTestOuterEnumL #-} + + + -- * File + -- | 'fileSourceUri' Lens fileSourceUriL :: Lens_' File (Maybe Text) -fileSourceUriL f File {..} = - (\fileSourceUri -> File {fileSourceUri, ..}) <$> f fileSourceUri - +fileSourceUriL f File{..} = (\fileSourceUri -> File { fileSourceUri, ..} ) <$> f fileSourceUri {-# INLINE fileSourceUriL #-} + + + -- * FileSchemaTestClass + -- | 'fileSchemaTestClassFile' Lens fileSchemaTestClassFileL :: Lens_' FileSchemaTestClass (Maybe File) -fileSchemaTestClassFileL f FileSchemaTestClass {..} = - (\fileSchemaTestClassFile -> FileSchemaTestClass {fileSchemaTestClassFile, ..}) <$> - f fileSchemaTestClassFile - +fileSchemaTestClassFileL f FileSchemaTestClass{..} = (\fileSchemaTestClassFile -> FileSchemaTestClass { fileSchemaTestClassFile, ..} ) <$> f fileSchemaTestClassFile {-# INLINE fileSchemaTestClassFileL #-} + -- | 'fileSchemaTestClassFiles' Lens fileSchemaTestClassFilesL :: Lens_' FileSchemaTestClass (Maybe [File]) -fileSchemaTestClassFilesL f FileSchemaTestClass {..} = - (\fileSchemaTestClassFiles -> - FileSchemaTestClass {fileSchemaTestClassFiles, ..}) <$> - f fileSchemaTestClassFiles - +fileSchemaTestClassFilesL f FileSchemaTestClass{..} = (\fileSchemaTestClassFiles -> FileSchemaTestClass { fileSchemaTestClassFiles, ..} ) <$> f fileSchemaTestClassFiles {-# INLINE fileSchemaTestClassFilesL #-} + + + -- * FormatTest + -- | 'formatTestInteger' Lens formatTestIntegerL :: Lens_' FormatTest (Maybe Int) -formatTestIntegerL f FormatTest {..} = - (\formatTestInteger -> FormatTest {formatTestInteger, ..}) <$> - f formatTestInteger - +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 - +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 - +formatTestInt64L f FormatTest{..} = (\formatTestInt64 -> FormatTest { formatTestInt64, ..} ) <$> f formatTestInt64 {-# INLINE formatTestInt64L #-} + -- | 'formatTestNumber' Lens formatTestNumberL :: Lens_' FormatTest (Double) -formatTestNumberL f FormatTest {..} = - (\formatTestNumber -> FormatTest {formatTestNumber, ..}) <$> - f formatTestNumber - +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 - +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 - +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 - +formatTestStringL f FormatTest{..} = (\formatTestString -> FormatTest { formatTestString, ..} ) <$> f formatTestString {-# INLINE formatTestStringL #-} + -- | 'formatTestByte' Lens formatTestByteL :: Lens_' FormatTest (ByteArray) -formatTestByteL f FormatTest {..} = - (\formatTestByte -> FormatTest {formatTestByte, ..}) <$> f formatTestByte - +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 - +formatTestBinaryL f FormatTest{..} = (\formatTestBinary -> FormatTest { formatTestBinary, ..} ) <$> f formatTestBinary {-# INLINE formatTestBinaryL #-} + -- | 'formatTestDate' Lens formatTestDateL :: Lens_' FormatTest (Date) -formatTestDateL f FormatTest {..} = - (\formatTestDate -> FormatTest {formatTestDate, ..}) <$> f formatTestDate - +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 - +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 - +formatTestUuidL f FormatTest{..} = (\formatTestUuid -> FormatTest { formatTestUuid, ..} ) <$> f formatTestUuid {-# INLINE formatTestUuidL #-} + -- | 'formatTestPassword' Lens formatTestPasswordL :: Lens_' FormatTest (Text) -formatTestPasswordL f FormatTest {..} = - (\formatTestPassword -> FormatTest {formatTestPassword, ..}) <$> - f formatTestPassword - +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 - +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 - +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 +-- | '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 - +mapTestMapOfEnumStringL f MapTest{..} = (\mapTestMapOfEnumString -> MapTest { mapTestMapOfEnumString, ..} ) <$> f mapTestMapOfEnumString {-# INLINE mapTestMapOfEnumStringL #-} + -- | 'mapTestDirectMap' Lens mapTestDirectMapL :: Lens_' MapTest (Maybe (Map.Map String Bool)) -mapTestDirectMapL f MapTest {..} = - (\mapTestDirectMap -> MapTest {mapTestDirectMap, ..}) <$> f mapTestDirectMap - +mapTestDirectMapL f MapTest{..} = (\mapTestDirectMap -> MapTest { mapTestDirectMap, ..} ) <$> f mapTestDirectMap {-# INLINE mapTestDirectMapL #-} + -- | 'mapTestIndirectMap' Lens mapTestIndirectMapL :: Lens_' MapTest (Maybe StringBooleanMap) -mapTestIndirectMapL f MapTest {..} = - (\mapTestIndirectMap -> MapTest {mapTestIndirectMap, ..}) <$> - f mapTestIndirectMap - +mapTestIndirectMapL f MapTest{..} = (\mapTestIndirectMap -> MapTest { mapTestIndirectMap, ..} ) <$> f mapTestIndirectMap {-# INLINE mapTestIndirectMapL #-} + + + -- * MixedPropertiesAndAdditionalPropertiesClass --- | 'mixedPropertiesAndAdditionalPropertiesClassUuid' Lens -mixedPropertiesAndAdditionalPropertiesClassUuidL :: - Lens_' MixedPropertiesAndAdditionalPropertiesClass (Maybe Text) -mixedPropertiesAndAdditionalPropertiesClassUuidL f MixedPropertiesAndAdditionalPropertiesClass {..} = - (\mixedPropertiesAndAdditionalPropertiesClassUuid -> - MixedPropertiesAndAdditionalPropertiesClass - {mixedPropertiesAndAdditionalPropertiesClassUuid, ..}) <$> - f mixedPropertiesAndAdditionalPropertiesClassUuid +-- | '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 +-- | '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 +-- | '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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +petCategoryL f Pet{..} = (\petCategory -> Pet { petCategory, ..} ) <$> f petCategory {-# INLINE petCategoryL #-} + -- | 'petName' Lens petNameL :: Lens_' Pet (Text) -petNameL f Pet {..} = (\petName -> Pet {petName, ..}) <$> f petName - +petNameL f Pet{..} = (\petName -> Pet { petName, ..} ) <$> f petName {-# INLINE petNameL #-} + -- | 'petPhotoUrls' Lens petPhotoUrlsL :: Lens_' Pet ([Text]) -petPhotoUrlsL f Pet {..} = - (\petPhotoUrls -> Pet {petPhotoUrls, ..}) <$> f petPhotoUrls - +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 - +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 - +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 - +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 - +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 - +specialModelNameSpecialPropertyNameL f SpecialModelName{..} = (\specialModelNameSpecialPropertyName -> SpecialModelName { specialModelNameSpecialPropertyName, ..} ) <$> f specialModelNameSpecialPropertyName {-# INLINE specialModelNameSpecialPropertyNameL #-} + + + -- * StringBooleanMap + + + -- * Tag + -- | 'tagId' Lens tagIdL :: Lens_' Tag (Maybe Integer) -tagIdL f Tag {..} = (\tagId -> Tag {tagId, ..}) <$> f tagId - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +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 - +userUserStatusL f User{..} = (\userUserStatus -> User { userUserStatus, ..} ) <$> f userUserStatus {-# INLINE userUserStatusL #-} + + diff --git a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs index 88ca2110a06..a217b69021b 100644 --- a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs +++ b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs @@ -1,15 +1,15 @@ {-# LANGUAGE DefaultSignatures #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module ApproxEq where -import Data.Text (Text) -import Data.Time.Clock -import Test.QuickCheck -import GHC.Generics as G +import Data.Text (Text) +import Data.Time.Clock +import GHC.Generics as G +import Test.QuickCheck (==~) :: (ApproxEq a, Show a) @@ -26,7 +26,7 @@ instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where gApproxEq (L1 a) (L1 b) = gApproxEq a b gApproxEq (R1 a) (R1 b) = gApproxEq a b - gApproxEq _ _ = False + gApproxEq _ _ = False instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index d00ec59c2bf..e4009849fc4 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -32,24 +32,24 @@ instance Arbitrary TI.UTCTime where TI.UTCTime <$> arbitrary <*> (TI.secondsToDiffTime <$> choose (0, 86401)) instance Arbitrary BL.ByteString where - arbitrary = BL.pack <$> arbitrary - shrink xs = BL.pack <$> shrink (BL.unpack xs) + arbitrary = BL.pack <$> arbitrary + shrink xs = BL.pack <$> shrink (BL.unpack xs) instance Arbitrary ByteArray where - arbitrary = ByteArray <$> arbitrary - shrink (ByteArray xs) = ByteArray <$> shrink xs + arbitrary = ByteArray <$> arbitrary + shrink (ByteArray xs) = ByteArray <$> shrink xs instance Arbitrary Binary where - arbitrary = Binary <$> arbitrary - shrink (Binary xs) = Binary <$> shrink xs + arbitrary = Binary <$> arbitrary + shrink (Binary xs) = Binary <$> shrink xs instance Arbitrary DateTime where - arbitrary = DateTime <$> arbitrary - shrink (DateTime xs) = DateTime <$> shrink xs + arbitrary = DateTime <$> arbitrary + shrink (DateTime xs) = DateTime <$> shrink xs instance Arbitrary Date where - arbitrary = Date <$> arbitrary - shrink (Date xs) = Date <$> shrink xs + arbitrary = Date <$> arbitrary + shrink (Date xs) = Date <$> shrink xs -- | A naive Arbitrary instance for A.Value: instance Arbitrary A.Value where @@ -73,7 +73,9 @@ instance Arbitrary A.Value where replicateM n $ (,) <$> (arbitrary :: Gen String) <*> simpleAndArrays -- | Checks if a given list has no duplicates in _O(n log n)_. -hasNoDups :: (Ord a) => [a] -> Bool +hasNoDups + :: (Ord a) + => [a] -> Bool hasNoDups = go Set.empty where go _ [] = True @@ -86,269 +88,244 @@ instance ApproxEq TI.Day where (=~) = (==) -- * Models + instance Arbitrary AdditionalPropertiesClass where arbitrary = - AdditionalPropertiesClass <$> - arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) - <*> - arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) + AdditionalPropertiesClass + <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) + <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) instance Arbitrary Animal where arbitrary = - Animal <$> arbitrary -- animalClassName :: Text - <*> - arbitrary -- animalColor :: Maybe Text + Animal + <$> arbitrary -- animalClassName :: Text + <*> arbitrary -- animalColor :: Maybe Text instance Arbitrary AnimalFarm where - arbitrary = pure AnimalFarm + arbitrary = + + pure AnimalFarm instance Arbitrary ApiResponse where arbitrary = - ApiResponse <$> arbitrary -- apiResponseCode :: Maybe Int - <*> - arbitrary -- apiResponseType :: Maybe Text - <*> - arbitrary -- apiResponseMessage :: Maybe Text + ApiResponse + <$> arbitrary -- apiResponseCode :: Maybe Int + <*> arbitrary -- apiResponseType :: Maybe Text + <*> arbitrary -- apiResponseMessage :: Maybe Text instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = - ArrayOfArrayOfNumberOnly <$> - arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] + ArrayOfArrayOfNumberOnly + <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] instance Arbitrary ArrayOfNumberOnly where arbitrary = - ArrayOfNumberOnly <$> - arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] + ArrayOfNumberOnly + <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] instance Arbitrary ArrayTest where arbitrary = - ArrayTest <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] - <*> - arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] - <*> - arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] + ArrayTest + <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] + <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] + <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] instance Arbitrary Capitalization where arbitrary = - Capitalization <$> arbitrary -- capitalizationSmallCamel :: Maybe Text - <*> - arbitrary -- capitalizationCapitalCamel :: Maybe Text - <*> - arbitrary -- capitalizationSmallSnake :: Maybe Text - <*> - arbitrary -- capitalizationCapitalSnake :: Maybe Text - <*> - arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text - <*> - arbitrary -- capitalizationAttName :: Maybe Text + Capitalization + <$> arbitrary -- capitalizationSmallCamel :: Maybe Text + <*> arbitrary -- capitalizationCapitalCamel :: Maybe Text + <*> arbitrary -- capitalizationSmallSnake :: Maybe Text + <*> arbitrary -- capitalizationCapitalSnake :: Maybe Text + <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text + <*> arbitrary -- capitalizationAttName :: Maybe Text instance Arbitrary Cat where arbitrary = - Cat <$> arbitrary -- catClassName :: Text - <*> - arbitrary -- catColor :: Maybe Text - <*> - arbitrary -- catDeclawed :: Maybe Bool + Cat + <$> arbitrary -- catClassName :: Text + <*> arbitrary -- catColor :: Maybe Text + <*> arbitrary -- catDeclawed :: Maybe Bool instance Arbitrary Category where arbitrary = - Category <$> arbitrary -- categoryId :: Maybe Integer - <*> - arbitrary -- categoryName :: Maybe Text + Category + <$> arbitrary -- categoryId :: Maybe Integer + <*> arbitrary -- categoryName :: Maybe Text instance Arbitrary ClassModel where - arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text + arbitrary = + ClassModel + <$> arbitrary -- classModelClass :: Maybe Text instance Arbitrary Client where - arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text + arbitrary = + Client + <$> arbitrary -- clientClient :: Maybe Text instance Arbitrary Dog where arbitrary = - Dog <$> arbitrary -- dogClassName :: Text - <*> - arbitrary -- dogColor :: Maybe Text - <*> - arbitrary -- dogBreed :: Maybe Text + Dog + <$> arbitrary -- dogClassName :: Text + <*> arbitrary -- dogColor :: Maybe Text + <*> arbitrary -- dogBreed :: Maybe Text instance Arbitrary EnumArrays where arbitrary = - EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text - <*> - arbitrary -- enumArraysArrayEnum :: Maybe [Text] + EnumArrays + <$> arbitrary -- enumArraysJustSymbol :: Maybe Text + <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] instance Arbitrary EnumTest where arbitrary = - EnumTest <$> arbitrary -- enumTestEnumString :: Maybe Text - <*> - arbitrary -- enumTestEnumStringRequired :: Text - <*> - arbitrary -- enumTestEnumInteger :: Maybe Int - <*> - arbitrary -- enumTestEnumNumber :: Maybe Double - <*> - arbitrary -- enumTestOuterEnum :: Maybe OuterEnum + EnumTest + <$> arbitrary -- enumTestEnumString :: Maybe Text + <*> arbitrary -- enumTestEnumStringRequired :: Text + <*> arbitrary -- enumTestEnumInteger :: Maybe Int + <*> arbitrary -- enumTestEnumNumber :: Maybe Double + <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum instance Arbitrary File where - arbitrary = File <$> arbitrary -- fileSourceUri :: Maybe Text + arbitrary = + File + <$> arbitrary -- fileSourceUri :: Maybe Text instance Arbitrary FileSchemaTestClass where arbitrary = - FileSchemaTestClass <$> arbitrary -- fileSchemaTestClassFile :: Maybe File - <*> - arbitrary -- fileSchemaTestClassFiles :: Maybe [File] + FileSchemaTestClass + <$> arbitrary -- fileSchemaTestClassFile :: Maybe File + <*> arbitrary -- fileSchemaTestClassFiles :: Maybe [File] instance Arbitrary FormatTest where arbitrary = - FormatTest <$> arbitrary -- formatTestInteger :: Maybe Int - <*> - arbitrary -- formatTestInt32 :: Maybe Int - <*> - arbitrary -- formatTestInt64 :: Maybe Integer - <*> - arbitrary -- formatTestNumber :: Double - <*> - arbitrary -- formatTestFloat :: Maybe Float - <*> - arbitrary -- formatTestDouble :: Maybe Double - <*> - arbitrary -- formatTestString :: Maybe Text - <*> - arbitrary -- formatTestByte :: ByteArray - <*> - arbitrary -- formatTestBinary :: Maybe FilePath - <*> - arbitrary -- formatTestDate :: Date - <*> - arbitrary -- formatTestDateTime :: Maybe DateTime - <*> - arbitrary -- formatTestUuid :: Maybe Text - <*> - arbitrary -- formatTestPassword :: Text + FormatTest + <$> arbitrary -- formatTestInteger :: Maybe Int + <*> arbitrary -- formatTestInt32 :: Maybe Int + <*> arbitrary -- formatTestInt64 :: Maybe Integer + <*> arbitrary -- formatTestNumber :: Double + <*> arbitrary -- formatTestFloat :: Maybe Float + <*> arbitrary -- formatTestDouble :: Maybe Double + <*> arbitrary -- formatTestString :: Maybe Text + <*> arbitrary -- formatTestByte :: ByteArray + <*> arbitrary -- formatTestBinary :: Maybe FilePath + <*> arbitrary -- formatTestDate :: Date + <*> arbitrary -- formatTestDateTime :: Maybe DateTime + <*> arbitrary -- formatTestUuid :: Maybe Text + <*> arbitrary -- formatTestPassword :: Text instance Arbitrary HasOnlyReadOnly where arbitrary = - HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text - <*> - arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text + HasOnlyReadOnly + <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text + <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text instance Arbitrary MapTest where arbitrary = - MapTest <$> - arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text)) - <*> - arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) - <*> - arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) - <*> - arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap + MapTest + <$> arbitrary -- mapTestMapMapOfString :: Maybe (Map.Map String (Map.Map String Text)) + <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) + <*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) + <*> arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = - MixedPropertiesAndAdditionalPropertiesClass <$> - arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text - <*> - arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime - <*> - arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) + MixedPropertiesAndAdditionalPropertiesClass + <$> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text + <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime + <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) instance Arbitrary Model200Response where arbitrary = - Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int - <*> - arbitrary -- model200ResponseClass :: Maybe Text + Model200Response + <$> arbitrary -- model200ResponseName :: Maybe Int + <*> arbitrary -- model200ResponseClass :: Maybe Text instance Arbitrary ModelList where - arbitrary = ModelList <$> arbitrary -- modelList123list :: Maybe Text + arbitrary = + ModelList + <$> arbitrary -- modelList123list :: Maybe Text instance Arbitrary ModelReturn where - arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int + arbitrary = + ModelReturn + <$> arbitrary -- modelReturnReturn :: Maybe Int instance Arbitrary Name where arbitrary = - Name <$> arbitrary -- nameName :: Int - <*> - arbitrary -- nameSnakeCase :: Maybe Int - <*> - arbitrary -- nameProperty :: Maybe Text - <*> - arbitrary -- name123number :: Maybe Int + Name + <$> arbitrary -- nameName :: Int + <*> arbitrary -- nameSnakeCase :: Maybe Int + <*> arbitrary -- nameProperty :: Maybe Text + <*> arbitrary -- name123number :: Maybe Int instance Arbitrary NumberOnly where - arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double + arbitrary = + NumberOnly + <$> arbitrary -- numberOnlyJustNumber :: Maybe Double instance Arbitrary Order where arbitrary = - Order <$> arbitrary -- orderId :: Maybe Integer - <*> - arbitrary -- orderPetId :: Maybe Integer - <*> - arbitrary -- orderQuantity :: Maybe Int - <*> - arbitrary -- orderShipDate :: Maybe DateTime - <*> - arbitrary -- orderStatus :: Maybe Text - <*> - arbitrary -- orderComplete :: Maybe Bool + Order + <$> arbitrary -- orderId :: Maybe Integer + <*> arbitrary -- orderPetId :: Maybe Integer + <*> arbitrary -- orderQuantity :: Maybe Int + <*> arbitrary -- orderShipDate :: Maybe DateTime + <*> arbitrary -- orderStatus :: Maybe Text + <*> arbitrary -- orderComplete :: Maybe Bool instance Arbitrary OuterComposite where arbitrary = - OuterComposite <$> arbitrary -- outerCompositeMyNumber :: Maybe Double - <*> - arbitrary -- outerCompositeMyString :: Maybe Text - <*> - arbitrary -- outerCompositeMyBoolean :: Maybe Bool + OuterComposite + <$> arbitrary -- outerCompositeMyNumber :: Maybe Double + <*> arbitrary -- outerCompositeMyString :: Maybe Text + <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool instance Arbitrary Pet where arbitrary = - Pet <$> arbitrary -- petId :: Maybe Integer - <*> - arbitrary -- petCategory :: Maybe Category - <*> - arbitrary -- petName :: Text - <*> - arbitrary -- petPhotoUrls :: [Text] - <*> - arbitrary -- petTags :: Maybe [Tag] - <*> - arbitrary -- petStatus :: Maybe Text + Pet + <$> arbitrary -- petId :: Maybe Integer + <*> arbitrary -- petCategory :: Maybe Category + <*> arbitrary -- petName :: Text + <*> arbitrary -- petPhotoUrls :: [Text] + <*> arbitrary -- petTags :: Maybe [Tag] + <*> arbitrary -- petStatus :: Maybe Text instance Arbitrary ReadOnlyFirst where arbitrary = - ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text - <*> - arbitrary -- readOnlyFirstBaz :: Maybe Text + ReadOnlyFirst + <$> arbitrary -- readOnlyFirstBar :: Maybe Text + <*> arbitrary -- readOnlyFirstBaz :: Maybe Text instance Arbitrary SpecialModelName where arbitrary = - SpecialModelName <$> - arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer + SpecialModelName + <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer instance Arbitrary StringBooleanMap where - arbitrary = pure StringBooleanMap + arbitrary = + + pure StringBooleanMap instance Arbitrary Tag where arbitrary = - Tag <$> arbitrary -- tagId :: Maybe Integer - <*> - arbitrary -- tagName :: Maybe Text + Tag + <$> arbitrary -- tagId :: Maybe Integer + <*> arbitrary -- tagName :: Maybe Text instance Arbitrary User where arbitrary = - User <$> arbitrary -- userId :: Maybe Integer - <*> - arbitrary -- userUsername :: Maybe Text - <*> - arbitrary -- userFirstName :: Maybe Text - <*> - arbitrary -- userLastName :: Maybe Text - <*> - arbitrary -- userEmail :: Maybe Text - <*> - arbitrary -- userPassword :: Maybe Text - <*> - arbitrary -- userPhone :: Maybe Text - <*> - arbitrary -- userUserStatus :: Maybe Int + User + <$> arbitrary -- userId :: Maybe Integer + <*> arbitrary -- userUsername :: Maybe Text + <*> arbitrary -- userFirstName :: Maybe Text + <*> arbitrary -- userLastName :: Maybe Text + <*> arbitrary -- userEmail :: Maybe Text + <*> arbitrary -- userPassword :: Maybe Text + <*> arbitrary -- userPhone :: Maybe Text + <*> arbitrary -- userUserStatus :: Maybe Int + + + instance Arbitrary E'ArrayEnum where arbitrary = arbitraryBoundedEnum diff --git a/samples/client/petstore/haskell-http-client/tests/PropMime.hs b/samples/client/petstore/haskell-http-client/tests/PropMime.hs index c5a78129777..2f64db78fe4 100644 --- a/samples/client/petstore/haskell-http-client/tests/PropMime.hs +++ b/samples/client/petstore/haskell-http-client/tests/PropMime.hs @@ -1,23 +1,23 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ConstraintKinds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module PropMime where -import Data.Aeson -import Data.Aeson.Types (parseEither) -import Data.Monoid ((<>)) -import Data.Typeable (Proxy(..), typeOf, Typeable) +import Data.Aeson +import Data.Aeson.Types (parseEither) import qualified Data.ByteString.Lazy.Char8 as BL8 -import Test.Hspec -import Test.QuickCheck -import Test.QuickCheck.Property -import Test.Hspec.QuickCheck (prop) +import Data.Monoid ((<>)) +import Data.Typeable (Proxy (..), Typeable, typeOf) +import Test.Hspec +import Test.Hspec.QuickCheck (prop) +import Test.QuickCheck +import Test.QuickCheck.Property -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes -import ApproxEq +import ApproxEq -- * Type Aliases diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index 99aa846de8f..926f7b9927b 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -17,8 +17,7 @@ import OpenAPIPetstore.Model main :: IO () main = - hspec $ - modifyMaxSize (const 5) $ do + hspec $ modifyMaxSize (const 5) $ do describe "JSON instances" $ do pure () propMimeEq MimeJSON (Proxy :: Proxy AdditionalPropertiesClass) @@ -42,9 +41,7 @@ main = propMimeEq MimeJSON (Proxy :: Proxy FormatTest) propMimeEq MimeJSON (Proxy :: Proxy HasOnlyReadOnly) propMimeEq MimeJSON (Proxy :: Proxy MapTest) - propMimeEq - MimeJSON - (Proxy :: Proxy MixedPropertiesAndAdditionalPropertiesClass) + propMimeEq MimeJSON (Proxy :: Proxy MixedPropertiesAndAdditionalPropertiesClass) propMimeEq MimeJSON (Proxy :: Proxy Model200Response) propMimeEq MimeJSON (Proxy :: Proxy ModelList) propMimeEq MimeJSON (Proxy :: Proxy ModelReturn) @@ -59,3 +56,4 @@ main = propMimeEq MimeJSON (Proxy :: Proxy StringBooleanMap) propMimeEq MimeJSON (Proxy :: Proxy Tag) propMimeEq MimeJSON (Proxy :: Proxy User) + -- GitLab From 3a1c5571afaeb268587434bc7f4fcc4372b19688 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Thu, 20 Sep 2018 15:26:56 +0800 Subject: [PATCH 06/10] rename env variable --- .../languages/HaskellHttpClientCodegen.java | 21 +- .../languages/HaskellServantCodegen.java | 21 +- .../petstore/haskell-http-client/Setup.hs | 2 +- .../lib/OpenAPIPetstore.hs | 14 +- .../lib/OpenAPIPetstore/API.hs | 12 +- .../lib/OpenAPIPetstore/API/AnotherFake.hs | 87 +++--- .../lib/OpenAPIPetstore/API/Fake.hs | 189 +++++++------ .../API/FakeClassnameTags123.hs | 89 +++---- .../lib/OpenAPIPetstore/API/Pet.hs | 175 ++++++------ .../lib/OpenAPIPetstore/API/Store.hs | 117 ++++---- .../lib/OpenAPIPetstore/API/User.hs | 153 +++++------ .../lib/OpenAPIPetstore/Client.hs | 72 ++--- .../lib/OpenAPIPetstore/Core.hs | 172 ++++++------ .../lib/OpenAPIPetstore/Logging.hs | 20 +- .../lib/OpenAPIPetstore/MimeTypes.hs | 53 ++-- .../lib/OpenAPIPetstore/Model.hs | 250 +++++++++--------- .../lib/OpenAPIPetstore/ModelLens.hs | 32 +-- .../haskell-http-client/tests/ApproxEq.hs | 14 +- .../haskell-http-client/tests/Instances.hs | 104 ++++---- .../haskell-http-client/tests/PropMime.hs | 24 +- .../haskell-http-client/tests/Test.hs | 22 +- 21 files changed, 786 insertions(+), 857 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 8c64f959531..07fc3c52e00 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -362,8 +362,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public void processOpts() { super.processOpts(); - if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { - LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); + if (StringUtils.isEmpty(System.getenv("HASKELL_POST_PROCESS_FILE"))) { + LOGGER.info("Hint: Environment variable HASKELL_POST_PROCESS_FILE not defined so the Haskell code may not be properly formatted. To define it, try 'export HASKELL_POST_PROCESS_FILE=\"$HOME/.local/bin/hfmt -w\"' (Linux/Mac)"); } if (additionalProperties.containsKey(PROP_ALLOW_FROMJSON_NULLS)) { @@ -1356,21 +1356,22 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC if (file == null) { return; } - String hfmtPath = System.getenv("HFMT_PATH"); - if (StringUtils.isEmpty(hfmtPath)) { - return; // skip if HFMT_PATH env variable is not defined + String haskellPostProcessFile = System.getenv("HASKELL_POST_PROCESS_FILE"); + if (StringUtils.isEmpty(haskellPostProcessFile)) { + return; // skip if HASKELL_POST_PROCESS_FILE env variable is not defined } // only process files with hs extension if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { - String command = hfmtPath + " -i " + file.toString(); + String command = haskellPostProcessFile + " " + file.toString(); try { Process p = Runtime.getRuntime().exec(command); - p.waitFor(); - if (p.exitValue() != 0) { - LOGGER.error("Error running the command ({}). Exit value: {}", command, p.exitValue()); + int exitValue = p.waitFor(); + if (exitValue != 0) { + LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue); + } else { + LOGGER.info("Successfully executed: " + command); } - LOGGER.info("Successfully executed: " + command); } catch (Exception e) { LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java index dabc8c9dd0b..2cb95164694 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java @@ -199,8 +199,8 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf public void processOpts() { super.processOpts(); - if (StringUtils.isEmpty(System.getenv("HFMT_PATH"))) { - LOGGER.info("Environment variable HFMT_PATH not defined so the Haskell code may not be properly formatted. To define it, try 'export HFMT_PATH=$HOME/.local/bin/hfmt' (Linux/Mac)"); + if (StringUtils.isEmpty(System.getenv("HASKELL_POST_PROCESS_FILE"))) { + LOGGER.info("Hint: Environment variable HASKELL_POST_PROCESS_FILE not defined so the Haskell code may not be properly formatted. To define it, try 'export HASKELL_POST_PROCESS_FILE=\"$HOME/.local/bin/hfmt -w\"' (Linux/Mac)"); } } @@ -607,21 +607,22 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf if (file == null) { return; } - String hfmtPath = System.getenv("HFMT_PATH"); - if (StringUtils.isEmpty(hfmtPath)) { - return; // skip if HFMT_PATH env variable is not defined + String haskellPostProcessFile = System.getenv("HASKELL_POST_PROCESS_FILE"); + if (StringUtils.isEmpty(haskellPostProcessFile)) { + return; // skip if HASKELL_POST_PROCESS_FILE env variable is not defined } // only process files with hs extension if ("hs".equals(FilenameUtils.getExtension(file.toString()))) { - String command = hfmtPath + " -w " + file.toString(); + String command = haskellPostProcessFile + " " + file.toString(); try { Process p = Runtime.getRuntime().exec(command); - p.waitFor(); - if (p.exitValue() != 0) { - LOGGER.error("Error running the command ({}). Exit value: {}", command, p.exitValue()); + int exitValue = p.waitFor(); + if (exitValue != 0) { + LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue); + } else { + LOGGER.info("Successfully executed: " + command); } - LOGGER.info("Successfully executed: " + command); } catch (Exception e) { LOGGER.error("Error running the command ({}). Exception: {}", command, e.getMessage()); } diff --git a/samples/client/petstore/haskell-http-client/Setup.hs b/samples/client/petstore/haskell-http-client/Setup.hs index 44671092b28..9a994af677b 100644 --- a/samples/client/petstore/haskell-http-client/Setup.hs +++ b/samples/client/petstore/haskell-http-client/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index 0f416bdb5f7..83e607b1ad7 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -22,10 +22,10 @@ module OpenAPIPetstore , 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 +import OpenAPIPetstore.API +import OpenAPIPetstore.Client +import OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model +import OpenAPIPetstore.ModelLens \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 5a97db25a66..7335a85067e 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -21,9 +21,9 @@ module OpenAPIPetstore.API , 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 +import OpenAPIPetstore.API.AnotherFake +import OpenAPIPetstore.API.Fake +import OpenAPIPetstore.API.FakeClassnameTags123 +import OpenAPIPetstore.API.Pet +import OpenAPIPetstore.API.Store +import OpenAPIPetstore.API.User \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index 6d532ae69fc..aa3b293eb67 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.AnotherFake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** op123testSpecialTags -- | @PATCH \/another-fake\/dummy@ --- +-- -- To test special tags --- +-- -- To test special tags and operation ID starting with number --- -op123testSpecialTags +-- +op123testSpecialTags :: (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest Op123testSpecialTags MimeJSON Client MimeJSON @@ -82,10 +73,10 @@ op123testSpecialTags client = _mkRequest "PATCH" ["/another-fake/dummy"] `setBodyParam` client -data Op123testSpecialTags +data Op123testSpecialTags -- | /Body Param/ "Client" - client model -instance HasBodyParam Op123testSpecialTags Client +instance HasBodyParam Op123testSpecialTags Client -- | @application/json@ instance Consumes Op123testSpecialTags MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index f2e7f89c413..4d73209965f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Fake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,10 +60,10 @@ import qualified Prelude as P -- *** fakeOuterBooleanSerialize -- | @POST \/fake\/outer\/boolean@ --- +-- -- Test serialization of outer boolean types --- -fakeOuterBooleanSerialize +-- +fakeOuterBooleanSerialize :: (Consumes FakeOuterBooleanSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -80,10 +71,10 @@ fakeOuterBooleanSerialize fakeOuterBooleanSerialize _ _ = _mkRequest "POST" ["/fake/outer/boolean"] -data FakeOuterBooleanSerialize +data FakeOuterBooleanSerialize -- | /Body Param/ "body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BodyBool +instance HasBodyParam FakeOuterBooleanSerialize BodyBool -- | @*/*@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype @@ -92,10 +83,10 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype -- *** fakeOuterCompositeSerialize -- | @POST \/fake\/outer\/composite@ --- +-- -- Test serialization of object with outer number type --- -fakeOuterCompositeSerialize +-- +fakeOuterCompositeSerialize :: (Consumes FakeOuterCompositeSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -103,10 +94,10 @@ fakeOuterCompositeSerialize fakeOuterCompositeSerialize _ _ = _mkRequest "POST" ["/fake/outer/composite"] -data FakeOuterCompositeSerialize +data FakeOuterCompositeSerialize -- | /Body Param/ "OuterComposite" - Input composite as post body -instance HasBodyParam FakeOuterCompositeSerialize OuterComposite +instance HasBodyParam FakeOuterCompositeSerialize OuterComposite -- | @*/*@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype @@ -115,10 +106,10 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype -- *** fakeOuterNumberSerialize -- | @POST \/fake\/outer\/number@ --- +-- -- Test serialization of outer number types --- -fakeOuterNumberSerialize +-- +fakeOuterNumberSerialize :: (Consumes FakeOuterNumberSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -126,10 +117,10 @@ fakeOuterNumberSerialize fakeOuterNumberSerialize _ _ = _mkRequest "POST" ["/fake/outer/number"] -data FakeOuterNumberSerialize +data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body -instance HasBodyParam FakeOuterNumberSerialize Body +instance HasBodyParam FakeOuterNumberSerialize Body -- | @*/*@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype @@ -138,10 +129,10 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype -- *** fakeOuterStringSerialize -- | @POST \/fake\/outer\/string@ --- +-- -- Test serialization of outer string types --- -fakeOuterStringSerialize +-- +fakeOuterStringSerialize :: (Consumes FakeOuterStringSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -149,10 +140,10 @@ fakeOuterStringSerialize fakeOuterStringSerialize _ _ = _mkRequest "POST" ["/fake/outer/string"] -data FakeOuterStringSerialize +data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body -instance HasBodyParam FakeOuterStringSerialize BodyText +instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype @@ -161,10 +152,10 @@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype -- *** testBodyWithFileSchema -- | @PUT \/fake\/body-with-file-schema@ --- +-- -- For this test, the body for this request much reference a schema named `File`. --- -testBodyWithFileSchema +-- +testBodyWithFileSchema :: (Consumes TestBodyWithFileSchema MimeJSON, MimeRender MimeJSON FileSchemaTestClass) => FileSchemaTestClass -- ^ "fileSchemaTestClass" -> OpenAPIPetstoreRequest TestBodyWithFileSchema MimeJSON NoContent MimeNoContent @@ -172,8 +163,8 @@ testBodyWithFileSchema fileSchemaTestClass = _mkRequest "PUT" ["/fake/body-with-file-schema"] `setBodyParam` fileSchemaTestClass -data TestBodyWithFileSchema -instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass +data TestBodyWithFileSchema +instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass -- | @application/json@ instance Consumes TestBodyWithFileSchema MimeJSON @@ -184,8 +175,8 @@ instance Produces TestBodyWithFileSchema MimeNoContent -- *** testBodyWithQueryParams -- | @PUT \/fake\/body-with-query-params@ --- -testBodyWithQueryParams +-- +testBodyWithQueryParams :: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) => User -- ^ "user" -> Query -- ^ "query" @@ -195,8 +186,8 @@ testBodyWithQueryParams user (Query query) = `setBodyParam` user `setQuery` toQuery ("query", Just query) -data TestBodyWithQueryParams -instance HasBodyParam TestBodyWithQueryParams User +data TestBodyWithQueryParams +instance HasBodyParam TestBodyWithQueryParams User -- | @application/json@ instance Consumes TestBodyWithQueryParams MimeJSON @@ -207,12 +198,12 @@ instance Produces TestBodyWithQueryParams MimeNoContent -- *** testClientModel -- | @PATCH \/fake@ --- +-- -- To test \"client\" model --- +-- -- To test \"client\" model --- -testClientModel +-- +testClientModel :: (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON @@ -220,10 +211,10 @@ testClientModel client = _mkRequest "PATCH" ["/fake"] `setBodyParam` client -data TestClientModel +data TestClientModel -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClientModel Client +instance HasBodyParam TestClientModel Client -- | @application/json@ instance Consumes TestClientModel MimeJSON @@ -235,14 +226,14 @@ instance Produces TestClientModel MimeJSON -- *** testEndpointParameters -- | @POST \/fake@ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- -- AuthMethod: 'AuthBasicHttpBasicTest' --- -testEndpointParameters +-- +testEndpointParameters :: (Consumes TestEndpointParameters MimeFormUrlEncoded) => Number -- ^ "number" - None -> ParamDouble -- ^ "double" - None @@ -257,7 +248,7 @@ testEndpointParameters (Number number) (ParamDouble double) (PatternWithoutDelim `addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter) `addForm` toForm ("byte", byte) -data TestEndpointParameters +data TestEndpointParameters -- | /Optional Param/ "integer" - None instance HasOptionalParam TestEndpointParameters ParamInteger where @@ -318,18 +309,18 @@ instance Produces TestEndpointParameters MimeNoContent -- *** testEnumParameters -- | @GET \/fake@ --- +-- -- To test enum parameters --- +-- -- To test enum parameters --- -testEnumParameters +-- +testEnumParameters :: (Consumes TestEnumParameters MimeFormUrlEncoded) => OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent testEnumParameters = _mkRequest "GET" ["/fake"] -data TestEnumParameters +data TestEnumParameters -- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumFormStringArray where @@ -380,10 +371,10 @@ instance Produces TestEnumParameters MimeNoContent -- *** testInlineAdditionalProperties -- | @POST \/fake\/inline-additionalProperties@ --- +-- -- test inline additionalProperties --- -testInlineAdditionalProperties +-- +testInlineAdditionalProperties :: (Consumes TestInlineAdditionalProperties MimeJSON, MimeRender MimeJSON RequestBody) => RequestBody -- ^ "requestBody" - request body -> OpenAPIPetstoreRequest TestInlineAdditionalProperties MimeJSON NoContent MimeNoContent @@ -391,10 +382,10 @@ testInlineAdditionalProperties requestBody = _mkRequest "POST" ["/fake/inline-additionalProperties"] `setBodyParam` requestBody -data TestInlineAdditionalProperties +data TestInlineAdditionalProperties -- | /Body Param/ "request_body" - request body -instance HasBodyParam TestInlineAdditionalProperties RequestBody +instance HasBodyParam TestInlineAdditionalProperties RequestBody -- | @application/json@ instance Consumes TestInlineAdditionalProperties MimeJSON @@ -405,10 +396,10 @@ instance Produces TestInlineAdditionalProperties MimeNoContent -- *** testJsonFormData -- | @GET \/fake\/jsonFormData@ --- +-- -- test json serialization of form data --- -testJsonFormData +-- +testJsonFormData :: (Consumes TestJsonFormData MimeFormUrlEncoded) => Param -- ^ "param" - field1 -> Param2 -- ^ "param2" - field2 @@ -418,7 +409,7 @@ testJsonFormData (Param param) (Param2 param2) = `addForm` toForm ("param", param) `addForm` toForm ("param2", param2) -data TestJsonFormData +data TestJsonFormData -- | @application/x-www-form-urlencoded@ instance Consumes TestJsonFormData MimeFormUrlEncoded diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index 6ffc6f39aff..5719e3c4cd4 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.FakeClassnameTags123 -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,14 +60,14 @@ import qualified Prelude as P -- *** testClassname -- | @PATCH \/fake_classname_test@ --- +-- -- To test class name in snake case --- +-- -- To test class name in snake case --- +-- -- AuthMethod: 'AuthApiKeyApiKeyQuery' --- -testClassname +-- +testClassname :: (Consumes TestClassname MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClassname MimeJSON Client MimeJSON @@ -85,10 +76,10 @@ testClassname client = `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) `setBodyParam` client -data TestClassname +data TestClassname -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClassname Client +instance HasBodyParam TestClassname Client -- | @application/json@ instance Consumes TestClassname MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 0e127d4e849..7b6de84e74b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Pet -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** addPet -- | @POST \/pet@ --- +-- -- Add a new pet to the store --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -addPet +-- +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 @@ -84,10 +75,10 @@ addPet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data AddPet +data AddPet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam AddPet Pet +instance HasBodyParam AddPet Pet -- | @application/xml@ instance Consumes AddPet MimeXML @@ -100,19 +91,19 @@ instance Produces AddPet MimeNoContent -- *** deletePet -- | @DELETE \/pet\/{petId}@ --- +-- -- Deletes a pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -deletePet +-- +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 +data DeletePet instance HasOptionalParam DeletePet ApiKey where applyOptionalParam req (ApiKey xs) = req `setHeader` toHeader ("api_key", xs) @@ -123,14 +114,14 @@ 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 +-- +findPetsByStatus :: Accept accept -- ^ request accept ('MimeType') -> Status -- ^ "status" - Status values that need to be considered for filter -> OpenAPIPetstoreRequest FindPetsByStatus MimeNoContent [Pet] accept @@ -139,7 +130,7 @@ findPetsByStatus _ (Status status) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setQuery` toQueryColl CommaSeparated ("status", Just status) -data FindPetsByStatus +data FindPetsByStatus -- | @application/xml@ instance Produces FindPetsByStatus MimeXML @@ -150,14 +141,14 @@ 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 +-- +findPetsByTags :: Accept accept -- ^ request accept ('MimeType') -> Tags -- ^ "tags" - Tags to filter by -> OpenAPIPetstoreRequest FindPetsByTags MimeNoContent [Pet] accept @@ -168,7 +159,7 @@ findPetsByTags _ (Tags tags) = {-# DEPRECATED findPetsByTags "" #-} -data FindPetsByTags +data FindPetsByTags -- | @application/xml@ instance Produces FindPetsByTags MimeXML @@ -179,14 +170,14 @@ instance Produces FindPetsByTags MimeJSON -- *** getPetById -- | @GET \/pet\/{petId}@ --- +-- -- Find pet by ID --- +-- -- Returns a single pet --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getPetById +-- +getPetById :: Accept accept -- ^ request accept ('MimeType') -> PetId -- ^ "petId" - ID of pet to return -> OpenAPIPetstoreRequest GetPetById MimeNoContent Pet accept @@ -194,7 +185,7 @@ getPetById _ (PetId petId) = _mkRequest "GET" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetPetById +data GetPetById -- | @application/xml@ instance Produces GetPetById MimeXML @@ -205,12 +196,12 @@ instance Produces GetPetById MimeJSON -- *** updatePet -- | @PUT \/pet@ --- +-- -- Update an existing pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePet +-- +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 @@ -220,10 +211,10 @@ updatePet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data UpdatePet +data UpdatePet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam UpdatePet Pet +instance HasBodyParam UpdatePet Pet -- | @application/xml@ instance Consumes UpdatePet MimeXML @@ -236,12 +227,12 @@ instance Produces UpdatePet MimeNoContent -- *** updatePetWithForm -- | @POST \/pet\/{petId}@ --- +-- -- Updates a pet in the store with form data --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePetWithForm +-- +updatePetWithForm :: (Consumes UpdatePetWithForm MimeFormUrlEncoded) => PetId -- ^ "petId" - ID of pet that needs to be updated -> OpenAPIPetstoreRequest UpdatePetWithForm MimeFormUrlEncoded NoContent MimeNoContent @@ -249,7 +240,7 @@ updatePetWithForm (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UpdatePetWithForm +data UpdatePetWithForm -- | /Optional Param/ "name" - Updated name of the pet instance HasOptionalParam UpdatePetWithForm Name2 where @@ -270,12 +261,12 @@ instance Produces UpdatePetWithForm MimeNoContent -- *** uploadFile -- | @POST \/pet\/{petId}\/uploadImage@ --- +-- -- uploads an image --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFile +-- +uploadFile :: (Consumes UploadFile MimeMultipartFormData) => PetId -- ^ "petId" - ID of pet to update -> OpenAPIPetstoreRequest UploadFile MimeMultipartFormData ApiResponse MimeJSON @@ -283,7 +274,7 @@ uploadFile (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UploadFile +data UploadFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFile AdditionalMetadata where @@ -305,12 +296,12 @@ instance Produces UploadFile MimeJSON -- *** uploadFileWithRequiredFile -- | @POST \/fake\/{petId}\/uploadImageWithRequiredFile@ --- +-- -- uploads an image (required) --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFileWithRequiredFile +-- +uploadFileWithRequiredFile :: (Consumes UploadFileWithRequiredFile MimeMultipartFormData) => RequiredFile -- ^ "requiredFile" - file to upload -> PetId -- ^ "petId" - ID of pet to update @@ -320,7 +311,7 @@ uploadFileWithRequiredFile (RequiredFile requiredFile) (PetId petId) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `_addMultiFormPart` NH.partFileSource "requiredFile" requiredFile -data UploadFileWithRequiredFile +data UploadFileWithRequiredFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFileWithRequiredFile AdditionalMetadata where diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index ef549c44c80..12bcd0bc94a 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Store -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,18 +60,18 @@ import qualified Prelude as P -- *** 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 +-- +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 +data DeleteOrder instance Produces DeleteOrder MimeNoContent @@ -88,20 +79,20 @@ instance Produces DeleteOrder MimeNoContent -- *** getInventory -- | @GET \/store\/inventory@ --- +-- -- Returns pet inventories by status --- +-- -- Returns a map of status codes to quantities --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getInventory +-- +getInventory :: OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON getInventory = _mkRequest "GET" ["/store/inventory"] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetInventory +data GetInventory -- | @application/json@ instance Produces GetInventory MimeJSON @@ -110,19 +101,19 @@ 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 +-- +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 +data GetOrderById -- | @application/xml@ instance Produces GetOrderById MimeXML @@ -133,10 +124,10 @@ instance Produces GetOrderById MimeJSON -- *** placeOrder -- | @POST \/store\/order@ --- +-- -- Place an order for a pet --- -placeOrder +-- +placeOrder :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -146,10 +137,10 @@ placeOrder _ _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order -data PlaceOrder +data PlaceOrder -- | /Body Param/ "Order" - order placed for purchasing the pet -instance HasBodyParam PlaceOrder Order +instance HasBodyParam PlaceOrder Order -- | @application/xml@ instance Produces PlaceOrder MimeXML diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index 87e0724d02f..efc6ad66f31 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.User -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** createUser -- | @POST \/user@ --- +-- -- Create user --- +-- -- This can only be done by the logged in user. --- -createUser +-- +createUser :: (Consumes CreateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Created user object @@ -83,10 +74,10 @@ createUser _ user = _mkRequest "POST" ["/user"] `setBodyParam` user -data CreateUser +data CreateUser -- | /Body Param/ "User" - Created user object -instance HasBodyParam CreateUser User +instance HasBodyParam CreateUser User instance Produces CreateUser MimeNoContent @@ -94,10 +85,10 @@ instance Produces CreateUser MimeNoContent -- *** createUsersWithArrayInput -- | @POST \/user\/createWithArray@ --- +-- -- Creates list of users with given input array --- -createUsersWithArrayInput +-- +createUsersWithArrayInput :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -106,10 +97,10 @@ createUsersWithArrayInput _ user = _mkRequest "POST" ["/user/createWithArray"] `setBodyParam` user -data CreateUsersWithArrayInput +data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithArrayInput User2 +instance HasBodyParam CreateUsersWithArrayInput User2 instance Produces CreateUsersWithArrayInput MimeNoContent @@ -117,10 +108,10 @@ instance Produces CreateUsersWithArrayInput MimeNoContent -- *** createUsersWithListInput -- | @POST \/user\/createWithList@ --- +-- -- Creates list of users with given input array --- -createUsersWithListInput +-- +createUsersWithListInput :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -129,10 +120,10 @@ createUsersWithListInput _ user = _mkRequest "POST" ["/user/createWithList"] `setBodyParam` user -data CreateUsersWithListInput +data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithListInput User2 +instance HasBodyParam CreateUsersWithListInput User2 instance Produces CreateUsersWithListInput MimeNoContent @@ -140,18 +131,18 @@ instance Produces CreateUsersWithListInput MimeNoContent -- *** deleteUser -- | @DELETE \/user\/{username}@ --- +-- -- Delete user --- +-- -- This can only be done by the logged in user. --- -deleteUser +-- +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 +data DeleteUser instance Produces DeleteUser MimeNoContent @@ -159,17 +150,17 @@ instance Produces DeleteUser MimeNoContent -- *** getUserByName -- | @GET \/user\/{username}@ --- +-- -- Get user by user name --- -getUserByName +-- +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 +data GetUserByName -- | @application/xml@ instance Produces GetUserByName MimeXML @@ -180,10 +171,10 @@ instance Produces GetUserByName MimeJSON -- *** loginUser -- | @GET \/user\/login@ --- +-- -- Logs user into the system --- -loginUser +-- +loginUser :: Accept accept -- ^ request accept ('MimeType') -> Username -- ^ "username" - The user name for login -> Password -- ^ "password" - The password for login in clear text @@ -193,7 +184,7 @@ loginUser _ (Username username) (Password password) = `setQuery` toQuery ("username", Just username) `setQuery` toQuery ("password", Just password) -data LoginUser +data LoginUser -- | @application/xml@ instance Produces LoginUser MimeXML @@ -204,15 +195,15 @@ instance Produces LoginUser MimeJSON -- *** logoutUser -- | @GET \/user\/logout@ --- +-- -- Logs out current logged in user session --- -logoutUser +-- +logoutUser :: OpenAPIPetstoreRequest LogoutUser MimeNoContent NoContent MimeNoContent logoutUser = _mkRequest "GET" ["/user/logout"] -data LogoutUser +data LogoutUser instance Produces LogoutUser MimeNoContent @@ -220,12 +211,12 @@ instance Produces LogoutUser MimeNoContent -- *** updateUser -- | @PUT \/user\/{username}@ --- +-- -- Updated user --- +-- -- This can only be done by the logged in user. --- -updateUser +-- +updateUser :: (Consumes UpdateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Updated user object @@ -235,10 +226,10 @@ updateUser _ user (Username username) = _mkRequest "PUT" ["/user/",toPath username] `setBodyParam` user -data UpdateUser +data UpdateUser -- | /Body Param/ "User" - Updated user object -instance HasBodyParam UpdateUser User +instance HasBodyParam UpdateUser User instance Produces UpdateUser MimeNoContent diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs index d8e0caf8a98..31cd12f7ada 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs @@ -12,42 +12,42 @@ Module : OpenAPIPetstore.Client -} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveFunctor #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} +{-# 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 as P -import qualified Control.Monad.IO.Class 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 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 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 (..)) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import GHC.Exts (IsString(..)) -- * Dispatch @@ -68,16 +68,16 @@ dispatchLbs manager config request = do -- | 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 + 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 + mimeError :: String -- ^ unrender/parser error + , mimeErrorResponse :: NH.Response BCL.ByteString -- ^ http response } deriving (Eq, Show) -- | send a request returning the 'MimeResult' @@ -153,7 +153,7 @@ dispatchInitUnsafe manager config (InitRequest req) = do "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> (case NH.requestBody req of NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) - _ -> "<RequestBody>") + _ -> "<RequestBody>") responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus responseLogMsg res = "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" @@ -171,7 +171,7 @@ _toInitRequest => OpenAPIPetstoreConfig -- ^ config -> OpenAPIPetstoreRequest req contentType res accept -- ^ request -> IO (InitRequest req contentType res accept) -- ^ initialized request -_toInitRequest config req0 = +_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 @@ -202,7 +202,7 @@ modifyInitRequest (InitRequest req) f = InitRequest (f req) 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 +-- ** Logging -- | Run a block using the configured logger instance runConfigLog diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs index f01a5542a69..6fbc9899d34 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs @@ -12,76 +12,70 @@ Module : OpenAPIPetstore.Core -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# 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.Logging -import OpenAPIPetstore.MimeTypes - -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, TypeRep, - Typeable, 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 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 Text.Printf as T -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Foldable (foldlM) -import Data.Function ((&)) -import Data.Monoid ((<>)) -import Data.Text (Text) -import Prelude (Bool (..), Char, - Functor, IO, Maybe (..), - Monad, String, fmap, - mempty, pure, return, - show, ($), (.), (<$>), - (<*>)) +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 + { 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 } @@ -113,7 +107,7 @@ newConfig = do , configLogContext = logCxt , configAuthMethods = [] , configValidateAuthMethods = True - } + } -- | updates config use AuthMethod on matching requests addAuthMethod :: AuthMethod auth => OpenAPIPetstoreConfig -> auth -> OpenAPIPetstoreConfig @@ -135,7 +129,7 @@ withStderrLogging p = do -- | updates the config to disable logging withNoLogging :: OpenAPIPetstoreConfig -> OpenAPIPetstoreConfig withNoLogging p = p { configLogExecWithContext = runNullLogExec} - + -- * OpenAPIPetstoreRequest -- | Represents a request. @@ -147,9 +141,9 @@ withNoLogging p = p { configLogExecWithContext = runNullLogExec} -- * 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 + { 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) @@ -202,9 +196,9 @@ infixl 2 -&- -- | Request Params data Params = Params - { paramsQuery :: NH.Query + { paramsQuery :: NH.Query , paramsHeaders :: NH.RequestHeaders - , paramsBody :: ParamBody + , paramsBody :: ParamBody } deriving (P.Show) @@ -234,7 +228,7 @@ data ParamBody -- ** OpenAPIPetstoreRequest Utils -_mkRequest :: NH.Method -- ^ Method +_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 [] @@ -259,18 +253,18 @@ removeHeader req header = _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)] + 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)] + 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 = +setQuery req query = req & L.over (rParamsL . paramsQueryL) @@ -279,25 +273,25 @@ setQuery req query = cifst = CI.mk . P.fst addForm :: OpenAPIPetstoreRequest req contentType res accept -> WH.Form -> OpenAPIPetstoreRequest req contentType res accept -addForm req newform = +addForm req newform = let form = case paramsBody (rParams req) of ParamBodyFormUrlEncoded _form -> _form - _ -> mempty + _ -> 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 = +_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 = +_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 = +_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 @@ -353,10 +347,10 @@ _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 '|') + CommaSeparated -> go (one ',') + SpaceSeparated -> go (one ' ') + TabSeparated -> go (one '\t') + PipeSeparated -> go (one '|') MultiParamArray -> expandList where go sep = @@ -366,7 +360,7 @@ _toCollA' c encode one xs = case c of {-# INLINE go #-} {-# INLINE expandList #-} {-# INLINE combine #-} - + -- * AuthMethods -- | Provides a method to apply auth methods to requests @@ -397,7 +391,7 @@ _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) @@ -405,7 +399,7 @@ _omitNulls :: [(Text, A.Value)] -> A.Value _omitNulls = A.object . P.filter notNull where notNull (_, A.Null) = False - notNull _ = True + notNull _ = True -- | Encodes fields using WH.toQueryParam _toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) @@ -414,13 +408,13 @@ _toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x -- | Collapse (Just "") to Nothing _emptyToNothing :: Maybe String -> Maybe String _emptyToNothing (Just "") = Nothing -_emptyToNothing x = x +_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 +_memptyToNothing x = x {-# INLINE _memptyToNothing #-} -- * DateTime Formatting @@ -491,7 +485,7 @@ _showDate = -- * Byte/Binary Formatting - + -- | base64 encoded characters newtype ByteArray = ByteArray { unByteArray :: BL.ByteString } deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index cd76f7789db..8e3d4ac772b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -13,23 +13,23 @@ Module : OpenAPIPetstore.Logging Katip Logging functions -} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} +{-# 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.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 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 Data.Text (Text) +import GHC.Exts (IsString(..)) -import qualified Katip as LG +import qualified Katip as LG -- * Type Aliases (for compatibility) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs index e9bfbd8babb..0da4b6310f0 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs @@ -12,38 +12,35 @@ Module : OpenAPIPetstore.MimeTypes -} -{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# 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 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 (Bool (..), Char, Double, FilePath, - Float, Int, Integer, Maybe (..), - String, fmap, mempty, undefined, - ($), (.), (<$>), (<*>)) -import qualified Prelude as P +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 @@ -85,13 +82,13 @@ class P.Typeable mtype => MimeType mtype where mimeTypes :: P.Proxy mtype -> [ME.MediaType] mimeTypes p = case mimeType p of - Just x -> [x] + Just x -> [x] Nothing -> [] mimeType :: P.Proxy mtype -> Maybe ME.MediaType mimeType p = case mimeTypes p of - [] -> Nothing + [] -> Nothing (x:_) -> Just x mimeType' :: mtype -> Maybe ME.MediaType diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index 0f25aaae94d..19b575dd855 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -12,60 +12,54 @@ Module : OpenAPIPetstore.Model -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.Model where -import OpenAPIPetstore.Core -import OpenAPIPetstore.MimeTypes - -import Data.Aeson ((.:), (.:!), (.:?), (.=)) - -import qualified Control.Arrow as P (left) -import qualified Data.Aeson as A -import qualified Data.ByteString as B -import qualified Data.ByteString.Base64 as B64 -import qualified Data.ByteString.Char8 as BC -import qualified Data.ByteString.Lazy as BL -import qualified Data.Data as P (TypeRep, Typeable, typeOf, - typeRep) -import qualified Data.Foldable as P -import qualified Data.HashMap.Lazy as HM -import qualified Data.Map as Map -import qualified Data.Maybe as P -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Time as TI -import qualified Lens.Micro as L -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Function ((&)) -import Data.Monoid ((<>)) -import Data.Text (Text) -import Prelude (Applicative, Bool (..), Char, - Double, FilePath, Float, Functor, - Int, Integer, Maybe (..), Monad, - String, fmap, maybe, mempty, pure, - undefined, ($), (.), (/=), (<$>), - (<*>), (=<<), (>>=)) - -import qualified Prelude as P +import OpenAPIPetstore.Core +import OpenAPIPetstore.MimeTypes + +import Data.Aeson ((.:),(.:!),(.:?),(.=)) + +import qualified Control.Arrow as P (left) +import qualified Data.Aeson as A +import qualified Data.ByteString as B +import qualified Data.ByteString.Base64 as B64 +import qualified Data.ByteString.Char8 as BC +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.HashMap.Lazy as HM +import qualified Data.Map as Map +import qualified Data.Maybe as P +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import qualified Data.Time as TI +import qualified Lens.Micro as L +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Function ((&)) +import Data.Monoid ((<>)) +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 @@ -237,7 +231,7 @@ mkAdditionalPropertiesClass = -- | Animal data Animal = Animal { animalClassName :: !(Text) -- ^ /Required/ "className" - , animalColor :: !(Maybe Text) -- ^ "color" + , animalColor :: !(Maybe Text) -- ^ "color" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Animal @@ -258,7 +252,7 @@ instance A.ToJSON Animal where -- | Construct a value of type 'Animal' (by applying it's required fields, if any) mkAnimal - :: Text -- ^ 'animalClassName' + :: Text -- ^ 'animalClassName' -> Animal mkAnimal animalClassName = Animal @@ -269,20 +263,20 @@ mkAnimal animalClassName = -- ** AnimalFarm -- | AnimalFarm data AnimalFarm = AnimalFarm - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON AnimalFarm instance A.FromJSON AnimalFarm where parseJSON = A.withObject "AnimalFarm" $ \o -> pure AnimalFarm - + -- | ToJSON AnimalFarm instance A.ToJSON AnimalFarm where toJSON AnimalFarm = _omitNulls - [ + [ ] @@ -291,14 +285,14 @@ mkAnimalFarm :: AnimalFarm mkAnimalFarm = AnimalFarm - { + { } -- ** ApiResponse -- | ApiResponse data ApiResponse = ApiResponse - { apiResponseCode :: !(Maybe Int) -- ^ "code" - , apiResponseType :: !(Maybe Text) -- ^ "type" + { apiResponseCode :: !(Maybe Int) -- ^ "code" + , apiResponseType :: !(Maybe Text) -- ^ "type" , apiResponseMessage :: !(Maybe Text) -- ^ "message" } deriving (P.Show, P.Eq, P.Typeable) @@ -389,9 +383,9 @@ mkArrayOfNumberOnly = -- ** ArrayTest -- | ArrayTest data ArrayTest = ArrayTest - { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" + { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" - , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" + , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ArrayTest @@ -425,12 +419,12 @@ mkArrayTest = -- ** Capitalization -- | Capitalization data Capitalization = Capitalization - { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" - , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" - , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" - , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" + { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" + , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" + , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" + , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" - , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet + , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Capitalization @@ -474,8 +468,8 @@ mkCapitalization = -- | Cat data Cat = Cat { catClassName :: !(Text) -- ^ /Required/ "className" - , catColor :: !(Maybe Text) -- ^ "color" - , catDeclawed :: !(Maybe Bool) -- ^ "declawed" + , catColor :: !(Maybe Text) -- ^ "color" + , catDeclawed :: !(Maybe Bool) -- ^ "declawed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Cat @@ -498,7 +492,7 @@ instance A.ToJSON Cat where -- | Construct a value of type 'Cat' (by applying it's required fields, if any) mkCat - :: Text -- ^ 'catClassName' + :: Text -- ^ 'catClassName' -> Cat mkCat catClassName = Cat @@ -510,7 +504,7 @@ mkCat catClassName = -- ** Category -- | Category data Category = Category - { categoryId :: !(Maybe Integer) -- ^ "id" + { categoryId :: !(Maybe Integer) -- ^ "id" , categoryName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -600,8 +594,8 @@ mkClient = -- | Dog data Dog = Dog { dogClassName :: !(Text) -- ^ /Required/ "className" - , dogColor :: !(Maybe Text) -- ^ "color" - , dogBreed :: !(Maybe Text) -- ^ "breed" + , dogColor :: !(Maybe Text) -- ^ "color" + , dogBreed :: !(Maybe Text) -- ^ "breed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Dog @@ -624,7 +618,7 @@ instance A.ToJSON Dog where -- | Construct a value of type 'Dog' (by applying it's required fields, if any) mkDog - :: Text -- ^ 'dogClassName' + :: Text -- ^ 'dogClassName' -> Dog mkDog dogClassName = Dog @@ -637,7 +631,7 @@ mkDog dogClassName = -- | EnumArrays data EnumArrays = EnumArrays { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumArrays @@ -668,11 +662,11 @@ mkEnumArrays = -- ** EnumTest -- | EnumTest data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" , enumTestEnumStringRequired :: !(E'EnumString) -- ^ /Required/ "enum_string_required" - , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" - , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" + , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumTest @@ -699,7 +693,7 @@ instance A.ToJSON EnumTest where -- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) mkEnumTest - :: E'EnumString -- ^ 'enumTestEnumStringRequired' + :: E'EnumString -- ^ 'enumTestEnumStringRequired' -> EnumTest mkEnumTest enumTestEnumStringRequired = EnumTest @@ -742,7 +736,7 @@ mkFile = -- ** FileSchemaTestClass -- | FileSchemaTestClass data FileSchemaTestClass = FileSchemaTestClass - { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" + { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" , fileSchemaTestClassFiles :: !(Maybe [File]) -- ^ "files" } deriving (P.Show, P.Eq, P.Typeable) @@ -774,18 +768,18 @@ mkFileSchemaTestClass = -- ** FormatTest -- | FormatTest data FormatTest = FormatTest - { formatTestInteger :: !(Maybe Int) -- ^ "integer" - , formatTestInt32 :: !(Maybe Int) -- ^ "int32" - , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" - , formatTestNumber :: !(Double) -- ^ /Required/ "number" - , formatTestFloat :: !(Maybe Float) -- ^ "float" - , formatTestDouble :: !(Maybe Double) -- ^ "double" - , formatTestString :: !(Maybe Text) -- ^ "string" - , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" - , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" - , formatTestDate :: !(Date) -- ^ /Required/ "date" + { formatTestInteger :: !(Maybe Int) -- ^ "integer" + , formatTestInt32 :: !(Maybe Int) -- ^ "int32" + , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" + , formatTestNumber :: !(Double) -- ^ /Required/ "number" + , formatTestFloat :: !(Maybe Float) -- ^ "float" + , formatTestDouble :: !(Maybe Double) -- ^ "double" + , formatTestString :: !(Maybe Text) -- ^ "string" + , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" + , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" + , formatTestDate :: !(Date) -- ^ /Required/ "date" , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , formatTestUuid :: !(Maybe Text) -- ^ "uuid" + , formatTestUuid :: !(Maybe Text) -- ^ "uuid" , formatTestPassword :: !(Text) -- ^ /Required/ "password" } deriving (P.Show, P.Eq, P.Typeable) @@ -829,10 +823,10 @@ instance A.ToJSON FormatTest where -- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) mkFormatTest - :: Double -- ^ 'formatTestNumber' - -> ByteArray -- ^ 'formatTestByte' - -> Date -- ^ 'formatTestDate' - -> Text -- ^ 'formatTestPassword' + :: Double -- ^ 'formatTestNumber' + -> ByteArray -- ^ 'formatTestByte' + -> Date -- ^ 'formatTestDate' + -> Text -- ^ 'formatTestPassword' -> FormatTest mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = FormatTest @@ -886,10 +880,10 @@ mkHasOnlyReadOnly = -- ** MapTest -- | MapTest data MapTest = MapTest - { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" + { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" - , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" - , mapTestIndirectMap :: !(Maybe StringBooleanMap) -- ^ "indirect_map" + , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" + , mapTestIndirectMap :: !(Maybe StringBooleanMap) -- ^ "indirect_map" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON MapTest @@ -963,7 +957,7 @@ mkMixedPropertiesAndAdditionalPropertiesClass = -- | Model200Response -- Model for testing model name starting with number data Model200Response = Model200Response - { model200ResponseName :: !(Maybe Int) -- ^ "name" + { model200ResponseName :: !(Maybe Int) -- ^ "name" , model200ResponseClass :: !(Maybe Text) -- ^ "class" } deriving (P.Show, P.Eq, P.Typeable) @@ -1053,9 +1047,9 @@ mkModelReturn = -- | Name -- Model for testing model name same as property name data Name = Name - { nameName :: !(Int) -- ^ /Required/ "name" + { nameName :: !(Int) -- ^ /Required/ "name" , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" - , nameProperty :: !(Maybe Text) -- ^ "property" + , nameProperty :: !(Maybe Text) -- ^ "property" , name123number :: !(Maybe Int) -- ^ "123Number" } deriving (P.Show, P.Eq, P.Typeable) @@ -1081,7 +1075,7 @@ instance A.ToJSON Name where -- | Construct a value of type 'Name' (by applying it's required fields, if any) mkName - :: Int -- ^ 'nameName' + :: Int -- ^ 'nameName' -> Name mkName nameName = Name @@ -1122,11 +1116,11 @@ mkNumberOnly = -- ** Order -- | Order data Order = Order - { orderId :: !(Maybe Integer) -- ^ "id" - , orderPetId :: !(Maybe Integer) -- ^ "petId" + { orderId :: !(Maybe Integer) -- ^ "id" + , orderPetId :: !(Maybe Integer) -- ^ "petId" , orderQuantity :: !(Maybe Int) -- ^ "quantity" , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status , orderComplete :: !(Maybe Bool) -- ^ "complete" } deriving (P.Show, P.Eq, P.Typeable) @@ -1170,8 +1164,8 @@ mkOrder = -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" + { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" , outerCompositeMyBoolean :: !(Maybe Bool) -- ^ "my_boolean" } deriving (P.Show, P.Eq, P.Typeable) @@ -1206,12 +1200,12 @@ mkOuterComposite = -- ** Pet -- | Pet data Pet = Pet - { petId :: !(Maybe Integer) -- ^ "id" - , petCategory :: !(Maybe Category) -- ^ "category" - , petName :: !(Text) -- ^ /Required/ "name" + { petId :: !(Maybe Integer) -- ^ "id" + , petCategory :: !(Maybe Category) -- ^ "category" + , petName :: !(Text) -- ^ /Required/ "name" , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" - , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store + , petTags :: !(Maybe [Tag]) -- ^ "tags" + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Pet @@ -1240,8 +1234,8 @@ instance A.ToJSON Pet where -- | Construct a value of type 'Pet' (by applying it's required fields, if any) mkPet - :: Text -- ^ 'petName' - -> [Text] -- ^ 'petPhotoUrls' + :: Text -- ^ 'petName' + -> [Text] -- ^ 'petPhotoUrls' -> Pet mkPet petName petPhotoUrls = Pet @@ -1316,20 +1310,20 @@ mkSpecialModelName = -- ** StringBooleanMap -- | StringBooleanMap data StringBooleanMap = StringBooleanMap - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON StringBooleanMap instance A.FromJSON StringBooleanMap where parseJSON = A.withObject "StringBooleanMap" $ \o -> pure StringBooleanMap - + -- | ToJSON StringBooleanMap instance A.ToJSON StringBooleanMap where toJSON StringBooleanMap = _omitNulls - [ + [ ] @@ -1338,13 +1332,13 @@ mkStringBooleanMap :: StringBooleanMap mkStringBooleanMap = StringBooleanMap - { + { } -- ** Tag -- | Tag data Tag = Tag - { tagId :: !(Maybe Integer) -- ^ "id" + { tagId :: !(Maybe Integer) -- ^ "id" , tagName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -1376,13 +1370,13 @@ mkTag = -- ** User -- | User data User = User - { userId :: !(Maybe Integer) -- ^ "id" - , userUsername :: !(Maybe Text) -- ^ "username" - , userFirstName :: !(Maybe Text) -- ^ "firstName" - , userLastName :: !(Maybe Text) -- ^ "lastName" - , userEmail :: !(Maybe Text) -- ^ "email" - , userPassword :: !(Maybe Text) -- ^ "password" - , userPhone :: !(Maybe Text) -- ^ "phone" + { userId :: !(Maybe Integer) -- ^ "id" + , userUsername :: !(Maybe Text) -- ^ "username" + , userFirstName :: !(Maybe Text) -- ^ "firstName" + , userLastName :: !(Maybe Text) -- ^ "lastName" + , userEmail :: !(Maybe Text) -- ^ "email" + , userPassword :: !(Maybe Text) -- ^ "password" + , userPhone :: !(Maybe Text) -- ^ "phone" , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status } deriving (P.Show, P.Eq, P.Typeable) @@ -1463,7 +1457,7 @@ toE'ArrayEnum = \case -- ** E'EnumFormString --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString = E'EnumFormString'_abc -- ^ @"_abc"@ @@ -1694,7 +1688,7 @@ toE'JustSymbol = \case -- ** E'Status --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Order Status data E'Status = E'Status'Placed -- ^ @"placed"@ @@ -1726,7 +1720,7 @@ toE'Status = \case -- ** E'Status2 --- | Enum of 'Text' . +-- | Enum of 'Text' . -- pet status in the store data E'Status2 = E'Status2'Available -- ^ @"available"@ @@ -1869,7 +1863,7 @@ instance AuthMethod AuthOAuthPetstoreAuth where applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index 49e04148108..2fd47679ee3 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -12,32 +12,28 @@ Module : OpenAPIPetstore.Lens -} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} +{-# 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 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 Data.Text (Text) -import Prelude (Applicative, Bool (..), Char, Double, - FilePath, Float, Functor, Int, Integer, - Maybe (..), Monad, String, fmap, maybe, - mempty, pure, undefined, ($), (.), - (<$>), (<*>), (=<<)) -import qualified Prelude as P +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.Core -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.Core -- * AdditionalPropertiesClass diff --git a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs index a217b69021b..88ca2110a06 100644 --- a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs +++ b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs @@ -1,15 +1,15 @@ {-# LANGUAGE DefaultSignatures #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module ApproxEq where -import Data.Text (Text) -import Data.Time.Clock -import GHC.Generics as G -import Test.QuickCheck +import Data.Text (Text) +import Data.Time.Clock +import Test.QuickCheck +import GHC.Generics as G (==~) :: (ApproxEq a, Show a) @@ -26,7 +26,7 @@ instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where gApproxEq (L1 a) (L1 b) = gApproxEq a b gApproxEq (R1 a) (R1 b) = gApproxEq a b - gApproxEq _ _ = False + gApproxEq _ _ = False instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index e4009849fc4..14cef8e188c 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -2,23 +2,23 @@ module Instances where -import OpenAPIPetstore.Core -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.Core -import qualified Data.Aeson as A -import qualified Data.ByteString.Lazy as BL -import qualified Data.HashMap.Strict as HM -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Time as TI -import qualified Data.Vector as V +import qualified Data.Aeson as A +import qualified Data.ByteString.Lazy as BL +import qualified Data.HashMap.Strict as HM +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Time as TI +import qualified Data.Vector as V -import Control.Monad -import Data.Char (isSpace) -import Data.List (sort) -import Test.QuickCheck +import Control.Monad +import Data.Char (isSpace) +import Data.List (sort) +import Test.QuickCheck -import ApproxEq +import ApproxEq instance Arbitrary T.Text where arbitrary = T.pack <$> arbitrary @@ -71,7 +71,7 @@ instance Arbitrary A.Value where sizedObject n = liftM (A.object . map mapF) $ replicateM n $ (,) <$> (arbitrary :: Gen String) <*> simpleAndArrays - + -- | Checks if a given list has no duplicates in _O(n log n)_. hasNoDups :: (Ord a) @@ -88,48 +88,48 @@ instance ApproxEq TI.Day where (=~) = (==) -- * Models - + instance Arbitrary AdditionalPropertiesClass where arbitrary = AdditionalPropertiesClass <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) - + instance Arbitrary Animal where arbitrary = Animal <$> arbitrary -- animalClassName :: Text <*> arbitrary -- animalColor :: Maybe Text - + instance Arbitrary AnimalFarm where arbitrary = - + pure AnimalFarm - + instance Arbitrary ApiResponse where arbitrary = ApiResponse <$> arbitrary -- apiResponseCode :: Maybe Int <*> arbitrary -- apiResponseType :: Maybe Text <*> arbitrary -- apiResponseMessage :: Maybe Text - + instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = ArrayOfArrayOfNumberOnly <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] - + instance Arbitrary ArrayOfNumberOnly where arbitrary = ArrayOfNumberOnly <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] - + instance Arbitrary ArrayTest where arbitrary = ArrayTest <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] - + instance Arbitrary Capitalization where arbitrary = Capitalization @@ -139,43 +139,43 @@ instance Arbitrary Capitalization where <*> arbitrary -- capitalizationCapitalSnake :: Maybe Text <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text <*> arbitrary -- capitalizationAttName :: Maybe Text - + instance Arbitrary Cat where arbitrary = Cat <$> arbitrary -- catClassName :: Text <*> arbitrary -- catColor :: Maybe Text <*> arbitrary -- catDeclawed :: Maybe Bool - + instance Arbitrary Category where arbitrary = Category <$> arbitrary -- categoryId :: Maybe Integer <*> arbitrary -- categoryName :: Maybe Text - + instance Arbitrary ClassModel where arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text - + instance Arbitrary Client where arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text - + instance Arbitrary Dog where arbitrary = Dog <$> arbitrary -- dogClassName :: Text <*> arbitrary -- dogColor :: Maybe Text <*> arbitrary -- dogBreed :: Maybe Text - + instance Arbitrary EnumArrays where arbitrary = EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] - + instance Arbitrary EnumTest where arbitrary = EnumTest @@ -184,18 +184,18 @@ instance Arbitrary EnumTest where <*> arbitrary -- enumTestEnumInteger :: Maybe Int <*> arbitrary -- enumTestEnumNumber :: Maybe Double <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum - + instance Arbitrary File where arbitrary = File <$> arbitrary -- fileSourceUri :: Maybe Text - + instance Arbitrary FileSchemaTestClass where arbitrary = FileSchemaTestClass <$> arbitrary -- fileSchemaTestClassFile :: Maybe File <*> arbitrary -- fileSchemaTestClassFiles :: Maybe [File] - + instance Arbitrary FormatTest where arbitrary = FormatTest @@ -212,13 +212,13 @@ instance Arbitrary FormatTest where <*> arbitrary -- formatTestDateTime :: Maybe DateTime <*> arbitrary -- formatTestUuid :: Maybe Text <*> arbitrary -- formatTestPassword :: Text - + instance Arbitrary HasOnlyReadOnly where arbitrary = HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text - + instance Arbitrary MapTest where arbitrary = MapTest @@ -226,30 +226,30 @@ instance Arbitrary MapTest where <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) <*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) <*> arbitrary -- mapTestIndirectMap :: Maybe StringBooleanMap - + instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = MixedPropertiesAndAdditionalPropertiesClass <$> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) - + instance Arbitrary Model200Response where arbitrary = Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int <*> arbitrary -- model200ResponseClass :: Maybe Text - + instance Arbitrary ModelList where arbitrary = ModelList <$> arbitrary -- modelList123list :: Maybe Text - + instance Arbitrary ModelReturn where arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int - + instance Arbitrary Name where arbitrary = Name @@ -257,12 +257,12 @@ instance Arbitrary Name where <*> arbitrary -- nameSnakeCase :: Maybe Int <*> arbitrary -- nameProperty :: Maybe Text <*> arbitrary -- name123number :: Maybe Int - + instance Arbitrary NumberOnly where arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double - + instance Arbitrary Order where arbitrary = Order @@ -272,14 +272,14 @@ instance Arbitrary Order where <*> arbitrary -- orderShipDate :: Maybe DateTime <*> arbitrary -- orderStatus :: Maybe Text <*> arbitrary -- orderComplete :: Maybe Bool - + instance Arbitrary OuterComposite where arbitrary = OuterComposite <$> arbitrary -- outerCompositeMyNumber :: Maybe Double <*> arbitrary -- outerCompositeMyString :: Maybe Text <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool - + instance Arbitrary Pet where arbitrary = Pet @@ -289,29 +289,29 @@ instance Arbitrary Pet where <*> arbitrary -- petPhotoUrls :: [Text] <*> arbitrary -- petTags :: Maybe [Tag] <*> arbitrary -- petStatus :: Maybe Text - + instance Arbitrary ReadOnlyFirst where arbitrary = ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text <*> arbitrary -- readOnlyFirstBaz :: Maybe Text - + instance Arbitrary SpecialModelName where arbitrary = SpecialModelName <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer - + instance Arbitrary StringBooleanMap where arbitrary = - + pure StringBooleanMap - + instance Arbitrary Tag where arbitrary = Tag <$> arbitrary -- tagId :: Maybe Integer <*> arbitrary -- tagName :: Maybe Text - + instance Arbitrary User where arbitrary = User @@ -323,7 +323,7 @@ instance Arbitrary User where <*> arbitrary -- userPassword :: Maybe Text <*> arbitrary -- userPhone :: Maybe Text <*> arbitrary -- userUserStatus :: Maybe Int - + diff --git a/samples/client/petstore/haskell-http-client/tests/PropMime.hs b/samples/client/petstore/haskell-http-client/tests/PropMime.hs index 2f64db78fe4..c5a78129777 100644 --- a/samples/client/petstore/haskell-http-client/tests/PropMime.hs +++ b/samples/client/petstore/haskell-http-client/tests/PropMime.hs @@ -1,23 +1,23 @@ -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE ConstraintKinds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module PropMime where -import Data.Aeson -import Data.Aeson.Types (parseEither) +import Data.Aeson +import Data.Aeson.Types (parseEither) +import Data.Monoid ((<>)) +import Data.Typeable (Proxy(..), typeOf, Typeable) import qualified Data.ByteString.Lazy.Char8 as BL8 -import Data.Monoid ((<>)) -import Data.Typeable (Proxy (..), Typeable, typeOf) -import Test.Hspec -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck -import Test.QuickCheck.Property +import Test.Hspec +import Test.QuickCheck +import Test.QuickCheck.Property +import Test.Hspec.QuickCheck (prop) -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes -import ApproxEq +import ApproxEq -- * Type Aliases diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index 926f7b9927b..ea6fff251e3 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -1,19 +1,19 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE PartialTypeSignatures #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} module Main where -import Data.Typeable (Proxy (..)) -import Test.Hspec -import Test.Hspec.QuickCheck +import Data.Typeable (Proxy(..)) +import Test.Hspec +import Test.Hspec.QuickCheck -import Instances () -import PropMime +import PropMime +import Instances () -import OpenAPIPetstore.MimeTypes -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.MimeTypes main :: IO () main = @@ -56,4 +56,4 @@ main = propMimeEq MimeJSON (Proxy :: Proxy StringBooleanMap) propMimeEq MimeJSON (Proxy :: Proxy Tag) propMimeEq MimeJSON (Proxy :: Proxy User) - + -- GitLab From 61df34295e17ff4d63597318e02de35730d6b28f Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Fri, 21 Sep 2018 00:30:12 +0800 Subject: [PATCH 07/10] update haskell samples with stylish-haskell --- .../petstore/haskell-http-client/Setup.hs | 2 +- .../lib/OpenAPIPetstore.hs | 14 +- .../lib/OpenAPIPetstore/API.hs | 12 +- .../lib/OpenAPIPetstore/API/AnotherFake.hs | 87 +++--- .../lib/OpenAPIPetstore/API/Fake.hs | 189 ++++++------- .../API/FakeClassnameTags123.hs | 89 ++++--- .../lib/OpenAPIPetstore/API/Pet.hs | 175 ++++++------ .../lib/OpenAPIPetstore/API/Store.hs | 117 ++++---- .../lib/OpenAPIPetstore/API/User.hs | 153 ++++++----- .../lib/OpenAPIPetstore/Client.hs | 72 ++--- .../lib/OpenAPIPetstore/Core.hs | 172 ++++++------ .../lib/OpenAPIPetstore/Logging.hs | 20 +- .../lib/OpenAPIPetstore/MimeTypes.hs | 53 ++-- .../lib/OpenAPIPetstore/Model.hs | 250 +++++++++--------- .../lib/OpenAPIPetstore/ModelLens.hs | 32 ++- .../haskell-http-client/tests/ApproxEq.hs | 14 +- .../haskell-http-client/tests/Instances.hs | 104 ++++---- .../haskell-http-client/tests/PropMime.hs | 24 +- .../haskell-http-client/tests/Test.hs | 22 +- 19 files changed, 837 insertions(+), 764 deletions(-) diff --git a/samples/client/petstore/haskell-http-client/Setup.hs b/samples/client/petstore/haskell-http-client/Setup.hs index 9a994af677b..44671092b28 100644 --- a/samples/client/petstore/haskell-http-client/Setup.hs +++ b/samples/client/petstore/haskell-http-client/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index 83e607b1ad7..0f416bdb5f7 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -22,10 +22,10 @@ module OpenAPIPetstore , 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 \ No newline at end of file +import OpenAPIPetstore.API +import OpenAPIPetstore.Client +import OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model +import OpenAPIPetstore.ModelLens diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 7335a85067e..5a97db25a66 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -21,9 +21,9 @@ module OpenAPIPetstore.API , 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 \ No newline at end of file +import OpenAPIPetstore.API.AnotherFake +import OpenAPIPetstore.API.Fake +import OpenAPIPetstore.API.FakeClassnameTags123 +import OpenAPIPetstore.API.Pet +import OpenAPIPetstore.API.Store +import OpenAPIPetstore.API.User diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index aa3b293eb67..6d532ae69fc 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.AnotherFake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,12 +69,12 @@ import qualified Prelude as P -- *** op123testSpecialTags -- | @PATCH \/another-fake\/dummy@ --- +-- -- To test special tags --- +-- -- To test special tags and operation ID starting with number --- -op123testSpecialTags +-- +op123testSpecialTags :: (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest Op123testSpecialTags MimeJSON Client MimeJSON @@ -73,10 +82,10 @@ op123testSpecialTags client = _mkRequest "PATCH" ["/another-fake/dummy"] `setBodyParam` client -data Op123testSpecialTags +data Op123testSpecialTags -- | /Body Param/ "Client" - client model -instance HasBodyParam Op123testSpecialTags Client +instance HasBodyParam Op123testSpecialTags Client -- | @application/json@ instance Consumes Op123testSpecialTags MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index 4d73209965f..f2e7f89c413 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.Fake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,10 +69,10 @@ import qualified Prelude as P -- *** fakeOuterBooleanSerialize -- | @POST \/fake\/outer\/boolean@ --- +-- -- Test serialization of outer boolean types --- -fakeOuterBooleanSerialize +-- +fakeOuterBooleanSerialize :: (Consumes FakeOuterBooleanSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -71,10 +80,10 @@ fakeOuterBooleanSerialize fakeOuterBooleanSerialize _ _ = _mkRequest "POST" ["/fake/outer/boolean"] -data FakeOuterBooleanSerialize +data FakeOuterBooleanSerialize -- | /Body Param/ "body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BodyBool +instance HasBodyParam FakeOuterBooleanSerialize BodyBool -- | @*/*@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype @@ -83,10 +92,10 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype -- *** fakeOuterCompositeSerialize -- | @POST \/fake\/outer\/composite@ --- +-- -- Test serialization of object with outer number type --- -fakeOuterCompositeSerialize +-- +fakeOuterCompositeSerialize :: (Consumes FakeOuterCompositeSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -94,10 +103,10 @@ fakeOuterCompositeSerialize fakeOuterCompositeSerialize _ _ = _mkRequest "POST" ["/fake/outer/composite"] -data FakeOuterCompositeSerialize +data FakeOuterCompositeSerialize -- | /Body Param/ "OuterComposite" - Input composite as post body -instance HasBodyParam FakeOuterCompositeSerialize OuterComposite +instance HasBodyParam FakeOuterCompositeSerialize OuterComposite -- | @*/*@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype @@ -106,10 +115,10 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype -- *** fakeOuterNumberSerialize -- | @POST \/fake\/outer\/number@ --- +-- -- Test serialization of outer number types --- -fakeOuterNumberSerialize +-- +fakeOuterNumberSerialize :: (Consumes FakeOuterNumberSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -117,10 +126,10 @@ fakeOuterNumberSerialize fakeOuterNumberSerialize _ _ = _mkRequest "POST" ["/fake/outer/number"] -data FakeOuterNumberSerialize +data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body -instance HasBodyParam FakeOuterNumberSerialize Body +instance HasBodyParam FakeOuterNumberSerialize Body -- | @*/*@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype @@ -129,10 +138,10 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype -- *** fakeOuterStringSerialize -- | @POST \/fake\/outer\/string@ --- +-- -- Test serialization of outer string types --- -fakeOuterStringSerialize +-- +fakeOuterStringSerialize :: (Consumes FakeOuterStringSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -140,10 +149,10 @@ fakeOuterStringSerialize fakeOuterStringSerialize _ _ = _mkRequest "POST" ["/fake/outer/string"] -data FakeOuterStringSerialize +data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body -instance HasBodyParam FakeOuterStringSerialize BodyText +instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype @@ -152,10 +161,10 @@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype -- *** testBodyWithFileSchema -- | @PUT \/fake\/body-with-file-schema@ --- +-- -- For this test, the body for this request much reference a schema named `File`. --- -testBodyWithFileSchema +-- +testBodyWithFileSchema :: (Consumes TestBodyWithFileSchema MimeJSON, MimeRender MimeJSON FileSchemaTestClass) => FileSchemaTestClass -- ^ "fileSchemaTestClass" -> OpenAPIPetstoreRequest TestBodyWithFileSchema MimeJSON NoContent MimeNoContent @@ -163,8 +172,8 @@ testBodyWithFileSchema fileSchemaTestClass = _mkRequest "PUT" ["/fake/body-with-file-schema"] `setBodyParam` fileSchemaTestClass -data TestBodyWithFileSchema -instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass +data TestBodyWithFileSchema +instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass -- | @application/json@ instance Consumes TestBodyWithFileSchema MimeJSON @@ -175,8 +184,8 @@ instance Produces TestBodyWithFileSchema MimeNoContent -- *** testBodyWithQueryParams -- | @PUT \/fake\/body-with-query-params@ --- -testBodyWithQueryParams +-- +testBodyWithQueryParams :: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) => User -- ^ "user" -> Query -- ^ "query" @@ -186,8 +195,8 @@ testBodyWithQueryParams user (Query query) = `setBodyParam` user `setQuery` toQuery ("query", Just query) -data TestBodyWithQueryParams -instance HasBodyParam TestBodyWithQueryParams User +data TestBodyWithQueryParams +instance HasBodyParam TestBodyWithQueryParams User -- | @application/json@ instance Consumes TestBodyWithQueryParams MimeJSON @@ -198,12 +207,12 @@ instance Produces TestBodyWithQueryParams MimeNoContent -- *** testClientModel -- | @PATCH \/fake@ --- +-- -- To test \"client\" model --- +-- -- To test \"client\" model --- -testClientModel +-- +testClientModel :: (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON @@ -211,10 +220,10 @@ testClientModel client = _mkRequest "PATCH" ["/fake"] `setBodyParam` client -data TestClientModel +data TestClientModel -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClientModel Client +instance HasBodyParam TestClientModel Client -- | @application/json@ instance Consumes TestClientModel MimeJSON @@ -226,14 +235,14 @@ instance Produces TestClientModel MimeJSON -- *** testEndpointParameters -- | @POST \/fake@ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- -- AuthMethod: 'AuthBasicHttpBasicTest' --- -testEndpointParameters +-- +testEndpointParameters :: (Consumes TestEndpointParameters MimeFormUrlEncoded) => Number -- ^ "number" - None -> ParamDouble -- ^ "double" - None @@ -248,7 +257,7 @@ testEndpointParameters (Number number) (ParamDouble double) (PatternWithoutDelim `addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter) `addForm` toForm ("byte", byte) -data TestEndpointParameters +data TestEndpointParameters -- | /Optional Param/ "integer" - None instance HasOptionalParam TestEndpointParameters ParamInteger where @@ -309,18 +318,18 @@ instance Produces TestEndpointParameters MimeNoContent -- *** testEnumParameters -- | @GET \/fake@ --- +-- -- To test enum parameters --- +-- -- To test enum parameters --- -testEnumParameters +-- +testEnumParameters :: (Consumes TestEnumParameters MimeFormUrlEncoded) => OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent testEnumParameters = _mkRequest "GET" ["/fake"] -data TestEnumParameters +data TestEnumParameters -- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumFormStringArray where @@ -371,10 +380,10 @@ instance Produces TestEnumParameters MimeNoContent -- *** testInlineAdditionalProperties -- | @POST \/fake\/inline-additionalProperties@ --- +-- -- test inline additionalProperties --- -testInlineAdditionalProperties +-- +testInlineAdditionalProperties :: (Consumes TestInlineAdditionalProperties MimeJSON, MimeRender MimeJSON RequestBody) => RequestBody -- ^ "requestBody" - request body -> OpenAPIPetstoreRequest TestInlineAdditionalProperties MimeJSON NoContent MimeNoContent @@ -382,10 +391,10 @@ testInlineAdditionalProperties requestBody = _mkRequest "POST" ["/fake/inline-additionalProperties"] `setBodyParam` requestBody -data TestInlineAdditionalProperties +data TestInlineAdditionalProperties -- | /Body Param/ "request_body" - request body -instance HasBodyParam TestInlineAdditionalProperties RequestBody +instance HasBodyParam TestInlineAdditionalProperties RequestBody -- | @application/json@ instance Consumes TestInlineAdditionalProperties MimeJSON @@ -396,10 +405,10 @@ instance Produces TestInlineAdditionalProperties MimeNoContent -- *** testJsonFormData -- | @GET \/fake\/jsonFormData@ --- +-- -- test json serialization of form data --- -testJsonFormData +-- +testJsonFormData :: (Consumes TestJsonFormData MimeFormUrlEncoded) => Param -- ^ "param" - field1 -> Param2 -- ^ "param2" - field2 @@ -409,7 +418,7 @@ testJsonFormData (Param param) (Param2 param2) = `addForm` toForm ("param", param) `addForm` toForm ("param2", param2) -data TestJsonFormData +data TestJsonFormData -- | @application/x-www-form-urlencoded@ instance Consumes TestJsonFormData MimeFormUrlEncoded diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index 5719e3c4cd4..6ffc6f39aff 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.FakeClassnameTags123 -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,14 +69,14 @@ import qualified Prelude as P -- *** testClassname -- | @PATCH \/fake_classname_test@ --- +-- -- To test class name in snake case --- +-- -- To test class name in snake case --- +-- -- AuthMethod: 'AuthApiKeyApiKeyQuery' --- -testClassname +-- +testClassname :: (Consumes TestClassname MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClassname MimeJSON Client MimeJSON @@ -76,10 +85,10 @@ testClassname client = `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) `setBodyParam` client -data TestClassname +data TestClassname -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClassname Client +instance HasBodyParam TestClassname Client -- | @application/json@ instance Consumes TestClassname MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 7b6de84e74b..0e127d4e849 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.Pet -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,12 +69,12 @@ import qualified Prelude as P -- *** addPet -- | @POST \/pet@ --- +-- -- Add a new pet to the store --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -addPet +-- +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 @@ -75,10 +84,10 @@ addPet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data AddPet +data AddPet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam AddPet Pet +instance HasBodyParam AddPet Pet -- | @application/xml@ instance Consumes AddPet MimeXML @@ -91,19 +100,19 @@ instance Produces AddPet MimeNoContent -- *** deletePet -- | @DELETE \/pet\/{petId}@ --- +-- -- Deletes a pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -deletePet +-- +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 +data DeletePet instance HasOptionalParam DeletePet ApiKey where applyOptionalParam req (ApiKey xs) = req `setHeader` toHeader ("api_key", xs) @@ -114,14 +123,14 @@ 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 +-- +findPetsByStatus :: Accept accept -- ^ request accept ('MimeType') -> Status -- ^ "status" - Status values that need to be considered for filter -> OpenAPIPetstoreRequest FindPetsByStatus MimeNoContent [Pet] accept @@ -130,7 +139,7 @@ findPetsByStatus _ (Status status) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setQuery` toQueryColl CommaSeparated ("status", Just status) -data FindPetsByStatus +data FindPetsByStatus -- | @application/xml@ instance Produces FindPetsByStatus MimeXML @@ -141,14 +150,14 @@ 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 +-- +findPetsByTags :: Accept accept -- ^ request accept ('MimeType') -> Tags -- ^ "tags" - Tags to filter by -> OpenAPIPetstoreRequest FindPetsByTags MimeNoContent [Pet] accept @@ -159,7 +168,7 @@ findPetsByTags _ (Tags tags) = {-# DEPRECATED findPetsByTags "" #-} -data FindPetsByTags +data FindPetsByTags -- | @application/xml@ instance Produces FindPetsByTags MimeXML @@ -170,14 +179,14 @@ instance Produces FindPetsByTags MimeJSON -- *** getPetById -- | @GET \/pet\/{petId}@ --- +-- -- Find pet by ID --- +-- -- Returns a single pet --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getPetById +-- +getPetById :: Accept accept -- ^ request accept ('MimeType') -> PetId -- ^ "petId" - ID of pet to return -> OpenAPIPetstoreRequest GetPetById MimeNoContent Pet accept @@ -185,7 +194,7 @@ getPetById _ (PetId petId) = _mkRequest "GET" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetPetById +data GetPetById -- | @application/xml@ instance Produces GetPetById MimeXML @@ -196,12 +205,12 @@ instance Produces GetPetById MimeJSON -- *** updatePet -- | @PUT \/pet@ --- +-- -- Update an existing pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePet +-- +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 @@ -211,10 +220,10 @@ updatePet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data UpdatePet +data UpdatePet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam UpdatePet Pet +instance HasBodyParam UpdatePet Pet -- | @application/xml@ instance Consumes UpdatePet MimeXML @@ -227,12 +236,12 @@ instance Produces UpdatePet MimeNoContent -- *** updatePetWithForm -- | @POST \/pet\/{petId}@ --- +-- -- Updates a pet in the store with form data --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePetWithForm +-- +updatePetWithForm :: (Consumes UpdatePetWithForm MimeFormUrlEncoded) => PetId -- ^ "petId" - ID of pet that needs to be updated -> OpenAPIPetstoreRequest UpdatePetWithForm MimeFormUrlEncoded NoContent MimeNoContent @@ -240,7 +249,7 @@ updatePetWithForm (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UpdatePetWithForm +data UpdatePetWithForm -- | /Optional Param/ "name" - Updated name of the pet instance HasOptionalParam UpdatePetWithForm Name2 where @@ -261,12 +270,12 @@ instance Produces UpdatePetWithForm MimeNoContent -- *** uploadFile -- | @POST \/pet\/{petId}\/uploadImage@ --- +-- -- uploads an image --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFile +-- +uploadFile :: (Consumes UploadFile MimeMultipartFormData) => PetId -- ^ "petId" - ID of pet to update -> OpenAPIPetstoreRequest UploadFile MimeMultipartFormData ApiResponse MimeJSON @@ -274,7 +283,7 @@ uploadFile (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UploadFile +data UploadFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFile AdditionalMetadata where @@ -296,12 +305,12 @@ instance Produces UploadFile MimeJSON -- *** uploadFileWithRequiredFile -- | @POST \/fake\/{petId}\/uploadImageWithRequiredFile@ --- +-- -- uploads an image (required) --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFileWithRequiredFile +-- +uploadFileWithRequiredFile :: (Consumes UploadFileWithRequiredFile MimeMultipartFormData) => RequiredFile -- ^ "requiredFile" - file to upload -> PetId -- ^ "petId" - ID of pet to update @@ -311,7 +320,7 @@ uploadFileWithRequiredFile (RequiredFile requiredFile) (PetId petId) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `_addMultiFormPart` NH.partFileSource "requiredFile" requiredFile -data UploadFileWithRequiredFile +data UploadFileWithRequiredFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFileWithRequiredFile AdditionalMetadata where diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index 12bcd0bc94a..ef549c44c80 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.Store -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,18 +69,18 @@ import qualified Prelude as P -- *** 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 +-- +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 +data DeleteOrder instance Produces DeleteOrder MimeNoContent @@ -79,20 +88,20 @@ instance Produces DeleteOrder MimeNoContent -- *** getInventory -- | @GET \/store\/inventory@ --- +-- -- Returns pet inventories by status --- +-- -- Returns a map of status codes to quantities --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getInventory +-- +getInventory :: OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON getInventory = _mkRequest "GET" ["/store/inventory"] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetInventory +data GetInventory -- | @application/json@ instance Produces GetInventory MimeJSON @@ -101,19 +110,19 @@ 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 +-- +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 +data GetOrderById -- | @application/xml@ instance Produces GetOrderById MimeXML @@ -124,10 +133,10 @@ instance Produces GetOrderById MimeJSON -- *** placeOrder -- | @POST \/store\/order@ --- +-- -- Place an order for a pet --- -placeOrder +-- +placeOrder :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -137,10 +146,10 @@ placeOrder _ _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order -data PlaceOrder +data PlaceOrder -- | /Body Param/ "Order" - order placed for purchasing the pet -instance HasBodyParam PlaceOrder Order +instance HasBodyParam PlaceOrder Order -- | @application/xml@ instance Produces PlaceOrder MimeXML diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index efc6ad66f31..87e0724d02f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -12,45 +12,54 @@ Module : OpenAPIPetstore.API.User -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 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 (TypeRep, Typeable, + 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 +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 (Applicative, Bool (..), + Char, Double, FilePath, + Float, Functor, Int, + Integer, Maybe (..), + Monad, String, fmap, + maybe, mempty, pure, + undefined, ($), (.), + (/=), (<$>), (<*>), + (==), (>>=)) +import qualified Prelude as P -- * Operations @@ -60,12 +69,12 @@ import qualified Prelude as P -- *** createUser -- | @POST \/user@ --- +-- -- Create user --- +-- -- This can only be done by the logged in user. --- -createUser +-- +createUser :: (Consumes CreateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Created user object @@ -74,10 +83,10 @@ createUser _ user = _mkRequest "POST" ["/user"] `setBodyParam` user -data CreateUser +data CreateUser -- | /Body Param/ "User" - Created user object -instance HasBodyParam CreateUser User +instance HasBodyParam CreateUser User instance Produces CreateUser MimeNoContent @@ -85,10 +94,10 @@ instance Produces CreateUser MimeNoContent -- *** createUsersWithArrayInput -- | @POST \/user\/createWithArray@ --- +-- -- Creates list of users with given input array --- -createUsersWithArrayInput +-- +createUsersWithArrayInput :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -97,10 +106,10 @@ createUsersWithArrayInput _ user = _mkRequest "POST" ["/user/createWithArray"] `setBodyParam` user -data CreateUsersWithArrayInput +data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithArrayInput User2 +instance HasBodyParam CreateUsersWithArrayInput User2 instance Produces CreateUsersWithArrayInput MimeNoContent @@ -108,10 +117,10 @@ instance Produces CreateUsersWithArrayInput MimeNoContent -- *** createUsersWithListInput -- | @POST \/user\/createWithList@ --- +-- -- Creates list of users with given input array --- -createUsersWithListInput +-- +createUsersWithListInput :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -120,10 +129,10 @@ createUsersWithListInput _ user = _mkRequest "POST" ["/user/createWithList"] `setBodyParam` user -data CreateUsersWithListInput +data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithListInput User2 +instance HasBodyParam CreateUsersWithListInput User2 instance Produces CreateUsersWithListInput MimeNoContent @@ -131,18 +140,18 @@ instance Produces CreateUsersWithListInput MimeNoContent -- *** deleteUser -- | @DELETE \/user\/{username}@ --- +-- -- Delete user --- +-- -- This can only be done by the logged in user. --- -deleteUser +-- +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 +data DeleteUser instance Produces DeleteUser MimeNoContent @@ -150,17 +159,17 @@ instance Produces DeleteUser MimeNoContent -- *** getUserByName -- | @GET \/user\/{username}@ --- +-- -- Get user by user name --- -getUserByName +-- +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 +data GetUserByName -- | @application/xml@ instance Produces GetUserByName MimeXML @@ -171,10 +180,10 @@ instance Produces GetUserByName MimeJSON -- *** loginUser -- | @GET \/user\/login@ --- +-- -- Logs user into the system --- -loginUser +-- +loginUser :: Accept accept -- ^ request accept ('MimeType') -> Username -- ^ "username" - The user name for login -> Password -- ^ "password" - The password for login in clear text @@ -184,7 +193,7 @@ loginUser _ (Username username) (Password password) = `setQuery` toQuery ("username", Just username) `setQuery` toQuery ("password", Just password) -data LoginUser +data LoginUser -- | @application/xml@ instance Produces LoginUser MimeXML @@ -195,15 +204,15 @@ instance Produces LoginUser MimeJSON -- *** logoutUser -- | @GET \/user\/logout@ --- +-- -- Logs out current logged in user session --- -logoutUser +-- +logoutUser :: OpenAPIPetstoreRequest LogoutUser MimeNoContent NoContent MimeNoContent logoutUser = _mkRequest "GET" ["/user/logout"] -data LogoutUser +data LogoutUser instance Produces LogoutUser MimeNoContent @@ -211,12 +220,12 @@ instance Produces LogoutUser MimeNoContent -- *** updateUser -- | @PUT \/user\/{username}@ --- +-- -- Updated user --- +-- -- This can only be done by the logged in user. --- -updateUser +-- +updateUser :: (Consumes UpdateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Updated user object @@ -226,10 +235,10 @@ updateUser _ user (Username username) = _mkRequest "PUT" ["/user/",toPath username] `setBodyParam` user -data UpdateUser +data UpdateUser -- | /Body Param/ "User" - Updated user object -instance HasBodyParam UpdateUser User +instance HasBodyParam UpdateUser User instance Produces UpdateUser MimeNoContent diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs index 31cd12f7ada..d8e0caf8a98 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs @@ -12,42 +12,42 @@ Module : OpenAPIPetstore.Client -} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RecordWildCards #-} {-# 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 OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes + +import qualified Control.Exception.Safe as E +import qualified Control.Monad as P +import qualified Control.Monad.IO.Class 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 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(..)) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import GHC.Exts (IsString (..)) -- * Dispatch @@ -68,16 +68,16 @@ dispatchLbs manager config request = do -- | 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 + 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 + mimeError :: String -- ^ unrender/parser error + , mimeErrorResponse :: NH.Response BCL.ByteString -- ^ http response } deriving (Eq, Show) -- | send a request returning the 'MimeResult' @@ -153,7 +153,7 @@ dispatchInitUnsafe manager config (InitRequest req) = do "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> (case NH.requestBody req of NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) - _ -> "<RequestBody>") + _ -> "<RequestBody>") responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus responseLogMsg res = "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" @@ -171,7 +171,7 @@ _toInitRequest => OpenAPIPetstoreConfig -- ^ config -> OpenAPIPetstoreRequest req contentType res accept -- ^ request -> IO (InitRequest req contentType res accept) -- ^ initialized request -_toInitRequest config req0 = +_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 @@ -202,7 +202,7 @@ modifyInitRequest (InitRequest req) f = InitRequest (f req) 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 +-- ** Logging -- | Run a block using the configured logger instance runConfigLog diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs index 6fbc9899d34..f01a5542a69 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs @@ -12,70 +12,76 @@ Module : OpenAPIPetstore.Core -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# 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 OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes + +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, TypeRep, + Typeable, 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) +import qualified Network.HTTP.Types as NH +import qualified Prelude as P +import qualified Text.Printf as T +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Foldable (foldlM) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import Prelude (Bool (..), Char, + Functor, IO, Maybe (..), + Monad, String, fmap, + mempty, pure, return, + show, ($), (.), (<$>), + (<*>)) -- * 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 + { 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 } @@ -107,7 +113,7 @@ newConfig = do , configLogContext = logCxt , configAuthMethods = [] , configValidateAuthMethods = True - } + } -- | updates config use AuthMethod on matching requests addAuthMethod :: AuthMethod auth => OpenAPIPetstoreConfig -> auth -> OpenAPIPetstoreConfig @@ -129,7 +135,7 @@ withStderrLogging p = do -- | updates the config to disable logging withNoLogging :: OpenAPIPetstoreConfig -> OpenAPIPetstoreConfig withNoLogging p = p { configLogExecWithContext = runNullLogExec} - + -- * OpenAPIPetstoreRequest -- | Represents a request. @@ -141,9 +147,9 @@ withNoLogging p = p { configLogExecWithContext = runNullLogExec} -- * 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 + { 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) @@ -196,9 +202,9 @@ infixl 2 -&- -- | Request Params data Params = Params - { paramsQuery :: NH.Query + { paramsQuery :: NH.Query , paramsHeaders :: NH.RequestHeaders - , paramsBody :: ParamBody + , paramsBody :: ParamBody } deriving (P.Show) @@ -228,7 +234,7 @@ data ParamBody -- ** OpenAPIPetstoreRequest Utils -_mkRequest :: NH.Method -- ^ Method +_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 [] @@ -253,18 +259,18 @@ removeHeader req header = _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)] + 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)] + 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 = +setQuery req query = req & L.over (rParamsL . paramsQueryL) @@ -273,25 +279,25 @@ setQuery req query = cifst = CI.mk . P.fst addForm :: OpenAPIPetstoreRequest req contentType res accept -> WH.Form -> OpenAPIPetstoreRequest req contentType res accept -addForm req newform = +addForm req newform = let form = case paramsBody (rParams req) of ParamBodyFormUrlEncoded _form -> _form - _ -> mempty + _ -> 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 = +_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 = +_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 = +_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 @@ -347,10 +353,10 @@ _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 '|') + CommaSeparated -> go (one ',') + SpaceSeparated -> go (one ' ') + TabSeparated -> go (one '\t') + PipeSeparated -> go (one '|') MultiParamArray -> expandList where go sep = @@ -360,7 +366,7 @@ _toCollA' c encode one xs = case c of {-# INLINE go #-} {-# INLINE expandList #-} {-# INLINE combine #-} - + -- * AuthMethods -- | Provides a method to apply auth methods to requests @@ -391,7 +397,7 @@ _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) @@ -399,7 +405,7 @@ _omitNulls :: [(Text, A.Value)] -> A.Value _omitNulls = A.object . P.filter notNull where notNull (_, A.Null) = False - notNull _ = True + notNull _ = True -- | Encodes fields using WH.toQueryParam _toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) @@ -408,13 +414,13 @@ _toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x -- | Collapse (Just "") to Nothing _emptyToNothing :: Maybe String -> Maybe String _emptyToNothing (Just "") = Nothing -_emptyToNothing x = x +_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 +_memptyToNothing x = x {-# INLINE _memptyToNothing #-} -- * DateTime Formatting @@ -485,7 +491,7 @@ _showDate = -- * Byte/Binary Formatting - + -- | base64 encoded characters newtype ByteArray = ByteArray { unByteArray :: BL.ByteString } deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index 8e3d4ac772b..cd76f7789db 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -13,23 +13,23 @@ Module : OpenAPIPetstore.Logging Katip Logging functions -} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} +{-# 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.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 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 Data.Text (Text) +import GHC.Exts (IsString (..)) -import qualified Katip as LG +import qualified Katip as LG -- * Type Aliases (for compatibility) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs index 0da4b6310f0..e9bfbd8babb 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs @@ -12,35 +12,38 @@ Module : OpenAPIPetstore.MimeTypes -} -{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# 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 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 +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 (Bool (..), Char, Double, FilePath, + Float, Int, Integer, Maybe (..), + String, fmap, mempty, undefined, + ($), (.), (<$>), (<*>)) +import qualified Prelude as P -- * ContentType MimeType @@ -82,13 +85,13 @@ class P.Typeable mtype => MimeType mtype where mimeTypes :: P.Proxy mtype -> [ME.MediaType] mimeTypes p = case mimeType p of - Just x -> [x] + Just x -> [x] Nothing -> [] mimeType :: P.Proxy mtype -> Maybe ME.MediaType mimeType p = case mimeTypes p of - [] -> Nothing + [] -> Nothing (x:_) -> Just x mimeType' :: mtype -> Maybe ME.MediaType diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index dcbcef0b83f..699e857586c 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -12,54 +12,60 @@ Module : OpenAPIPetstore.Model -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.Model where -import OpenAPIPetstore.Core -import OpenAPIPetstore.MimeTypes - -import Data.Aeson ((.:),(.:!),(.:?),(.=)) - -import qualified Control.Arrow as P (left) -import qualified Data.Aeson as A -import qualified Data.ByteString as B -import qualified Data.ByteString.Base64 as B64 -import qualified Data.ByteString.Char8 as BC -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.HashMap.Lazy as HM -import qualified Data.Map as Map -import qualified Data.Maybe as P -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Time as TI -import qualified Lens.Micro as L -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Function ((&)) -import Data.Monoid ((<>)) -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.Core +import OpenAPIPetstore.MimeTypes + +import Data.Aeson ((.:), (.:!), (.:?), (.=)) + +import qualified Control.Arrow as P (left) +import qualified Data.Aeson as A +import qualified Data.ByteString as B +import qualified Data.ByteString.Base64 as B64 +import qualified Data.ByteString.Char8 as BC +import qualified Data.ByteString.Lazy as BL +import qualified Data.Data as P (TypeRep, Typeable, typeOf, + typeRep) +import qualified Data.Foldable as P +import qualified Data.HashMap.Lazy as HM +import qualified Data.Map as Map +import qualified Data.Maybe as P +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import qualified Data.Time as TI +import qualified Lens.Micro as L +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import Prelude (Applicative, Bool (..), Char, + Double, FilePath, Float, Functor, + Int, Integer, Maybe (..), Monad, + String, fmap, maybe, mempty, pure, + undefined, ($), (.), (/=), (<$>), + (<*>), (=<<), (>>=)) + +import qualified Prelude as P @@ -231,7 +237,7 @@ mkAdditionalPropertiesClass = -- | Animal data Animal = Animal { animalClassName :: !(Text) -- ^ /Required/ "className" - , animalColor :: !(Maybe Text) -- ^ "color" + , animalColor :: !(Maybe Text) -- ^ "color" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Animal @@ -252,7 +258,7 @@ instance A.ToJSON Animal where -- | Construct a value of type 'Animal' (by applying it's required fields, if any) mkAnimal - :: Text -- ^ 'animalClassName' + :: Text -- ^ 'animalClassName' -> Animal mkAnimal animalClassName = Animal @@ -263,20 +269,20 @@ mkAnimal animalClassName = -- ** AnimalFarm -- | AnimalFarm data AnimalFarm = AnimalFarm - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON AnimalFarm instance A.FromJSON AnimalFarm where parseJSON = A.withObject "AnimalFarm" $ \o -> pure AnimalFarm - + -- | ToJSON AnimalFarm instance A.ToJSON AnimalFarm where toJSON AnimalFarm = _omitNulls - [ + [ ] @@ -285,14 +291,14 @@ mkAnimalFarm :: AnimalFarm mkAnimalFarm = AnimalFarm - { + { } -- ** ApiResponse -- | ApiResponse data ApiResponse = ApiResponse - { apiResponseCode :: !(Maybe Int) -- ^ "code" - , apiResponseType :: !(Maybe Text) -- ^ "type" + { apiResponseCode :: !(Maybe Int) -- ^ "code" + , apiResponseType :: !(Maybe Text) -- ^ "type" , apiResponseMessage :: !(Maybe Text) -- ^ "message" } deriving (P.Show, P.Eq, P.Typeable) @@ -383,9 +389,9 @@ mkArrayOfNumberOnly = -- ** ArrayTest -- | ArrayTest data ArrayTest = ArrayTest - { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" + { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" - , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" + , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ArrayTest @@ -419,12 +425,12 @@ mkArrayTest = -- ** Capitalization -- | Capitalization data Capitalization = Capitalization - { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" - , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" - , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" - , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" + { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" + , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" + , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" + , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" - , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet + , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Capitalization @@ -468,8 +474,8 @@ mkCapitalization = -- | Cat data Cat = Cat { catClassName :: !(Text) -- ^ /Required/ "className" - , catColor :: !(Maybe Text) -- ^ "color" - , catDeclawed :: !(Maybe Bool) -- ^ "declawed" + , catColor :: !(Maybe Text) -- ^ "color" + , catDeclawed :: !(Maybe Bool) -- ^ "declawed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Cat @@ -492,7 +498,7 @@ instance A.ToJSON Cat where -- | Construct a value of type 'Cat' (by applying it's required fields, if any) mkCat - :: Text -- ^ 'catClassName' + :: Text -- ^ 'catClassName' -> Cat mkCat catClassName = Cat @@ -504,7 +510,7 @@ mkCat catClassName = -- ** Category -- | Category data Category = Category - { categoryId :: !(Maybe Integer) -- ^ "id" + { categoryId :: !(Maybe Integer) -- ^ "id" , categoryName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -594,8 +600,8 @@ mkClient = -- | Dog data Dog = Dog { dogClassName :: !(Text) -- ^ /Required/ "className" - , dogColor :: !(Maybe Text) -- ^ "color" - , dogBreed :: !(Maybe Text) -- ^ "breed" + , dogColor :: !(Maybe Text) -- ^ "color" + , dogBreed :: !(Maybe Text) -- ^ "breed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Dog @@ -618,7 +624,7 @@ instance A.ToJSON Dog where -- | Construct a value of type 'Dog' (by applying it's required fields, if any) mkDog - :: Text -- ^ 'dogClassName' + :: Text -- ^ 'dogClassName' -> Dog mkDog dogClassName = Dog @@ -631,7 +637,7 @@ mkDog dogClassName = -- | EnumArrays data EnumArrays = EnumArrays { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumArrays @@ -662,11 +668,11 @@ mkEnumArrays = -- ** EnumTest -- | EnumTest data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" , enumTestEnumStringRequired :: !(E'EnumString) -- ^ /Required/ "enum_string_required" - , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" - , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" + , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumTest @@ -693,7 +699,7 @@ instance A.ToJSON EnumTest where -- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) mkEnumTest - :: E'EnumString -- ^ 'enumTestEnumStringRequired' + :: E'EnumString -- ^ 'enumTestEnumStringRequired' -> EnumTest mkEnumTest enumTestEnumStringRequired = EnumTest @@ -736,7 +742,7 @@ mkFile = -- ** FileSchemaTestClass -- | FileSchemaTestClass data FileSchemaTestClass = FileSchemaTestClass - { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" + { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" , fileSchemaTestClassFiles :: !(Maybe [File]) -- ^ "files" } deriving (P.Show, P.Eq, P.Typeable) @@ -768,18 +774,18 @@ mkFileSchemaTestClass = -- ** FormatTest -- | FormatTest data FormatTest = FormatTest - { formatTestInteger :: !(Maybe Int) -- ^ "integer" - , formatTestInt32 :: !(Maybe Int) -- ^ "int32" - , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" - , formatTestNumber :: !(Double) -- ^ /Required/ "number" - , formatTestFloat :: !(Maybe Float) -- ^ "float" - , formatTestDouble :: !(Maybe Double) -- ^ "double" - , formatTestString :: !(Maybe Text) -- ^ "string" - , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" - , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" - , formatTestDate :: !(Date) -- ^ /Required/ "date" + { formatTestInteger :: !(Maybe Int) -- ^ "integer" + , formatTestInt32 :: !(Maybe Int) -- ^ "int32" + , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" + , formatTestNumber :: !(Double) -- ^ /Required/ "number" + , formatTestFloat :: !(Maybe Float) -- ^ "float" + , formatTestDouble :: !(Maybe Double) -- ^ "double" + , formatTestString :: !(Maybe Text) -- ^ "string" + , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" + , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" + , formatTestDate :: !(Date) -- ^ /Required/ "date" , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , formatTestUuid :: !(Maybe Text) -- ^ "uuid" + , formatTestUuid :: !(Maybe Text) -- ^ "uuid" , formatTestPassword :: !(Text) -- ^ /Required/ "password" } deriving (P.Show, P.Eq, P.Typeable) @@ -823,10 +829,10 @@ instance A.ToJSON FormatTest where -- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) mkFormatTest - :: Double -- ^ 'formatTestNumber' - -> ByteArray -- ^ 'formatTestByte' - -> Date -- ^ 'formatTestDate' - -> Text -- ^ 'formatTestPassword' + :: Double -- ^ 'formatTestNumber' + -> ByteArray -- ^ 'formatTestByte' + -> Date -- ^ 'formatTestDate' + -> Text -- ^ 'formatTestPassword' -> FormatTest mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = FormatTest @@ -880,10 +886,10 @@ mkHasOnlyReadOnly = -- ** MapTest -- | MapTest data MapTest = MapTest - { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" + { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" - , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" - , mapTestIndirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "indirect_map" + , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" + , mapTestIndirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "indirect_map" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON MapTest @@ -957,7 +963,7 @@ mkMixedPropertiesAndAdditionalPropertiesClass = -- | Model200Response -- Model for testing model name starting with number data Model200Response = Model200Response - { model200ResponseName :: !(Maybe Int) -- ^ "name" + { model200ResponseName :: !(Maybe Int) -- ^ "name" , model200ResponseClass :: !(Maybe Text) -- ^ "class" } deriving (P.Show, P.Eq, P.Typeable) @@ -1047,9 +1053,9 @@ mkModelReturn = -- | Name -- Model for testing model name same as property name data Name = Name - { nameName :: !(Int) -- ^ /Required/ "name" + { nameName :: !(Int) -- ^ /Required/ "name" , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" - , nameProperty :: !(Maybe Text) -- ^ "property" + , nameProperty :: !(Maybe Text) -- ^ "property" , name123number :: !(Maybe Int) -- ^ "123Number" } deriving (P.Show, P.Eq, P.Typeable) @@ -1075,7 +1081,7 @@ instance A.ToJSON Name where -- | Construct a value of type 'Name' (by applying it's required fields, if any) mkName - :: Int -- ^ 'nameName' + :: Int -- ^ 'nameName' -> Name mkName nameName = Name @@ -1116,11 +1122,11 @@ mkNumberOnly = -- ** Order -- | Order data Order = Order - { orderId :: !(Maybe Integer) -- ^ "id" - , orderPetId :: !(Maybe Integer) -- ^ "petId" + { orderId :: !(Maybe Integer) -- ^ "id" + , orderPetId :: !(Maybe Integer) -- ^ "petId" , orderQuantity :: !(Maybe Int) -- ^ "quantity" , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status , orderComplete :: !(Maybe Bool) -- ^ "complete" } deriving (P.Show, P.Eq, P.Typeable) @@ -1164,8 +1170,8 @@ mkOrder = -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" + { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" , outerCompositeMyBoolean :: !(Maybe Bool) -- ^ "my_boolean" } deriving (P.Show, P.Eq, P.Typeable) @@ -1200,12 +1206,12 @@ mkOuterComposite = -- ** Pet -- | Pet data Pet = Pet - { petId :: !(Maybe Integer) -- ^ "id" - , petCategory :: !(Maybe Category) -- ^ "category" - , petName :: !(Text) -- ^ /Required/ "name" + { petId :: !(Maybe Integer) -- ^ "id" + , petCategory :: !(Maybe Category) -- ^ "category" + , petName :: !(Text) -- ^ /Required/ "name" , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" - , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store + , petTags :: !(Maybe [Tag]) -- ^ "tags" + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Pet @@ -1234,8 +1240,8 @@ instance A.ToJSON Pet where -- | Construct a value of type 'Pet' (by applying it's required fields, if any) mkPet - :: Text -- ^ 'petName' - -> [Text] -- ^ 'petPhotoUrls' + :: Text -- ^ 'petName' + -> [Text] -- ^ 'petPhotoUrls' -> Pet mkPet petName petPhotoUrls = Pet @@ -1310,20 +1316,20 @@ mkSpecialModelName = -- ** StringBooleanMap -- | StringBooleanMap data StringBooleanMap = StringBooleanMap - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON StringBooleanMap instance A.FromJSON StringBooleanMap where parseJSON = A.withObject "StringBooleanMap" $ \o -> pure StringBooleanMap - + -- | ToJSON StringBooleanMap instance A.ToJSON StringBooleanMap where toJSON StringBooleanMap = _omitNulls - [ + [ ] @@ -1332,13 +1338,13 @@ mkStringBooleanMap :: StringBooleanMap mkStringBooleanMap = StringBooleanMap - { + { } -- ** Tag -- | Tag data Tag = Tag - { tagId :: !(Maybe Integer) -- ^ "id" + { tagId :: !(Maybe Integer) -- ^ "id" , tagName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -1370,13 +1376,13 @@ mkTag = -- ** User -- | User data User = User - { userId :: !(Maybe Integer) -- ^ "id" - , userUsername :: !(Maybe Text) -- ^ "username" - , userFirstName :: !(Maybe Text) -- ^ "firstName" - , userLastName :: !(Maybe Text) -- ^ "lastName" - , userEmail :: !(Maybe Text) -- ^ "email" - , userPassword :: !(Maybe Text) -- ^ "password" - , userPhone :: !(Maybe Text) -- ^ "phone" + { userId :: !(Maybe Integer) -- ^ "id" + , userUsername :: !(Maybe Text) -- ^ "username" + , userFirstName :: !(Maybe Text) -- ^ "firstName" + , userLastName :: !(Maybe Text) -- ^ "lastName" + , userEmail :: !(Maybe Text) -- ^ "email" + , userPassword :: !(Maybe Text) -- ^ "password" + , userPhone :: !(Maybe Text) -- ^ "phone" , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status } deriving (P.Show, P.Eq, P.Typeable) @@ -1457,7 +1463,7 @@ toE'ArrayEnum = \case -- ** E'EnumFormString --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString = E'EnumFormString'_abc -- ^ @"_abc"@ @@ -1688,7 +1694,7 @@ toE'JustSymbol = \case -- ** E'Status --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Order Status data E'Status = E'Status'Placed -- ^ @"placed"@ @@ -1720,7 +1726,7 @@ toE'Status = \case -- ** E'Status2 --- | Enum of 'Text' . +-- | Enum of 'Text' . -- pet status in the store data E'Status2 = E'Status2'Available -- ^ @"available"@ @@ -1863,7 +1869,7 @@ instance AuthMethod AuthOAuthPetstoreAuth where applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index a093ca73ca0..a6c3e12b2cd 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -12,28 +12,32 @@ Module : OpenAPIPetstore.Lens -} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} +{-# 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 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 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 Prelude (Applicative, Bool (..), Char, Double, + FilePath, Float, Functor, Int, Integer, + Maybe (..), Monad, String, fmap, maybe, + mempty, pure, undefined, ($), (.), + (<$>), (<*>), (=<<)) +import qualified Prelude as P -import OpenAPIPetstore.Model -import OpenAPIPetstore.Core +import OpenAPIPetstore.Core +import OpenAPIPetstore.Model -- * AdditionalPropertiesClass diff --git a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs index 88ca2110a06..a217b69021b 100644 --- a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs +++ b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs @@ -1,15 +1,15 @@ {-# LANGUAGE DefaultSignatures #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module ApproxEq where -import Data.Text (Text) -import Data.Time.Clock -import Test.QuickCheck -import GHC.Generics as G +import Data.Text (Text) +import Data.Time.Clock +import GHC.Generics as G +import Test.QuickCheck (==~) :: (ApproxEq a, Show a) @@ -26,7 +26,7 @@ instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where gApproxEq (L1 a) (L1 b) = gApproxEq a b gApproxEq (R1 a) (R1 b) = gApproxEq a b - gApproxEq _ _ = False + gApproxEq _ _ = False instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index dc1a79b93dd..4913699524d 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -2,23 +2,23 @@ module Instances where -import OpenAPIPetstore.Model -import OpenAPIPetstore.Core +import OpenAPIPetstore.Core +import OpenAPIPetstore.Model -import qualified Data.Aeson as A -import qualified Data.ByteString.Lazy as BL -import qualified Data.HashMap.Strict as HM -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Time as TI -import qualified Data.Vector as V +import qualified Data.Aeson as A +import qualified Data.ByteString.Lazy as BL +import qualified Data.HashMap.Strict as HM +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Time as TI +import qualified Data.Vector as V -import Control.Monad -import Data.Char (isSpace) -import Data.List (sort) -import Test.QuickCheck +import Control.Monad +import Data.Char (isSpace) +import Data.List (sort) +import Test.QuickCheck -import ApproxEq +import ApproxEq instance Arbitrary T.Text where arbitrary = T.pack <$> arbitrary @@ -71,7 +71,7 @@ instance Arbitrary A.Value where sizedObject n = liftM (A.object . map mapF) $ replicateM n $ (,) <$> (arbitrary :: Gen String) <*> simpleAndArrays - + -- | Checks if a given list has no duplicates in _O(n log n)_. hasNoDups :: (Ord a) @@ -88,48 +88,48 @@ instance ApproxEq TI.Day where (=~) = (==) -- * Models - + instance Arbitrary AdditionalPropertiesClass where arbitrary = AdditionalPropertiesClass <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) - + instance Arbitrary Animal where arbitrary = Animal <$> arbitrary -- animalClassName :: Text <*> arbitrary -- animalColor :: Maybe Text - + instance Arbitrary AnimalFarm where arbitrary = - + pure AnimalFarm - + instance Arbitrary ApiResponse where arbitrary = ApiResponse <$> arbitrary -- apiResponseCode :: Maybe Int <*> arbitrary -- apiResponseType :: Maybe Text <*> arbitrary -- apiResponseMessage :: Maybe Text - + instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = ArrayOfArrayOfNumberOnly <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] - + instance Arbitrary ArrayOfNumberOnly where arbitrary = ArrayOfNumberOnly <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] - + instance Arbitrary ArrayTest where arbitrary = ArrayTest <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] - + instance Arbitrary Capitalization where arbitrary = Capitalization @@ -139,43 +139,43 @@ instance Arbitrary Capitalization where <*> arbitrary -- capitalizationCapitalSnake :: Maybe Text <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text <*> arbitrary -- capitalizationAttName :: Maybe Text - + instance Arbitrary Cat where arbitrary = Cat <$> arbitrary -- catClassName :: Text <*> arbitrary -- catColor :: Maybe Text <*> arbitrary -- catDeclawed :: Maybe Bool - + instance Arbitrary Category where arbitrary = Category <$> arbitrary -- categoryId :: Maybe Integer <*> arbitrary -- categoryName :: Maybe Text - + instance Arbitrary ClassModel where arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text - + instance Arbitrary Client where arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text - + instance Arbitrary Dog where arbitrary = Dog <$> arbitrary -- dogClassName :: Text <*> arbitrary -- dogColor :: Maybe Text <*> arbitrary -- dogBreed :: Maybe Text - + instance Arbitrary EnumArrays where arbitrary = EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] - + instance Arbitrary EnumTest where arbitrary = EnumTest @@ -184,18 +184,18 @@ instance Arbitrary EnumTest where <*> arbitrary -- enumTestEnumInteger :: Maybe Int <*> arbitrary -- enumTestEnumNumber :: Maybe Double <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum - + instance Arbitrary File where arbitrary = File <$> arbitrary -- fileSourceUri :: Maybe Text - + instance Arbitrary FileSchemaTestClass where arbitrary = FileSchemaTestClass <$> arbitrary -- fileSchemaTestClassFile :: Maybe File <*> arbitrary -- fileSchemaTestClassFiles :: Maybe [File] - + instance Arbitrary FormatTest where arbitrary = FormatTest @@ -212,13 +212,13 @@ instance Arbitrary FormatTest where <*> arbitrary -- formatTestDateTime :: Maybe DateTime <*> arbitrary -- formatTestUuid :: Maybe Text <*> arbitrary -- formatTestPassword :: Text - + instance Arbitrary HasOnlyReadOnly where arbitrary = HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text - + instance Arbitrary MapTest where arbitrary = MapTest @@ -226,30 +226,30 @@ instance Arbitrary MapTest where <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) <*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) <*> arbitrary -- mapTestIndirectMap :: Maybe (Map.Map String Bool) - + instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = MixedPropertiesAndAdditionalPropertiesClass <$> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) - + instance Arbitrary Model200Response where arbitrary = Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int <*> arbitrary -- model200ResponseClass :: Maybe Text - + instance Arbitrary ModelList where arbitrary = ModelList <$> arbitrary -- modelList123list :: Maybe Text - + instance Arbitrary ModelReturn where arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int - + instance Arbitrary Name where arbitrary = Name @@ -257,12 +257,12 @@ instance Arbitrary Name where <*> arbitrary -- nameSnakeCase :: Maybe Int <*> arbitrary -- nameProperty :: Maybe Text <*> arbitrary -- name123number :: Maybe Int - + instance Arbitrary NumberOnly where arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double - + instance Arbitrary Order where arbitrary = Order @@ -272,14 +272,14 @@ instance Arbitrary Order where <*> arbitrary -- orderShipDate :: Maybe DateTime <*> arbitrary -- orderStatus :: Maybe Text <*> arbitrary -- orderComplete :: Maybe Bool - + instance Arbitrary OuterComposite where arbitrary = OuterComposite <$> arbitrary -- outerCompositeMyNumber :: Maybe Double <*> arbitrary -- outerCompositeMyString :: Maybe Text <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool - + instance Arbitrary Pet where arbitrary = Pet @@ -289,29 +289,29 @@ instance Arbitrary Pet where <*> arbitrary -- petPhotoUrls :: [Text] <*> arbitrary -- petTags :: Maybe [Tag] <*> arbitrary -- petStatus :: Maybe Text - + instance Arbitrary ReadOnlyFirst where arbitrary = ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text <*> arbitrary -- readOnlyFirstBaz :: Maybe Text - + instance Arbitrary SpecialModelName where arbitrary = SpecialModelName <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer - + instance Arbitrary StringBooleanMap where arbitrary = - + pure StringBooleanMap - + instance Arbitrary Tag where arbitrary = Tag <$> arbitrary -- tagId :: Maybe Integer <*> arbitrary -- tagName :: Maybe Text - + instance Arbitrary User where arbitrary = User @@ -323,7 +323,7 @@ instance Arbitrary User where <*> arbitrary -- userPassword :: Maybe Text <*> arbitrary -- userPhone :: Maybe Text <*> arbitrary -- userUserStatus :: Maybe Int - + diff --git a/samples/client/petstore/haskell-http-client/tests/PropMime.hs b/samples/client/petstore/haskell-http-client/tests/PropMime.hs index c5a78129777..2f64db78fe4 100644 --- a/samples/client/petstore/haskell-http-client/tests/PropMime.hs +++ b/samples/client/petstore/haskell-http-client/tests/PropMime.hs @@ -1,23 +1,23 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ConstraintKinds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module PropMime where -import Data.Aeson -import Data.Aeson.Types (parseEither) -import Data.Monoid ((<>)) -import Data.Typeable (Proxy(..), typeOf, Typeable) +import Data.Aeson +import Data.Aeson.Types (parseEither) import qualified Data.ByteString.Lazy.Char8 as BL8 -import Test.Hspec -import Test.QuickCheck -import Test.QuickCheck.Property -import Test.Hspec.QuickCheck (prop) +import Data.Monoid ((<>)) +import Data.Typeable (Proxy (..), Typeable, typeOf) +import Test.Hspec +import Test.Hspec.QuickCheck (prop) +import Test.QuickCheck +import Test.QuickCheck.Property -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes -import ApproxEq +import ApproxEq -- * Type Aliases diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index ea6fff251e3..926f7b9927b 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -1,19 +1,19 @@ -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PartialTypeSignatures #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} module Main where -import Data.Typeable (Proxy(..)) -import Test.Hspec -import Test.Hspec.QuickCheck +import Data.Typeable (Proxy (..)) +import Test.Hspec +import Test.Hspec.QuickCheck -import PropMime -import Instances () +import Instances () +import PropMime -import OpenAPIPetstore.Model -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model main :: IO () main = @@ -56,4 +56,4 @@ main = propMimeEq MimeJSON (Proxy :: Proxy StringBooleanMap) propMimeEq MimeJSON (Proxy :: Proxy Tag) propMimeEq MimeJSON (Proxy :: Proxy User) - + -- GitLab From 8656e5669c7f921842037c8e59487613f3d8e6ea Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Fri, 21 Sep 2018 00:31:06 +0800 Subject: [PATCH 08/10] regenerate haskell samples without stylish-haskell --- .../petstore/haskell-http-client/Setup.hs | 2 +- .../lib/OpenAPIPetstore.hs | 14 +- .../lib/OpenAPIPetstore/API.hs | 12 +- .../lib/OpenAPIPetstore/API/AnotherFake.hs | 87 +++--- .../lib/OpenAPIPetstore/API/Fake.hs | 189 +++++++------ .../API/FakeClassnameTags123.hs | 89 +++---- .../lib/OpenAPIPetstore/API/Pet.hs | 175 ++++++------ .../lib/OpenAPIPetstore/API/Store.hs | 117 ++++---- .../lib/OpenAPIPetstore/API/User.hs | 153 +++++------ .../lib/OpenAPIPetstore/Client.hs | 72 ++--- .../lib/OpenAPIPetstore/Core.hs | 172 ++++++------ .../lib/OpenAPIPetstore/Logging.hs | 20 +- .../lib/OpenAPIPetstore/MimeTypes.hs | 53 ++-- .../lib/OpenAPIPetstore/Model.hs | 250 +++++++++--------- .../lib/OpenAPIPetstore/ModelLens.hs | 32 +-- .../haskell-http-client/tests/ApproxEq.hs | 14 +- .../haskell-http-client/tests/Instances.hs | 104 ++++---- .../haskell-http-client/tests/PropMime.hs | 24 +- .../haskell-http-client/tests/Test.hs | 22 +- 19 files changed, 764 insertions(+), 837 deletions(-) diff --git a/samples/client/petstore/haskell-http-client/Setup.hs b/samples/client/petstore/haskell-http-client/Setup.hs index 44671092b28..9a994af677b 100644 --- a/samples/client/petstore/haskell-http-client/Setup.hs +++ b/samples/client/petstore/haskell-http-client/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs index 0f416bdb5f7..83e607b1ad7 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore.hs @@ -22,10 +22,10 @@ module OpenAPIPetstore , 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 +import OpenAPIPetstore.API +import OpenAPIPetstore.Client +import OpenAPIPetstore.Core +import OpenAPIPetstore.Logging +import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.Model +import OpenAPIPetstore.ModelLens \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs index 5a97db25a66..7335a85067e 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API.hs @@ -21,9 +21,9 @@ module OpenAPIPetstore.API , 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 +import OpenAPIPetstore.API.AnotherFake +import OpenAPIPetstore.API.Fake +import OpenAPIPetstore.API.FakeClassnameTags123 +import OpenAPIPetstore.API.Pet +import OpenAPIPetstore.API.Store +import OpenAPIPetstore.API.User \ No newline at end of file diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs index 6d532ae69fc..aa3b293eb67 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/AnotherFake.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.AnotherFake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** op123testSpecialTags -- | @PATCH \/another-fake\/dummy@ --- +-- -- To test special tags --- +-- -- To test special tags and operation ID starting with number --- -op123testSpecialTags +-- +op123testSpecialTags :: (Consumes Op123testSpecialTags MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest Op123testSpecialTags MimeJSON Client MimeJSON @@ -82,10 +73,10 @@ op123testSpecialTags client = _mkRequest "PATCH" ["/another-fake/dummy"] `setBodyParam` client -data Op123testSpecialTags +data Op123testSpecialTags -- | /Body Param/ "Client" - client model -instance HasBodyParam Op123testSpecialTags Client +instance HasBodyParam Op123testSpecialTags Client -- | @application/json@ instance Consumes Op123testSpecialTags MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index f2e7f89c413..4d73209965f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Fake -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,10 +60,10 @@ import qualified Prelude as P -- *** fakeOuterBooleanSerialize -- | @POST \/fake\/outer\/boolean@ --- +-- -- Test serialization of outer boolean types --- -fakeOuterBooleanSerialize +-- +fakeOuterBooleanSerialize :: (Consumes FakeOuterBooleanSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -80,10 +71,10 @@ fakeOuterBooleanSerialize fakeOuterBooleanSerialize _ _ = _mkRequest "POST" ["/fake/outer/boolean"] -data FakeOuterBooleanSerialize +data FakeOuterBooleanSerialize -- | /Body Param/ "body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BodyBool +instance HasBodyParam FakeOuterBooleanSerialize BodyBool -- | @*/*@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype @@ -92,10 +83,10 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype -- *** fakeOuterCompositeSerialize -- | @POST \/fake\/outer\/composite@ --- +-- -- Test serialization of object with outer number type --- -fakeOuterCompositeSerialize +-- +fakeOuterCompositeSerialize :: (Consumes FakeOuterCompositeSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -103,10 +94,10 @@ fakeOuterCompositeSerialize fakeOuterCompositeSerialize _ _ = _mkRequest "POST" ["/fake/outer/composite"] -data FakeOuterCompositeSerialize +data FakeOuterCompositeSerialize -- | /Body Param/ "OuterComposite" - Input composite as post body -instance HasBodyParam FakeOuterCompositeSerialize OuterComposite +instance HasBodyParam FakeOuterCompositeSerialize OuterComposite -- | @*/*@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype @@ -115,10 +106,10 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype -- *** fakeOuterNumberSerialize -- | @POST \/fake\/outer\/number@ --- +-- -- Test serialization of outer number types --- -fakeOuterNumberSerialize +-- +fakeOuterNumberSerialize :: (Consumes FakeOuterNumberSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -126,10 +117,10 @@ fakeOuterNumberSerialize fakeOuterNumberSerialize _ _ = _mkRequest "POST" ["/fake/outer/number"] -data FakeOuterNumberSerialize +data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body -instance HasBodyParam FakeOuterNumberSerialize Body +instance HasBodyParam FakeOuterNumberSerialize Body -- | @*/*@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype @@ -138,10 +129,10 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype -- *** fakeOuterStringSerialize -- | @POST \/fake\/outer\/string@ --- +-- -- Test serialization of outer string types --- -fakeOuterStringSerialize +-- +fakeOuterStringSerialize :: (Consumes FakeOuterStringSerialize contentType) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -149,10 +140,10 @@ fakeOuterStringSerialize fakeOuterStringSerialize _ _ = _mkRequest "POST" ["/fake/outer/string"] -data FakeOuterStringSerialize +data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body -instance HasBodyParam FakeOuterStringSerialize BodyText +instance HasBodyParam FakeOuterStringSerialize BodyText -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype @@ -161,10 +152,10 @@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype -- *** testBodyWithFileSchema -- | @PUT \/fake\/body-with-file-schema@ --- +-- -- For this test, the body for this request much reference a schema named `File`. --- -testBodyWithFileSchema +-- +testBodyWithFileSchema :: (Consumes TestBodyWithFileSchema MimeJSON, MimeRender MimeJSON FileSchemaTestClass) => FileSchemaTestClass -- ^ "fileSchemaTestClass" -> OpenAPIPetstoreRequest TestBodyWithFileSchema MimeJSON NoContent MimeNoContent @@ -172,8 +163,8 @@ testBodyWithFileSchema fileSchemaTestClass = _mkRequest "PUT" ["/fake/body-with-file-schema"] `setBodyParam` fileSchemaTestClass -data TestBodyWithFileSchema -instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass +data TestBodyWithFileSchema +instance HasBodyParam TestBodyWithFileSchema FileSchemaTestClass -- | @application/json@ instance Consumes TestBodyWithFileSchema MimeJSON @@ -184,8 +175,8 @@ instance Produces TestBodyWithFileSchema MimeNoContent -- *** testBodyWithQueryParams -- | @PUT \/fake\/body-with-query-params@ --- -testBodyWithQueryParams +-- +testBodyWithQueryParams :: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) => User -- ^ "user" -> Query -- ^ "query" @@ -195,8 +186,8 @@ testBodyWithQueryParams user (Query query) = `setBodyParam` user `setQuery` toQuery ("query", Just query) -data TestBodyWithQueryParams -instance HasBodyParam TestBodyWithQueryParams User +data TestBodyWithQueryParams +instance HasBodyParam TestBodyWithQueryParams User -- | @application/json@ instance Consumes TestBodyWithQueryParams MimeJSON @@ -207,12 +198,12 @@ instance Produces TestBodyWithQueryParams MimeNoContent -- *** testClientModel -- | @PATCH \/fake@ --- +-- -- To test \"client\" model --- +-- -- To test \"client\" model --- -testClientModel +-- +testClientModel :: (Consumes TestClientModel MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClientModel MimeJSON Client MimeJSON @@ -220,10 +211,10 @@ testClientModel client = _mkRequest "PATCH" ["/fake"] `setBodyParam` client -data TestClientModel +data TestClientModel -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClientModel Client +instance HasBodyParam TestClientModel Client -- | @application/json@ instance Consumes TestClientModel MimeJSON @@ -235,14 +226,14 @@ instance Produces TestClientModel MimeJSON -- *** testEndpointParameters -- | @POST \/fake@ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- --- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ --- +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- +-- Fake endpoint for testing various parameters å‡ç«¯é»ž å½ã®ã‚¨ãƒ³ãƒ‰ãƒã‚¤ãƒ³ãƒˆ 가짜 엔드 í¬ì¸íЏ +-- -- AuthMethod: 'AuthBasicHttpBasicTest' --- -testEndpointParameters +-- +testEndpointParameters :: (Consumes TestEndpointParameters MimeFormUrlEncoded) => Number -- ^ "number" - None -> ParamDouble -- ^ "double" - None @@ -257,7 +248,7 @@ testEndpointParameters (Number number) (ParamDouble double) (PatternWithoutDelim `addForm` toForm ("pattern_without_delimiter", patternWithoutDelimiter) `addForm` toForm ("byte", byte) -data TestEndpointParameters +data TestEndpointParameters -- | /Optional Param/ "integer" - None instance HasOptionalParam TestEndpointParameters ParamInteger where @@ -318,18 +309,18 @@ instance Produces TestEndpointParameters MimeNoContent -- *** testEnumParameters -- | @GET \/fake@ --- +-- -- To test enum parameters --- +-- -- To test enum parameters --- -testEnumParameters +-- +testEnumParameters :: (Consumes TestEnumParameters MimeFormUrlEncoded) => OpenAPIPetstoreRequest TestEnumParameters MimeFormUrlEncoded NoContent MimeNoContent testEnumParameters = _mkRequest "GET" ["/fake"] -data TestEnumParameters +data TestEnumParameters -- | /Optional Param/ "enum_form_string_array" - Form parameter enum test (string array) instance HasOptionalParam TestEnumParameters EnumFormStringArray where @@ -380,10 +371,10 @@ instance Produces TestEnumParameters MimeNoContent -- *** testInlineAdditionalProperties -- | @POST \/fake\/inline-additionalProperties@ --- +-- -- test inline additionalProperties --- -testInlineAdditionalProperties +-- +testInlineAdditionalProperties :: (Consumes TestInlineAdditionalProperties MimeJSON, MimeRender MimeJSON RequestBody) => RequestBody -- ^ "requestBody" - request body -> OpenAPIPetstoreRequest TestInlineAdditionalProperties MimeJSON NoContent MimeNoContent @@ -391,10 +382,10 @@ testInlineAdditionalProperties requestBody = _mkRequest "POST" ["/fake/inline-additionalProperties"] `setBodyParam` requestBody -data TestInlineAdditionalProperties +data TestInlineAdditionalProperties -- | /Body Param/ "request_body" - request body -instance HasBodyParam TestInlineAdditionalProperties RequestBody +instance HasBodyParam TestInlineAdditionalProperties RequestBody -- | @application/json@ instance Consumes TestInlineAdditionalProperties MimeJSON @@ -405,10 +396,10 @@ instance Produces TestInlineAdditionalProperties MimeNoContent -- *** testJsonFormData -- | @GET \/fake\/jsonFormData@ --- +-- -- test json serialization of form data --- -testJsonFormData +-- +testJsonFormData :: (Consumes TestJsonFormData MimeFormUrlEncoded) => Param -- ^ "param" - field1 -> Param2 -- ^ "param2" - field2 @@ -418,7 +409,7 @@ testJsonFormData (Param param) (Param2 param2) = `addForm` toForm ("param", param) `addForm` toForm ("param2", param2) -data TestJsonFormData +data TestJsonFormData -- | @application/x-www-form-urlencoded@ instance Consumes TestJsonFormData MimeFormUrlEncoded diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs index 6ffc6f39aff..5719e3c4cd4 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/FakeClassnameTags123.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.FakeClassnameTags123 -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,14 +60,14 @@ import qualified Prelude as P -- *** testClassname -- | @PATCH \/fake_classname_test@ --- +-- -- To test class name in snake case --- +-- -- To test class name in snake case --- +-- -- AuthMethod: 'AuthApiKeyApiKeyQuery' --- -testClassname +-- +testClassname :: (Consumes TestClassname MimeJSON, MimeRender MimeJSON Client) => Client -- ^ "client" - client model -> OpenAPIPetstoreRequest TestClassname MimeJSON Client MimeJSON @@ -85,10 +76,10 @@ testClassname client = `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKeyQuery) `setBodyParam` client -data TestClassname +data TestClassname -- | /Body Param/ "Client" - client model -instance HasBodyParam TestClassname Client +instance HasBodyParam TestClassname Client -- | @application/json@ instance Consumes TestClassname MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs index 0e127d4e849..7b6de84e74b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Pet.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Pet -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** addPet -- | @POST \/pet@ --- +-- -- Add a new pet to the store --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -addPet +-- +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 @@ -84,10 +75,10 @@ addPet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data AddPet +data AddPet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam AddPet Pet +instance HasBodyParam AddPet Pet -- | @application/xml@ instance Consumes AddPet MimeXML @@ -100,19 +91,19 @@ instance Produces AddPet MimeNoContent -- *** deletePet -- | @DELETE \/pet\/{petId}@ --- +-- -- Deletes a pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -deletePet +-- +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 +data DeletePet instance HasOptionalParam DeletePet ApiKey where applyOptionalParam req (ApiKey xs) = req `setHeader` toHeader ("api_key", xs) @@ -123,14 +114,14 @@ 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 +-- +findPetsByStatus :: Accept accept -- ^ request accept ('MimeType') -> Status -- ^ "status" - Status values that need to be considered for filter -> OpenAPIPetstoreRequest FindPetsByStatus MimeNoContent [Pet] accept @@ -139,7 +130,7 @@ findPetsByStatus _ (Status status) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setQuery` toQueryColl CommaSeparated ("status", Just status) -data FindPetsByStatus +data FindPetsByStatus -- | @application/xml@ instance Produces FindPetsByStatus MimeXML @@ -150,14 +141,14 @@ 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 +-- +findPetsByTags :: Accept accept -- ^ request accept ('MimeType') -> Tags -- ^ "tags" - Tags to filter by -> OpenAPIPetstoreRequest FindPetsByTags MimeNoContent [Pet] accept @@ -168,7 +159,7 @@ findPetsByTags _ (Tags tags) = {-# DEPRECATED findPetsByTags "" #-} -data FindPetsByTags +data FindPetsByTags -- | @application/xml@ instance Produces FindPetsByTags MimeXML @@ -179,14 +170,14 @@ instance Produces FindPetsByTags MimeJSON -- *** getPetById -- | @GET \/pet\/{petId}@ --- +-- -- Find pet by ID --- +-- -- Returns a single pet --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getPetById +-- +getPetById :: Accept accept -- ^ request accept ('MimeType') -> PetId -- ^ "petId" - ID of pet to return -> OpenAPIPetstoreRequest GetPetById MimeNoContent Pet accept @@ -194,7 +185,7 @@ getPetById _ (PetId petId) = _mkRequest "GET" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetPetById +data GetPetById -- | @application/xml@ instance Produces GetPetById MimeXML @@ -205,12 +196,12 @@ instance Produces GetPetById MimeJSON -- *** updatePet -- | @PUT \/pet@ --- +-- -- Update an existing pet --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePet +-- +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 @@ -220,10 +211,10 @@ updatePet _ pet = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `setBodyParam` pet -data UpdatePet +data UpdatePet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store -instance HasBodyParam UpdatePet Pet +instance HasBodyParam UpdatePet Pet -- | @application/xml@ instance Consumes UpdatePet MimeXML @@ -236,12 +227,12 @@ instance Produces UpdatePet MimeNoContent -- *** updatePetWithForm -- | @POST \/pet\/{petId}@ --- +-- -- Updates a pet in the store with form data --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -updatePetWithForm +-- +updatePetWithForm :: (Consumes UpdatePetWithForm MimeFormUrlEncoded) => PetId -- ^ "petId" - ID of pet that needs to be updated -> OpenAPIPetstoreRequest UpdatePetWithForm MimeFormUrlEncoded NoContent MimeNoContent @@ -249,7 +240,7 @@ updatePetWithForm (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UpdatePetWithForm +data UpdatePetWithForm -- | /Optional Param/ "name" - Updated name of the pet instance HasOptionalParam UpdatePetWithForm Name2 where @@ -270,12 +261,12 @@ instance Produces UpdatePetWithForm MimeNoContent -- *** uploadFile -- | @POST \/pet\/{petId}\/uploadImage@ --- +-- -- uploads an image --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFile +-- +uploadFile :: (Consumes UploadFile MimeMultipartFormData) => PetId -- ^ "petId" - ID of pet to update -> OpenAPIPetstoreRequest UploadFile MimeMultipartFormData ApiResponse MimeJSON @@ -283,7 +274,7 @@ uploadFile (PetId petId) = _mkRequest "POST" ["/pet/",toPath petId,"/uploadImage"] `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) -data UploadFile +data UploadFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFile AdditionalMetadata where @@ -305,12 +296,12 @@ instance Produces UploadFile MimeJSON -- *** uploadFileWithRequiredFile -- | @POST \/fake\/{petId}\/uploadImageWithRequiredFile@ --- +-- -- uploads an image (required) --- +-- -- AuthMethod: 'AuthOAuthPetstoreAuth' --- -uploadFileWithRequiredFile +-- +uploadFileWithRequiredFile :: (Consumes UploadFileWithRequiredFile MimeMultipartFormData) => RequiredFile -- ^ "requiredFile" - file to upload -> PetId -- ^ "petId" - ID of pet to update @@ -320,7 +311,7 @@ uploadFileWithRequiredFile (RequiredFile requiredFile) (PetId petId) = `_hasAuthType` (P.Proxy :: P.Proxy AuthOAuthPetstoreAuth) `_addMultiFormPart` NH.partFileSource "requiredFile" requiredFile -data UploadFileWithRequiredFile +data UploadFileWithRequiredFile -- | /Optional Param/ "additionalMetadata" - Additional data to pass to server instance HasOptionalParam UploadFileWithRequiredFile AdditionalMetadata where diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs index ef549c44c80..12bcd0bc94a 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Store.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.Store -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,18 +60,18 @@ import qualified Prelude as P -- *** 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 +-- +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 +data DeleteOrder instance Produces DeleteOrder MimeNoContent @@ -88,20 +79,20 @@ instance Produces DeleteOrder MimeNoContent -- *** getInventory -- | @GET \/store\/inventory@ --- +-- -- Returns pet inventories by status --- +-- -- Returns a map of status codes to quantities --- +-- -- AuthMethod: 'AuthApiKeyApiKey' --- -getInventory +-- +getInventory :: OpenAPIPetstoreRequest GetInventory MimeNoContent ((Map.Map String Int)) MimeJSON getInventory = _mkRequest "GET" ["/store/inventory"] `_hasAuthType` (P.Proxy :: P.Proxy AuthApiKeyApiKey) -data GetInventory +data GetInventory -- | @application/json@ instance Produces GetInventory MimeJSON @@ -110,19 +101,19 @@ 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 +-- +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 +data GetOrderById -- | @application/xml@ instance Produces GetOrderById MimeXML @@ -133,10 +124,10 @@ instance Produces GetOrderById MimeJSON -- *** placeOrder -- | @POST \/store\/order@ --- +-- -- Place an order for a pet --- -placeOrder +-- +placeOrder :: (Consumes PlaceOrder contentType, MimeRender contentType Order) => ContentType contentType -- ^ request content-type ('MimeType') -> Accept accept -- ^ request accept ('MimeType') @@ -146,10 +137,10 @@ placeOrder _ _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order -data PlaceOrder +data PlaceOrder -- | /Body Param/ "Order" - order placed for purchasing the pet -instance HasBodyParam PlaceOrder Order +instance HasBodyParam PlaceOrder Order -- | @application/xml@ instance Produces PlaceOrder MimeXML diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs index 87e0724d02f..efc6ad66f31 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/User.hs @@ -12,54 +12,45 @@ Module : OpenAPIPetstore.API.User -} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MonoLocalBinds #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} +{-# 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 (TypeRep, Typeable, - 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 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 (Applicative, Bool (..), - Char, Double, FilePath, - Float, Functor, Int, - Integer, Maybe (..), - Monad, String, fmap, - maybe, mempty, pure, - undefined, ($), (.), - (/=), (<$>), (<*>), - (==), (>>=)) -import qualified Prelude as P +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 @@ -69,12 +60,12 @@ import qualified Prelude as P -- *** createUser -- | @POST \/user@ --- +-- -- Create user --- +-- -- This can only be done by the logged in user. --- -createUser +-- +createUser :: (Consumes CreateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Created user object @@ -83,10 +74,10 @@ createUser _ user = _mkRequest "POST" ["/user"] `setBodyParam` user -data CreateUser +data CreateUser -- | /Body Param/ "User" - Created user object -instance HasBodyParam CreateUser User +instance HasBodyParam CreateUser User instance Produces CreateUser MimeNoContent @@ -94,10 +85,10 @@ instance Produces CreateUser MimeNoContent -- *** createUsersWithArrayInput -- | @POST \/user\/createWithArray@ --- +-- -- Creates list of users with given input array --- -createUsersWithArrayInput +-- +createUsersWithArrayInput :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -106,10 +97,10 @@ createUsersWithArrayInput _ user = _mkRequest "POST" ["/user/createWithArray"] `setBodyParam` user -data CreateUsersWithArrayInput +data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithArrayInput User2 +instance HasBodyParam CreateUsersWithArrayInput User2 instance Produces CreateUsersWithArrayInput MimeNoContent @@ -117,10 +108,10 @@ instance Produces CreateUsersWithArrayInput MimeNoContent -- *** createUsersWithListInput -- | @POST \/user\/createWithList@ --- +-- -- Creates list of users with given input array --- -createUsersWithListInput +-- +createUsersWithListInput :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2) => ContentType contentType -- ^ request content-type ('MimeType') -> User2 -- ^ "user" - List of user object @@ -129,10 +120,10 @@ createUsersWithListInput _ user = _mkRequest "POST" ["/user/createWithList"] `setBodyParam` user -data CreateUsersWithListInput +data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object -instance HasBodyParam CreateUsersWithListInput User2 +instance HasBodyParam CreateUsersWithListInput User2 instance Produces CreateUsersWithListInput MimeNoContent @@ -140,18 +131,18 @@ instance Produces CreateUsersWithListInput MimeNoContent -- *** deleteUser -- | @DELETE \/user\/{username}@ --- +-- -- Delete user --- +-- -- This can only be done by the logged in user. --- -deleteUser +-- +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 +data DeleteUser instance Produces DeleteUser MimeNoContent @@ -159,17 +150,17 @@ instance Produces DeleteUser MimeNoContent -- *** getUserByName -- | @GET \/user\/{username}@ --- +-- -- Get user by user name --- -getUserByName +-- +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 +data GetUserByName -- | @application/xml@ instance Produces GetUserByName MimeXML @@ -180,10 +171,10 @@ instance Produces GetUserByName MimeJSON -- *** loginUser -- | @GET \/user\/login@ --- +-- -- Logs user into the system --- -loginUser +-- +loginUser :: Accept accept -- ^ request accept ('MimeType') -> Username -- ^ "username" - The user name for login -> Password -- ^ "password" - The password for login in clear text @@ -193,7 +184,7 @@ loginUser _ (Username username) (Password password) = `setQuery` toQuery ("username", Just username) `setQuery` toQuery ("password", Just password) -data LoginUser +data LoginUser -- | @application/xml@ instance Produces LoginUser MimeXML @@ -204,15 +195,15 @@ instance Produces LoginUser MimeJSON -- *** logoutUser -- | @GET \/user\/logout@ --- +-- -- Logs out current logged in user session --- -logoutUser +-- +logoutUser :: OpenAPIPetstoreRequest LogoutUser MimeNoContent NoContent MimeNoContent logoutUser = _mkRequest "GET" ["/user/logout"] -data LogoutUser +data LogoutUser instance Produces LogoutUser MimeNoContent @@ -220,12 +211,12 @@ instance Produces LogoutUser MimeNoContent -- *** updateUser -- | @PUT \/user\/{username}@ --- +-- -- Updated user --- +-- -- This can only be done by the logged in user. --- -updateUser +-- +updateUser :: (Consumes UpdateUser contentType, MimeRender contentType User) => ContentType contentType -- ^ request content-type ('MimeType') -> User -- ^ "user" - Updated user object @@ -235,10 +226,10 @@ updateUser _ user (Username username) = _mkRequest "PUT" ["/user/",toPath username] `setBodyParam` user -data UpdateUser +data UpdateUser -- | /Body Param/ "User" - Updated user object -instance HasBodyParam UpdateUser User +instance HasBodyParam UpdateUser User instance Produces UpdateUser MimeNoContent diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs index d8e0caf8a98..31cd12f7ada 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Client.hs @@ -12,42 +12,42 @@ Module : OpenAPIPetstore.Client -} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveFunctor #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} +{-# 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 as P -import qualified Control.Monad.IO.Class 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 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 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 (..)) +import Data.Function ((&)) +import Data.Monoid ((<>)) +import Data.Text (Text) +import GHC.Exts (IsString(..)) -- * Dispatch @@ -68,16 +68,16 @@ dispatchLbs manager config request = do -- | 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 + 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 + mimeError :: String -- ^ unrender/parser error + , mimeErrorResponse :: NH.Response BCL.ByteString -- ^ http response } deriving (Eq, Show) -- | send a request returning the 'MimeResult' @@ -153,7 +153,7 @@ dispatchInitUnsafe manager config (InitRequest req) = do "Headers=" <> (T.pack . show) (NH.requestHeaders req) <> " Body=" <> (case NH.requestBody req of NH.RequestBodyLBS xs -> T.decodeUtf8 (BL.toStrict xs) - _ -> "<RequestBody>") + _ -> "<RequestBody>") responseStatusCode = (T.pack . show) . NH.statusCode . NH.responseStatus responseLogMsg res = "RES:statusCode=" <> responseStatusCode res <> " (" <> endpoint <> ")" @@ -171,7 +171,7 @@ _toInitRequest => OpenAPIPetstoreConfig -- ^ config -> OpenAPIPetstoreRequest req contentType res accept -- ^ request -> IO (InitRequest req contentType res accept) -- ^ initialized request -_toInitRequest config req0 = +_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 @@ -202,7 +202,7 @@ modifyInitRequest (InitRequest req) f = InitRequest (f req) 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 +-- ** Logging -- | Run a block using the configured logger instance runConfigLog diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs index f01a5542a69..6fbc9899d34 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Core.hs @@ -12,76 +12,70 @@ Module : OpenAPIPetstore.Core -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# 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.Logging -import OpenAPIPetstore.MimeTypes - -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, TypeRep, - Typeable, 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 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 Text.Printf as T -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Foldable (foldlM) -import Data.Function ((&)) -import Data.Monoid ((<>)) -import Data.Text (Text) -import Prelude (Bool (..), Char, - Functor, IO, Maybe (..), - Monad, String, fmap, - mempty, pure, return, - show, ($), (.), (<$>), - (<*>)) +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 + { 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 } @@ -113,7 +107,7 @@ newConfig = do , configLogContext = logCxt , configAuthMethods = [] , configValidateAuthMethods = True - } + } -- | updates config use AuthMethod on matching requests addAuthMethod :: AuthMethod auth => OpenAPIPetstoreConfig -> auth -> OpenAPIPetstoreConfig @@ -135,7 +129,7 @@ withStderrLogging p = do -- | updates the config to disable logging withNoLogging :: OpenAPIPetstoreConfig -> OpenAPIPetstoreConfig withNoLogging p = p { configLogExecWithContext = runNullLogExec} - + -- * OpenAPIPetstoreRequest -- | Represents a request. @@ -147,9 +141,9 @@ withNoLogging p = p { configLogExecWithContext = runNullLogExec} -- * 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 + { 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) @@ -202,9 +196,9 @@ infixl 2 -&- -- | Request Params data Params = Params - { paramsQuery :: NH.Query + { paramsQuery :: NH.Query , paramsHeaders :: NH.RequestHeaders - , paramsBody :: ParamBody + , paramsBody :: ParamBody } deriving (P.Show) @@ -234,7 +228,7 @@ data ParamBody -- ** OpenAPIPetstoreRequest Utils -_mkRequest :: NH.Method -- ^ Method +_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 [] @@ -259,18 +253,18 @@ removeHeader req header = _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)] + 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)] + 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 = +setQuery req query = req & L.over (rParamsL . paramsQueryL) @@ -279,25 +273,25 @@ setQuery req query = cifst = CI.mk . P.fst addForm :: OpenAPIPetstoreRequest req contentType res accept -> WH.Form -> OpenAPIPetstoreRequest req contentType res accept -addForm req newform = +addForm req newform = let form = case paramsBody (rParams req) of ParamBodyFormUrlEncoded _form -> _form - _ -> mempty + _ -> 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 = +_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 = +_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 = +_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 @@ -353,10 +347,10 @@ _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 '|') + CommaSeparated -> go (one ',') + SpaceSeparated -> go (one ' ') + TabSeparated -> go (one '\t') + PipeSeparated -> go (one '|') MultiParamArray -> expandList where go sep = @@ -366,7 +360,7 @@ _toCollA' c encode one xs = case c of {-# INLINE go #-} {-# INLINE expandList #-} {-# INLINE combine #-} - + -- * AuthMethods -- | Provides a method to apply auth methods to requests @@ -397,7 +391,7 @@ _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) @@ -405,7 +399,7 @@ _omitNulls :: [(Text, A.Value)] -> A.Value _omitNulls = A.object . P.filter notNull where notNull (_, A.Null) = False - notNull _ = True + notNull _ = True -- | Encodes fields using WH.toQueryParam _toFormItem :: (WH.ToHttpApiData a, Functor f) => t -> f a -> f (t, [Text]) @@ -414,13 +408,13 @@ _toFormItem name x = (name,) . (:[]) . WH.toQueryParam <$> x -- | Collapse (Just "") to Nothing _emptyToNothing :: Maybe String -> Maybe String _emptyToNothing (Just "") = Nothing -_emptyToNothing x = x +_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 +_memptyToNothing x = x {-# INLINE _memptyToNothing #-} -- * DateTime Formatting @@ -491,7 +485,7 @@ _showDate = -- * Byte/Binary Formatting - + -- | base64 encoded characters newtype ByteArray = ByteArray { unByteArray :: BL.ByteString } deriving (P.Eq,P.Data,P.Ord,P.Typeable,NF.NFData) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs index cd76f7789db..8e3d4ac772b 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Logging.hs @@ -13,23 +13,23 @@ Module : OpenAPIPetstore.Logging Katip Logging functions -} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} +{-# 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.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 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 Data.Text (Text) +import GHC.Exts (IsString(..)) -import qualified Katip as LG +import qualified Katip as LG -- * Type Aliases (for compatibility) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs index e9bfbd8babb..0da4b6310f0 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/MimeTypes.hs @@ -12,38 +12,35 @@ Module : OpenAPIPetstore.MimeTypes -} -{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} +{-# 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 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 (Bool (..), Char, Double, FilePath, - Float, Int, Integer, Maybe (..), - String, fmap, mempty, undefined, - ($), (.), (<$>), (<*>)) -import qualified Prelude as P +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 @@ -85,13 +82,13 @@ class P.Typeable mtype => MimeType mtype where mimeTypes :: P.Proxy mtype -> [ME.MediaType] mimeTypes p = case mimeType p of - Just x -> [x] + Just x -> [x] Nothing -> [] mimeType :: P.Proxy mtype -> Maybe ME.MediaType mimeType p = case mimeTypes p of - [] -> Nothing + [] -> Nothing (x:_) -> Just x mimeType' :: mtype -> Maybe ME.MediaType diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index 699e857586c..dcbcef0b83f 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -12,60 +12,54 @@ Module : OpenAPIPetstore.Model -} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TupleSections #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unused-matches -fno-warn-unused-binds -fno-warn-unused-imports #-} module OpenAPIPetstore.Model where -import OpenAPIPetstore.Core -import OpenAPIPetstore.MimeTypes - -import Data.Aeson ((.:), (.:!), (.:?), (.=)) - -import qualified Control.Arrow as P (left) -import qualified Data.Aeson as A -import qualified Data.ByteString as B -import qualified Data.ByteString.Base64 as B64 -import qualified Data.ByteString.Char8 as BC -import qualified Data.ByteString.Lazy as BL -import qualified Data.Data as P (TypeRep, Typeable, typeOf, - typeRep) -import qualified Data.Foldable as P -import qualified Data.HashMap.Lazy as HM -import qualified Data.Map as Map -import qualified Data.Maybe as P -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Time as TI -import qualified Lens.Micro as L -import qualified Web.FormUrlEncoded as WH -import qualified Web.HttpApiData as WH - -import Control.Applicative ((<|>)) -import Control.Applicative (Alternative) -import Data.Function ((&)) -import Data.Monoid ((<>)) -import Data.Text (Text) -import Prelude (Applicative, Bool (..), Char, - Double, FilePath, Float, Functor, - Int, Integer, Maybe (..), Monad, - String, fmap, maybe, mempty, pure, - undefined, ($), (.), (/=), (<$>), - (<*>), (=<<), (>>=)) - -import qualified Prelude as P +import OpenAPIPetstore.Core +import OpenAPIPetstore.MimeTypes + +import Data.Aeson ((.:),(.:!),(.:?),(.=)) + +import qualified Control.Arrow as P (left) +import qualified Data.Aeson as A +import qualified Data.ByteString as B +import qualified Data.ByteString.Base64 as B64 +import qualified Data.ByteString.Char8 as BC +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.HashMap.Lazy as HM +import qualified Data.Map as Map +import qualified Data.Maybe as P +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Text.Encoding as T +import qualified Data.Time as TI +import qualified Lens.Micro as L +import qualified Web.FormUrlEncoded as WH +import qualified Web.HttpApiData as WH + +import Control.Applicative ((<|>)) +import Control.Applicative (Alternative) +import Data.Function ((&)) +import Data.Monoid ((<>)) +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 @@ -237,7 +231,7 @@ mkAdditionalPropertiesClass = -- | Animal data Animal = Animal { animalClassName :: !(Text) -- ^ /Required/ "className" - , animalColor :: !(Maybe Text) -- ^ "color" + , animalColor :: !(Maybe Text) -- ^ "color" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Animal @@ -258,7 +252,7 @@ instance A.ToJSON Animal where -- | Construct a value of type 'Animal' (by applying it's required fields, if any) mkAnimal - :: Text -- ^ 'animalClassName' + :: Text -- ^ 'animalClassName' -> Animal mkAnimal animalClassName = Animal @@ -269,20 +263,20 @@ mkAnimal animalClassName = -- ** AnimalFarm -- | AnimalFarm data AnimalFarm = AnimalFarm - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON AnimalFarm instance A.FromJSON AnimalFarm where parseJSON = A.withObject "AnimalFarm" $ \o -> pure AnimalFarm - + -- | ToJSON AnimalFarm instance A.ToJSON AnimalFarm where toJSON AnimalFarm = _omitNulls - [ + [ ] @@ -291,14 +285,14 @@ mkAnimalFarm :: AnimalFarm mkAnimalFarm = AnimalFarm - { + { } -- ** ApiResponse -- | ApiResponse data ApiResponse = ApiResponse - { apiResponseCode :: !(Maybe Int) -- ^ "code" - , apiResponseType :: !(Maybe Text) -- ^ "type" + { apiResponseCode :: !(Maybe Int) -- ^ "code" + , apiResponseType :: !(Maybe Text) -- ^ "type" , apiResponseMessage :: !(Maybe Text) -- ^ "message" } deriving (P.Show, P.Eq, P.Typeable) @@ -389,9 +383,9 @@ mkArrayOfNumberOnly = -- ** ArrayTest -- | ArrayTest data ArrayTest = ArrayTest - { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" + { arrayTestArrayOfString :: !(Maybe [Text]) -- ^ "array_of_string" , arrayTestArrayArrayOfInteger :: !(Maybe [[Integer]]) -- ^ "array_array_of_integer" - , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" + , arrayTestArrayArrayOfModel :: !(Maybe [[ReadOnlyFirst]]) -- ^ "array_array_of_model" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ArrayTest @@ -425,12 +419,12 @@ mkArrayTest = -- ** Capitalization -- | Capitalization data Capitalization = Capitalization - { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" - , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" - , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" - , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" + { capitalizationSmallCamel :: !(Maybe Text) -- ^ "smallCamel" + , capitalizationCapitalCamel :: !(Maybe Text) -- ^ "CapitalCamel" + , capitalizationSmallSnake :: !(Maybe Text) -- ^ "small_Snake" + , capitalizationCapitalSnake :: !(Maybe Text) -- ^ "Capital_Snake" , capitalizationScaEthFlowPoints :: !(Maybe Text) -- ^ "SCA_ETH_Flow_Points" - , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet + , capitalizationAttName :: !(Maybe Text) -- ^ "ATT_NAME" - Name of the pet } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Capitalization @@ -474,8 +468,8 @@ mkCapitalization = -- | Cat data Cat = Cat { catClassName :: !(Text) -- ^ /Required/ "className" - , catColor :: !(Maybe Text) -- ^ "color" - , catDeclawed :: !(Maybe Bool) -- ^ "declawed" + , catColor :: !(Maybe Text) -- ^ "color" + , catDeclawed :: !(Maybe Bool) -- ^ "declawed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Cat @@ -498,7 +492,7 @@ instance A.ToJSON Cat where -- | Construct a value of type 'Cat' (by applying it's required fields, if any) mkCat - :: Text -- ^ 'catClassName' + :: Text -- ^ 'catClassName' -> Cat mkCat catClassName = Cat @@ -510,7 +504,7 @@ mkCat catClassName = -- ** Category -- | Category data Category = Category - { categoryId :: !(Maybe Integer) -- ^ "id" + { categoryId :: !(Maybe Integer) -- ^ "id" , categoryName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -600,8 +594,8 @@ mkClient = -- | Dog data Dog = Dog { dogClassName :: !(Text) -- ^ /Required/ "className" - , dogColor :: !(Maybe Text) -- ^ "color" - , dogBreed :: !(Maybe Text) -- ^ "breed" + , dogColor :: !(Maybe Text) -- ^ "color" + , dogBreed :: !(Maybe Text) -- ^ "breed" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Dog @@ -624,7 +618,7 @@ instance A.ToJSON Dog where -- | Construct a value of type 'Dog' (by applying it's required fields, if any) mkDog - :: Text -- ^ 'dogClassName' + :: Text -- ^ 'dogClassName' -> Dog mkDog dogClassName = Dog @@ -637,7 +631,7 @@ mkDog dogClassName = -- | EnumArrays data EnumArrays = EnumArrays { enumArraysJustSymbol :: !(Maybe E'JustSymbol) -- ^ "just_symbol" - , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" + , enumArraysArrayEnum :: !(Maybe [E'ArrayEnum]) -- ^ "array_enum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumArrays @@ -668,11 +662,11 @@ mkEnumArrays = -- ** EnumTest -- | EnumTest data EnumTest = EnumTest - { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" + { enumTestEnumString :: !(Maybe E'EnumString) -- ^ "enum_string" , enumTestEnumStringRequired :: !(E'EnumString) -- ^ /Required/ "enum_string_required" - , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" - , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" - , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" + , enumTestEnumInteger :: !(Maybe E'EnumInteger) -- ^ "enum_integer" + , enumTestEnumNumber :: !(Maybe E'EnumNumber) -- ^ "enum_number" + , enumTestOuterEnum :: !(Maybe OuterEnum) -- ^ "outerEnum" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON EnumTest @@ -699,7 +693,7 @@ instance A.ToJSON EnumTest where -- | Construct a value of type 'EnumTest' (by applying it's required fields, if any) mkEnumTest - :: E'EnumString -- ^ 'enumTestEnumStringRequired' + :: E'EnumString -- ^ 'enumTestEnumStringRequired' -> EnumTest mkEnumTest enumTestEnumStringRequired = EnumTest @@ -742,7 +736,7 @@ mkFile = -- ** FileSchemaTestClass -- | FileSchemaTestClass data FileSchemaTestClass = FileSchemaTestClass - { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" + { fileSchemaTestClassFile :: !(Maybe File) -- ^ "file" , fileSchemaTestClassFiles :: !(Maybe [File]) -- ^ "files" } deriving (P.Show, P.Eq, P.Typeable) @@ -774,18 +768,18 @@ mkFileSchemaTestClass = -- ** FormatTest -- | FormatTest data FormatTest = FormatTest - { formatTestInteger :: !(Maybe Int) -- ^ "integer" - , formatTestInt32 :: !(Maybe Int) -- ^ "int32" - , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" - , formatTestNumber :: !(Double) -- ^ /Required/ "number" - , formatTestFloat :: !(Maybe Float) -- ^ "float" - , formatTestDouble :: !(Maybe Double) -- ^ "double" - , formatTestString :: !(Maybe Text) -- ^ "string" - , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" - , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" - , formatTestDate :: !(Date) -- ^ /Required/ "date" + { formatTestInteger :: !(Maybe Int) -- ^ "integer" + , formatTestInt32 :: !(Maybe Int) -- ^ "int32" + , formatTestInt64 :: !(Maybe Integer) -- ^ "int64" + , formatTestNumber :: !(Double) -- ^ /Required/ "number" + , formatTestFloat :: !(Maybe Float) -- ^ "float" + , formatTestDouble :: !(Maybe Double) -- ^ "double" + , formatTestString :: !(Maybe Text) -- ^ "string" + , formatTestByte :: !(ByteArray) -- ^ /Required/ "byte" + , formatTestBinary :: !(Maybe FilePath) -- ^ "binary" + , formatTestDate :: !(Date) -- ^ /Required/ "date" , formatTestDateTime :: !(Maybe DateTime) -- ^ "dateTime" - , formatTestUuid :: !(Maybe Text) -- ^ "uuid" + , formatTestUuid :: !(Maybe Text) -- ^ "uuid" , formatTestPassword :: !(Text) -- ^ /Required/ "password" } deriving (P.Show, P.Eq, P.Typeable) @@ -829,10 +823,10 @@ instance A.ToJSON FormatTest where -- | Construct a value of type 'FormatTest' (by applying it's required fields, if any) mkFormatTest - :: Double -- ^ 'formatTestNumber' - -> ByteArray -- ^ 'formatTestByte' - -> Date -- ^ 'formatTestDate' - -> Text -- ^ 'formatTestPassword' + :: Double -- ^ 'formatTestNumber' + -> ByteArray -- ^ 'formatTestByte' + -> Date -- ^ 'formatTestDate' + -> Text -- ^ 'formatTestPassword' -> FormatTest mkFormatTest formatTestNumber formatTestByte formatTestDate formatTestPassword = FormatTest @@ -886,10 +880,10 @@ mkHasOnlyReadOnly = -- ** MapTest -- | MapTest data MapTest = MapTest - { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" + { mapTestMapMapOfString :: !(Maybe (Map.Map String (Map.Map String Text))) -- ^ "map_map_of_string" , mapTestMapOfEnumString :: !(Maybe (Map.Map String E'Inner)) -- ^ "map_of_enum_string" - , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" - , mapTestIndirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "indirect_map" + , mapTestDirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "direct_map" + , mapTestIndirectMap :: !(Maybe (Map.Map String Bool)) -- ^ "indirect_map" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON MapTest @@ -963,7 +957,7 @@ mkMixedPropertiesAndAdditionalPropertiesClass = -- | Model200Response -- Model for testing model name starting with number data Model200Response = Model200Response - { model200ResponseName :: !(Maybe Int) -- ^ "name" + { model200ResponseName :: !(Maybe Int) -- ^ "name" , model200ResponseClass :: !(Maybe Text) -- ^ "class" } deriving (P.Show, P.Eq, P.Typeable) @@ -1053,9 +1047,9 @@ mkModelReturn = -- | Name -- Model for testing model name same as property name data Name = Name - { nameName :: !(Int) -- ^ /Required/ "name" + { nameName :: !(Int) -- ^ /Required/ "name" , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" - , nameProperty :: !(Maybe Text) -- ^ "property" + , nameProperty :: !(Maybe Text) -- ^ "property" , name123number :: !(Maybe Int) -- ^ "123Number" } deriving (P.Show, P.Eq, P.Typeable) @@ -1081,7 +1075,7 @@ instance A.ToJSON Name where -- | Construct a value of type 'Name' (by applying it's required fields, if any) mkName - :: Int -- ^ 'nameName' + :: Int -- ^ 'nameName' -> Name mkName nameName = Name @@ -1122,11 +1116,11 @@ mkNumberOnly = -- ** Order -- | Order data Order = Order - { orderId :: !(Maybe Integer) -- ^ "id" - , orderPetId :: !(Maybe Integer) -- ^ "petId" + { orderId :: !(Maybe Integer) -- ^ "id" + , orderPetId :: !(Maybe Integer) -- ^ "petId" , orderQuantity :: !(Maybe Int) -- ^ "quantity" , orderShipDate :: !(Maybe DateTime) -- ^ "shipDate" - , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status + , orderStatus :: !(Maybe E'Status) -- ^ "status" - Order Status , orderComplete :: !(Maybe Bool) -- ^ "complete" } deriving (P.Show, P.Eq, P.Typeable) @@ -1170,8 +1164,8 @@ mkOrder = -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" + { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" , outerCompositeMyBoolean :: !(Maybe Bool) -- ^ "my_boolean" } deriving (P.Show, P.Eq, P.Typeable) @@ -1206,12 +1200,12 @@ mkOuterComposite = -- ** Pet -- | Pet data Pet = Pet - { petId :: !(Maybe Integer) -- ^ "id" - , petCategory :: !(Maybe Category) -- ^ "category" - , petName :: !(Text) -- ^ /Required/ "name" + { petId :: !(Maybe Integer) -- ^ "id" + , petCategory :: !(Maybe Category) -- ^ "category" + , petName :: !(Text) -- ^ /Required/ "name" , petPhotoUrls :: !([Text]) -- ^ /Required/ "photoUrls" - , petTags :: !(Maybe [Tag]) -- ^ "tags" - , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store + , petTags :: !(Maybe [Tag]) -- ^ "tags" + , petStatus :: !(Maybe E'Status2) -- ^ "status" - pet status in the store } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Pet @@ -1240,8 +1234,8 @@ instance A.ToJSON Pet where -- | Construct a value of type 'Pet' (by applying it's required fields, if any) mkPet - :: Text -- ^ 'petName' - -> [Text] -- ^ 'petPhotoUrls' + :: Text -- ^ 'petName' + -> [Text] -- ^ 'petPhotoUrls' -> Pet mkPet petName petPhotoUrls = Pet @@ -1316,20 +1310,20 @@ mkSpecialModelName = -- ** StringBooleanMap -- | StringBooleanMap data StringBooleanMap = StringBooleanMap - { + { } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON StringBooleanMap instance A.FromJSON StringBooleanMap where parseJSON = A.withObject "StringBooleanMap" $ \o -> pure StringBooleanMap - + -- | ToJSON StringBooleanMap instance A.ToJSON StringBooleanMap where toJSON StringBooleanMap = _omitNulls - [ + [ ] @@ -1338,13 +1332,13 @@ mkStringBooleanMap :: StringBooleanMap mkStringBooleanMap = StringBooleanMap - { + { } -- ** Tag -- | Tag data Tag = Tag - { tagId :: !(Maybe Integer) -- ^ "id" + { tagId :: !(Maybe Integer) -- ^ "id" , tagName :: !(Maybe Text) -- ^ "name" } deriving (P.Show, P.Eq, P.Typeable) @@ -1376,13 +1370,13 @@ mkTag = -- ** User -- | User data User = User - { userId :: !(Maybe Integer) -- ^ "id" - , userUsername :: !(Maybe Text) -- ^ "username" - , userFirstName :: !(Maybe Text) -- ^ "firstName" - , userLastName :: !(Maybe Text) -- ^ "lastName" - , userEmail :: !(Maybe Text) -- ^ "email" - , userPassword :: !(Maybe Text) -- ^ "password" - , userPhone :: !(Maybe Text) -- ^ "phone" + { userId :: !(Maybe Integer) -- ^ "id" + , userUsername :: !(Maybe Text) -- ^ "username" + , userFirstName :: !(Maybe Text) -- ^ "firstName" + , userLastName :: !(Maybe Text) -- ^ "lastName" + , userEmail :: !(Maybe Text) -- ^ "email" + , userPassword :: !(Maybe Text) -- ^ "password" + , userPhone :: !(Maybe Text) -- ^ "phone" , userUserStatus :: !(Maybe Int) -- ^ "userStatus" - User Status } deriving (P.Show, P.Eq, P.Typeable) @@ -1463,7 +1457,7 @@ toE'ArrayEnum = \case -- ** E'EnumFormString --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString = E'EnumFormString'_abc -- ^ @"_abc"@ @@ -1694,7 +1688,7 @@ toE'JustSymbol = \case -- ** E'Status --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Order Status data E'Status = E'Status'Placed -- ^ @"placed"@ @@ -1726,7 +1720,7 @@ toE'Status = \case -- ** E'Status2 --- | Enum of 'Text' . +-- | Enum of 'Text' . -- pet status in the store data E'Status2 = E'Status2'Available -- ^ @"available"@ @@ -1869,7 +1863,7 @@ instance AuthMethod AuthOAuthPetstoreAuth where applyAuthMethod _ a@(AuthOAuthPetstoreAuth secret) req = P.pure $ if (P.typeOf a `P.elem` rAuthTypes req) - then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) + then req `setHeader` toHeader ("Authorization", "Bearer " <> secret) & L.over rAuthTypesL (P.filter (/= P.typeOf a)) else req diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index a6c3e12b2cd..a093ca73ca0 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -12,32 +12,28 @@ Module : OpenAPIPetstore.Lens -} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE RankNTypes #-} +{-# 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 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 Data.Text (Text) -import Prelude (Applicative, Bool (..), Char, Double, - FilePath, Float, Functor, Int, Integer, - Maybe (..), Monad, String, fmap, maybe, - mempty, pure, undefined, ($), (.), - (<$>), (<*>), (=<<)) -import qualified Prelude as P +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.Core -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.Core -- * AdditionalPropertiesClass diff --git a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs index a217b69021b..88ca2110a06 100644 --- a/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs +++ b/samples/client/petstore/haskell-http-client/tests/ApproxEq.hs @@ -1,15 +1,15 @@ {-# LANGUAGE DefaultSignatures #-} -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module ApproxEq where -import Data.Text (Text) -import Data.Time.Clock -import GHC.Generics as G -import Test.QuickCheck +import Data.Text (Text) +import Data.Time.Clock +import Test.QuickCheck +import GHC.Generics as G (==~) :: (ApproxEq a, Show a) @@ -26,7 +26,7 @@ instance (GApproxEq a, GApproxEq b) => GApproxEq (a :+: b) where gApproxEq (L1 a) (L1 b) = gApproxEq a b gApproxEq (R1 a) (R1 b) = gApproxEq a b - gApproxEq _ _ = False + gApproxEq _ _ = False instance (GApproxEq a, GApproxEq b) => GApproxEq (a :*: b) where diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 4913699524d..dc1a79b93dd 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -2,23 +2,23 @@ module Instances where -import OpenAPIPetstore.Core -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.Core -import qualified Data.Aeson as A -import qualified Data.ByteString.Lazy as BL -import qualified Data.HashMap.Strict as HM -import qualified Data.Set as Set -import qualified Data.Text as T -import qualified Data.Time as TI -import qualified Data.Vector as V +import qualified Data.Aeson as A +import qualified Data.ByteString.Lazy as BL +import qualified Data.HashMap.Strict as HM +import qualified Data.Set as Set +import qualified Data.Text as T +import qualified Data.Time as TI +import qualified Data.Vector as V -import Control.Monad -import Data.Char (isSpace) -import Data.List (sort) -import Test.QuickCheck +import Control.Monad +import Data.Char (isSpace) +import Data.List (sort) +import Test.QuickCheck -import ApproxEq +import ApproxEq instance Arbitrary T.Text where arbitrary = T.pack <$> arbitrary @@ -71,7 +71,7 @@ instance Arbitrary A.Value where sizedObject n = liftM (A.object . map mapF) $ replicateM n $ (,) <$> (arbitrary :: Gen String) <*> simpleAndArrays - + -- | Checks if a given list has no duplicates in _O(n log n)_. hasNoDups :: (Ord a) @@ -88,48 +88,48 @@ instance ApproxEq TI.Day where (=~) = (==) -- * Models - + instance Arbitrary AdditionalPropertiesClass where arbitrary = AdditionalPropertiesClass <$> arbitrary -- additionalPropertiesClassMapProperty :: Maybe (Map.Map String Text) <*> arbitrary -- additionalPropertiesClassMapOfMapProperty :: Maybe (Map.Map String (Map.Map String Text)) - + instance Arbitrary Animal where arbitrary = Animal <$> arbitrary -- animalClassName :: Text <*> arbitrary -- animalColor :: Maybe Text - + instance Arbitrary AnimalFarm where arbitrary = - + pure AnimalFarm - + instance Arbitrary ApiResponse where arbitrary = ApiResponse <$> arbitrary -- apiResponseCode :: Maybe Int <*> arbitrary -- apiResponseType :: Maybe Text <*> arbitrary -- apiResponseMessage :: Maybe Text - + instance Arbitrary ArrayOfArrayOfNumberOnly where arbitrary = ArrayOfArrayOfNumberOnly <$> arbitrary -- arrayOfArrayOfNumberOnlyArrayArrayNumber :: Maybe [[Double]] - + instance Arbitrary ArrayOfNumberOnly where arbitrary = ArrayOfNumberOnly <$> arbitrary -- arrayOfNumberOnlyArrayNumber :: Maybe [Double] - + instance Arbitrary ArrayTest where arbitrary = ArrayTest <$> arbitrary -- arrayTestArrayOfString :: Maybe [Text] <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] - + instance Arbitrary Capitalization where arbitrary = Capitalization @@ -139,43 +139,43 @@ instance Arbitrary Capitalization where <*> arbitrary -- capitalizationCapitalSnake :: Maybe Text <*> arbitrary -- capitalizationScaEthFlowPoints :: Maybe Text <*> arbitrary -- capitalizationAttName :: Maybe Text - + instance Arbitrary Cat where arbitrary = Cat <$> arbitrary -- catClassName :: Text <*> arbitrary -- catColor :: Maybe Text <*> arbitrary -- catDeclawed :: Maybe Bool - + instance Arbitrary Category where arbitrary = Category <$> arbitrary -- categoryId :: Maybe Integer <*> arbitrary -- categoryName :: Maybe Text - + instance Arbitrary ClassModel where arbitrary = ClassModel <$> arbitrary -- classModelClass :: Maybe Text - + instance Arbitrary Client where arbitrary = Client <$> arbitrary -- clientClient :: Maybe Text - + instance Arbitrary Dog where arbitrary = Dog <$> arbitrary -- dogClassName :: Text <*> arbitrary -- dogColor :: Maybe Text <*> arbitrary -- dogBreed :: Maybe Text - + instance Arbitrary EnumArrays where arbitrary = EnumArrays <$> arbitrary -- enumArraysJustSymbol :: Maybe Text <*> arbitrary -- enumArraysArrayEnum :: Maybe [Text] - + instance Arbitrary EnumTest where arbitrary = EnumTest @@ -184,18 +184,18 @@ instance Arbitrary EnumTest where <*> arbitrary -- enumTestEnumInteger :: Maybe Int <*> arbitrary -- enumTestEnumNumber :: Maybe Double <*> arbitrary -- enumTestOuterEnum :: Maybe OuterEnum - + instance Arbitrary File where arbitrary = File <$> arbitrary -- fileSourceUri :: Maybe Text - + instance Arbitrary FileSchemaTestClass where arbitrary = FileSchemaTestClass <$> arbitrary -- fileSchemaTestClassFile :: Maybe File <*> arbitrary -- fileSchemaTestClassFiles :: Maybe [File] - + instance Arbitrary FormatTest where arbitrary = FormatTest @@ -212,13 +212,13 @@ instance Arbitrary FormatTest where <*> arbitrary -- formatTestDateTime :: Maybe DateTime <*> arbitrary -- formatTestUuid :: Maybe Text <*> arbitrary -- formatTestPassword :: Text - + instance Arbitrary HasOnlyReadOnly where arbitrary = HasOnlyReadOnly <$> arbitrary -- hasOnlyReadOnlyBar :: Maybe Text <*> arbitrary -- hasOnlyReadOnlyFoo :: Maybe Text - + instance Arbitrary MapTest where arbitrary = MapTest @@ -226,30 +226,30 @@ instance Arbitrary MapTest where <*> arbitrary -- mapTestMapOfEnumString :: Maybe (Map.Map String Text) <*> arbitrary -- mapTestDirectMap :: Maybe (Map.Map String Bool) <*> arbitrary -- mapTestIndirectMap :: Maybe (Map.Map String Bool) - + instance Arbitrary MixedPropertiesAndAdditionalPropertiesClass where arbitrary = MixedPropertiesAndAdditionalPropertiesClass <$> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassUuid :: Maybe Text <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassDateTime :: Maybe DateTime <*> arbitrary -- mixedPropertiesAndAdditionalPropertiesClassMap :: Maybe (Map.Map String Animal) - + instance Arbitrary Model200Response where arbitrary = Model200Response <$> arbitrary -- model200ResponseName :: Maybe Int <*> arbitrary -- model200ResponseClass :: Maybe Text - + instance Arbitrary ModelList where arbitrary = ModelList <$> arbitrary -- modelList123list :: Maybe Text - + instance Arbitrary ModelReturn where arbitrary = ModelReturn <$> arbitrary -- modelReturnReturn :: Maybe Int - + instance Arbitrary Name where arbitrary = Name @@ -257,12 +257,12 @@ instance Arbitrary Name where <*> arbitrary -- nameSnakeCase :: Maybe Int <*> arbitrary -- nameProperty :: Maybe Text <*> arbitrary -- name123number :: Maybe Int - + instance Arbitrary NumberOnly where arbitrary = NumberOnly <$> arbitrary -- numberOnlyJustNumber :: Maybe Double - + instance Arbitrary Order where arbitrary = Order @@ -272,14 +272,14 @@ instance Arbitrary Order where <*> arbitrary -- orderShipDate :: Maybe DateTime <*> arbitrary -- orderStatus :: Maybe Text <*> arbitrary -- orderComplete :: Maybe Bool - + instance Arbitrary OuterComposite where arbitrary = OuterComposite <$> arbitrary -- outerCompositeMyNumber :: Maybe Double <*> arbitrary -- outerCompositeMyString :: Maybe Text <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool - + instance Arbitrary Pet where arbitrary = Pet @@ -289,29 +289,29 @@ instance Arbitrary Pet where <*> arbitrary -- petPhotoUrls :: [Text] <*> arbitrary -- petTags :: Maybe [Tag] <*> arbitrary -- petStatus :: Maybe Text - + instance Arbitrary ReadOnlyFirst where arbitrary = ReadOnlyFirst <$> arbitrary -- readOnlyFirstBar :: Maybe Text <*> arbitrary -- readOnlyFirstBaz :: Maybe Text - + instance Arbitrary SpecialModelName where arbitrary = SpecialModelName <$> arbitrary -- specialModelNameSpecialPropertyName :: Maybe Integer - + instance Arbitrary StringBooleanMap where arbitrary = - + pure StringBooleanMap - + instance Arbitrary Tag where arbitrary = Tag <$> arbitrary -- tagId :: Maybe Integer <*> arbitrary -- tagName :: Maybe Text - + instance Arbitrary User where arbitrary = User @@ -323,7 +323,7 @@ instance Arbitrary User where <*> arbitrary -- userPassword :: Maybe Text <*> arbitrary -- userPhone :: Maybe Text <*> arbitrary -- userUserStatus :: Maybe Int - + diff --git a/samples/client/petstore/haskell-http-client/tests/PropMime.hs b/samples/client/petstore/haskell-http-client/tests/PropMime.hs index 2f64db78fe4..c5a78129777 100644 --- a/samples/client/petstore/haskell-http-client/tests/PropMime.hs +++ b/samples/client/petstore/haskell-http-client/tests/PropMime.hs @@ -1,23 +1,23 @@ -{-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE ConstraintKinds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module PropMime where -import Data.Aeson -import Data.Aeson.Types (parseEither) +import Data.Aeson +import Data.Aeson.Types (parseEither) +import Data.Monoid ((<>)) +import Data.Typeable (Proxy(..), typeOf, Typeable) import qualified Data.ByteString.Lazy.Char8 as BL8 -import Data.Monoid ((<>)) -import Data.Typeable (Proxy (..), Typeable, typeOf) -import Test.Hspec -import Test.Hspec.QuickCheck (prop) -import Test.QuickCheck -import Test.QuickCheck.Property +import Test.Hspec +import Test.QuickCheck +import Test.QuickCheck.Property +import Test.Hspec.QuickCheck (prop) -import OpenAPIPetstore.MimeTypes +import OpenAPIPetstore.MimeTypes -import ApproxEq +import ApproxEq -- * Type Aliases diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index 926f7b9927b..ea6fff251e3 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -1,19 +1,19 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE PartialTypeSignatures #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} module Main where -import Data.Typeable (Proxy (..)) -import Test.Hspec -import Test.Hspec.QuickCheck +import Data.Typeable (Proxy(..)) +import Test.Hspec +import Test.Hspec.QuickCheck -import Instances () -import PropMime +import PropMime +import Instances () -import OpenAPIPetstore.MimeTypes -import OpenAPIPetstore.Model +import OpenAPIPetstore.Model +import OpenAPIPetstore.MimeTypes main :: IO () main = @@ -56,4 +56,4 @@ main = propMimeEq MimeJSON (Proxy :: Proxy StringBooleanMap) propMimeEq MimeJSON (Proxy :: Proxy Tag) propMimeEq MimeJSON (Proxy :: Proxy User) - + -- GitLab From e77d68c99a31e1cc1e23fe9831e909538138720a Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Fri, 21 Sep 2018 00:35:31 +0800 Subject: [PATCH 09/10] regenerate haskell servant sample --- .../server/petstore/haskell-servant/Setup.hs | 3 +- .../lib/OpenAPIPetstore/API.hs | 265 +++++++++--------- .../lib/OpenAPIPetstore/Types.hs | 105 ++++--- 3 files changed, 177 insertions(+), 196 deletions(-) diff --git a/samples/server/petstore/haskell-servant/Setup.hs b/samples/server/petstore/haskell-servant/Setup.hs index ebdc00e6461..9a994af677b 100644 --- a/samples/server/petstore/haskell-servant/Setup.hs +++ b/samples/server/petstore/haskell-servant/Setup.hs @@ -1,3 +1,2 @@ -import Distribution.Simple - +import Distribution.Simple main = defaultMain diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs index 254e77a4b28..be52403f5c7 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs @@ -1,14 +1,14 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports -fcontext-stack=328 #-} @@ -25,56 +25,52 @@ module OpenAPIPetstore.API , OpenAPIPetstoreAPI ) where -import OpenAPIPetstore.Types - -import Control.Monad.Except (ExceptT) -import Control.Monad.IO.Class -import Data.Aeson (Value) -import Data.Coerce (coerce) -import Data.Function ((&)) -import qualified Data.Map as Map -import Data.Monoid ((<>)) -import Data.Proxy (Proxy (..)) -import Data.Text (Text) -import qualified Data.Text as T -import GHC.Exts (IsString (..)) -import GHC.Generics (Generic) -import Network.HTTP.Client (Manager, defaultManagerSettings, - newManager) -import Network.HTTP.Types.Method (methodOptions) -import qualified Network.Wai.Handler.Warp as Warp -import Servant (ServantErr, serve) -import Servant.API -import Servant.API.Verbs (StdMethod (..), Verb) -import Servant.Client (Scheme (Http), ServantError, client) -import Servant.Common.BaseUrl (BaseUrl (..)) -import Web.HttpApiData +import OpenAPIPetstore.Types + +import Control.Monad.Except (ExceptT) +import Control.Monad.IO.Class +import Data.Aeson (Value) +import Data.Coerce (coerce) +import Data.Function ((&)) +import qualified Data.Map as Map +import Data.Monoid ((<>)) +import Data.Proxy (Proxy(..)) +import Data.Text (Text) +import qualified Data.Text as T +import GHC.Exts (IsString(..)) +import GHC.Generics (Generic) +import Network.HTTP.Client (Manager, defaultManagerSettings, newManager) +import Network.HTTP.Types.Method (methodOptions) +import qualified Network.Wai.Handler.Warp as Warp +import Servant (ServantErr, serve) +import Servant.API +import Servant.API.Verbs (StdMethod(..), Verb) +import Servant.Client (Scheme(Http), ServantError, client) +import Servant.Common.BaseUrl (BaseUrl(..)) +import Web.HttpApiData + + data FormUpdatePetWithForm = FormUpdatePetWithForm - { updatePetWithFormName :: Text + { updatePetWithFormName :: Text , updatePetWithFormStatus :: Text } deriving (Show, Eq, Generic) instance FromFormUrlEncoded FormUpdatePetWithForm where - fromFormUrlEncoded inputs = - FormUpdatePetWithForm <$> lookupEither "name" inputs <*> - lookupEither "status" inputs + fromFormUrlEncoded inputs = FormUpdatePetWithForm <$> lookupEither "name" inputs <*> lookupEither "status" inputs instance ToFormUrlEncoded FormUpdatePetWithForm where toFormUrlEncoded value = [ ("name", toQueryParam $ updatePetWithFormName value) , ("status", toQueryParam $ updatePetWithFormStatus value) ] - data FormUploadFile = FormUploadFile { uploadFileAdditionalMetadata :: Text - , uploadFileFile :: FilePath + , uploadFileFile :: FilePath } deriving (Show, Eq, Generic) instance FromFormUrlEncoded FormUploadFile where - fromFormUrlEncoded inputs = - FormUploadFile <$> lookupEither "additionalMetadata" inputs <*> - lookupEither "file" inputs + fromFormUrlEncoded inputs = FormUploadFile <$> lookupEither "additionalMetadata" inputs <*> lookupEither "file" inputs instance ToFormUrlEncoded FormUploadFile where toFormUrlEncoded value = @@ -86,40 +82,39 @@ instance ToFormUrlEncoded FormUploadFile where lookupEither :: FromHttpApiData b => Text -> [(Text, Text)] -> Either String b lookupEither key assocs = case lookup key assocs of - Nothing -> - Left $ "Could not find parameter " <> (T.unpack key) <> " in form data" + Nothing -> Left $ "Could not find parameter " <> (T.unpack key) <> " in form data" Just value -> case parseQueryParam value of - Left result -> Left $ T.unpack result + Left result -> Left $ T.unpack result Right result -> Right $ result -- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore. type OpenAPIPetstoreAPI - = "pet" :> ReqBody '[ JSON] Pet :> Verb 'POST 200 '[ JSON] () -- 'addPet' route - :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deletePet' route - :<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[ JSON] [Pet] -- 'findPetsByStatus' route - :<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[ JSON] [Pet] -- 'findPetsByTags' route - :<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[ JSON] Pet -- 'getPetById' route - :<|> "pet" :> ReqBody '[ JSON] Pet :> Verb 'PUT 200 '[ JSON] () -- 'updatePet' route - :<|> "pet" :> Capture "petId" Integer :> ReqBody '[ FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[ JSON] () -- 'updatePetWithForm' route - :<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[ FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[ JSON] ApiResponse -- 'uploadFile' route - :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deleteOrder' route - :<|> "store" :> "inventory" :> Verb 'GET 200 '[ JSON] (Map.Map String Int) -- 'getInventory' route - :<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[ JSON] Order -- 'getOrderById' route - :<|> "store" :> "order" :> ReqBody '[ JSON] Order :> Verb 'POST 200 '[ JSON] Order -- 'placeOrder' route - :<|> "user" :> ReqBody '[ JSON] User :> Verb 'POST 200 '[ JSON] () -- 'createUser' route - :<|> "user" :> "createWithArray" :> ReqBody '[ JSON] [User] :> Verb 'POST 200 '[ JSON] () -- 'createUsersWithArrayInput' route - :<|> "user" :> "createWithList" :> ReqBody '[ JSON] [User] :> Verb 'POST 200 '[ JSON] () -- 'createUsersWithListInput' route - :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[ JSON] () -- 'deleteUser' route - :<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[ JSON] User -- 'getUserByName' route - :<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[ JSON] Text -- 'loginUser' route - :<|> "user" :> "logout" :> Verb 'GET 200 '[ JSON] () -- 'logoutUser' route - :<|> "user" :> Capture "username" Text :> ReqBody '[ JSON] User :> Verb 'PUT 200 '[ JSON] () -- 'updateUser' route + = "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route + :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' route + :<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByStatus' route + :<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route + :<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route + :<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route + :<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' route + :<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[JSON] ApiResponse -- 'uploadFile' route + :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteOrder' route + :<|> "store" :> "inventory" :> Verb 'GET 200 '[JSON] (Map.Map String Int) -- 'getInventory' route + :<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[JSON] Order -- 'getOrderById' route + :<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route + :<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] () -- 'createUser' route + :<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithArrayInput' route + :<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithListInput' route + :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteUser' route + :<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[JSON] User -- 'getUserByName' route + :<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[JSON] Text -- 'loginUser' route + :<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] () -- 'logoutUser' route + :<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] () -- 'updateUser' route -- | Server or client configuration, specifying the host and port to query or serve on. data ServerConfig = ServerConfig - { configHost :: String -- ^ Hostname to serve on, e.g. "127.0.0.1" - , configPort :: Int -- ^ Port to serve on, e.g. 8080 + { configHost :: String -- ^ Hostname to serve on, e.g. "127.0.0.1" + , configPort :: Int -- ^ Port to serve on, e.g. 8080 } deriving (Eq, Ord, Show, Read) -- | List of elements parsed from a query. @@ -135,29 +130,23 @@ data CollectionFormat | PipeSeparated -- ^ `value1|value2|value2` | MultiParamArray -- ^ Using multiple GET parameters, e.g. `foo=bar&foo=baz`. Only for GET params. -instance FromHttpApiData a => - FromHttpApiData (QueryList 'CommaSeparated a) where +instance FromHttpApiData a => FromHttpApiData (QueryList 'CommaSeparated a) where parseQueryParam = parseSeparatedQueryList ',' instance FromHttpApiData a => FromHttpApiData (QueryList 'TabSeparated a) where parseQueryParam = parseSeparatedQueryList '\t' -instance FromHttpApiData a => - FromHttpApiData (QueryList 'SpaceSeparated a) where +instance FromHttpApiData a => FromHttpApiData (QueryList 'SpaceSeparated a) where parseQueryParam = parseSeparatedQueryList ' ' instance FromHttpApiData a => FromHttpApiData (QueryList 'PipeSeparated a) where parseQueryParam = parseSeparatedQueryList '|' -instance FromHttpApiData a => - FromHttpApiData (QueryList 'MultiParamArray a) where - parseQueryParam = - error "unimplemented FromHttpApiData for MultiParamArray collection format" +instance FromHttpApiData a => FromHttpApiData (QueryList 'MultiParamArray a) where + parseQueryParam = error "unimplemented FromHttpApiData for MultiParamArray collection format" -parseSeparatedQueryList :: - FromHttpApiData a => Char -> Text -> Either Text (QueryList p a) -parseSeparatedQueryList char = - fmap QueryList . mapM parseQueryParam . T.split (== char) +parseSeparatedQueryList :: FromHttpApiData a => Char -> Text -> Either Text (QueryList p a) +parseSeparatedQueryList char = fmap QueryList . mapM parseQueryParam . T.split (== char) instance ToHttpApiData a => ToHttpApiData (QueryList 'CommaSeparated a) where toQueryParam = formatSeparatedQueryList ',' @@ -172,43 +161,42 @@ instance ToHttpApiData a => ToHttpApiData (QueryList 'PipeSeparated a) where toQueryParam = formatSeparatedQueryList '|' instance ToHttpApiData a => ToHttpApiData (QueryList 'MultiParamArray a) where - toQueryParam = - error "unimplemented ToHttpApiData for MultiParamArray collection format" + toQueryParam = error "unimplemented ToHttpApiData for MultiParamArray collection format" + +formatSeparatedQueryList :: ToHttpApiData a => Char -> QueryList p a -> Text +formatSeparatedQueryList char = T.intercalate (T.singleton char) . map toQueryParam . fromQueryList -formatSeparatedQueryList :: ToHttpApiData a => Char -> QueryList p a -> Text -formatSeparatedQueryList char = - T.intercalate (T.singleton char) . map toQueryParam . fromQueryList -- | Backend for OpenAPIPetstore. -- The backend can be used both for the client and the server. The client generated from the OpenAPIPetstore OpenAPI spec -- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided -- a backend, the API can be served using @runOpenAPIPetstoreServer@. data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend - { addPet :: Pet -> m () {- ^ -} - , deletePet :: Integer -> Maybe Text -> m () {- ^ -} - , findPetsByStatus :: Maybe [Text] -> m [Pet] {- ^ Multiple status values can be provided with comma separated strings -} - , findPetsByTags :: Maybe [Text] -> m [Pet] {- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -} - , getPetById :: Integer -> m Pet {- ^ Returns a single pet -} - , updatePet :: Pet -> m () {- ^ -} - , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m () {- ^ -} - , uploadFile :: Integer -> FormUploadFile -> m ApiResponse {- ^ -} - , deleteOrder :: Text -> m () {- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} - , getInventory :: m (Map.Map String Int) {- ^ Returns a map of status codes to quantities -} - , getOrderById :: Integer -> m Order {- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -} - , placeOrder :: Order -> m Order {- ^ -} - , createUser :: User -> m () {- ^ This can only be done by the logged in user. -} - , createUsersWithArrayInput :: [User] -> m () {- ^ -} - , createUsersWithListInput :: [User] -> m () {- ^ -} - , deleteUser :: Text -> m () {- ^ This can only be done by the logged in user. -} - , getUserByName :: Text -> m User {- ^ -} - , loginUser :: Maybe Text -> Maybe Text -> m Text {- ^ -} - , logoutUser :: m () {- ^ -} - , updateUser :: Text -> User -> m () {- ^ This can only be done by the logged in user. -} + { addPet :: Pet -> m (){- ^ -} + , deletePet :: Integer -> Maybe Text -> m (){- ^ -} + , findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -} + , findPetsByTags :: Maybe [Text] -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -} + , getPetById :: Integer -> m Pet{- ^ Returns a single pet -} + , updatePet :: Pet -> m (){- ^ -} + , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -} + , uploadFile :: Integer -> FormUploadFile -> m ApiResponse{- ^ -} + , deleteOrder :: Text -> m (){- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} + , getInventory :: m (Map.Map String Int){- ^ Returns a map of status codes to quantities -} + , getOrderById :: Integer -> m Order{- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -} + , placeOrder :: Order -> m Order{- ^ -} + , createUser :: User -> m (){- ^ This can only be done by the logged in user. -} + , createUsersWithArrayInput :: [User] -> m (){- ^ -} + , createUsersWithListInput :: [User] -> m (){- ^ -} + , deleteUser :: Text -> m (){- ^ This can only be done by the logged in user. -} + , getUserByName :: Text -> m User{- ^ -} + , loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -} + , logoutUser :: m (){- ^ -} + , updateUser :: Text -> User -> m (){- ^ This can only be done by the logged in user. -} } newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient { runClient :: Manager -> BaseUrl -> ExceptT ServantError IO a - } deriving (Functor) + } deriving Functor instance Applicative OpenAPIPetstoreClient where pure x = OpenAPIPetstoreClient (\_ _ -> pure x) @@ -217,53 +205,58 @@ instance Applicative OpenAPIPetstoreClient where instance Monad OpenAPIPetstoreClient where (OpenAPIPetstoreClient a) >>= f = - OpenAPIPetstoreClient - (\manager url -> do - value <- a manager url - runClient (f value) manager url) + OpenAPIPetstoreClient (\manager url -> do + value <- a manager url + runClient (f value) manager url) instance MonadIO OpenAPIPetstoreClient where liftIO io = OpenAPIPetstoreClient (\_ _ -> liftIO io) createOpenAPIPetstoreClient :: OpenAPIPetstoreBackend OpenAPIPetstoreClient -createOpenAPIPetstoreClient = OpenAPIPetstoreBackend {..} +createOpenAPIPetstoreClient = OpenAPIPetstoreBackend{..} where - ((coerce -> addPet) :<|> (coerce -> deletePet) :<|> (coerce -> findPetsByStatus) :<|> (coerce -> findPetsByTags) :<|> (coerce -> getPetById) :<|> (coerce -> updatePet) :<|> (coerce -> updatePetWithForm) :<|> (coerce -> uploadFile) :<|> (coerce -> deleteOrder) :<|> (coerce -> getInventory) :<|> (coerce -> getOrderById) :<|> (coerce -> placeOrder) :<|> (coerce -> createUser) :<|> (coerce -> createUsersWithArrayInput) :<|> (coerce -> createUsersWithListInput) :<|> (coerce -> deleteUser) :<|> (coerce -> getUserByName) :<|> (coerce -> loginUser) :<|> (coerce -> logoutUser) :<|> (coerce -> updateUser)) = - client (Proxy :: Proxy OpenAPIPetstoreAPI) + ((coerce -> addPet) :<|> + (coerce -> deletePet) :<|> + (coerce -> findPetsByStatus) :<|> + (coerce -> findPetsByTags) :<|> + (coerce -> getPetById) :<|> + (coerce -> updatePet) :<|> + (coerce -> updatePetWithForm) :<|> + (coerce -> uploadFile) :<|> + (coerce -> deleteOrder) :<|> + (coerce -> getInventory) :<|> + (coerce -> getOrderById) :<|> + (coerce -> placeOrder) :<|> + (coerce -> createUser) :<|> + (coerce -> createUsersWithArrayInput) :<|> + (coerce -> createUsersWithListInput) :<|> + (coerce -> deleteUser) :<|> + (coerce -> getUserByName) :<|> + (coerce -> loginUser) :<|> + (coerce -> logoutUser) :<|> + (coerce -> updateUser)) = client (Proxy :: Proxy OpenAPIPetstoreAPI) -- | Run requests in the OpenAPIPetstoreClient monad. -runOpenAPIPetstoreClient :: - ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a +runOpenAPIPetstoreClient :: ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a runOpenAPIPetstoreClient clientConfig cl = do manager <- liftIO $ newManager defaultManagerSettings runOpenAPIPetstoreClientWithManager manager clientConfig cl -- | Run requests in the OpenAPIPetstoreClient monad using a custom manager. -runOpenAPIPetstoreClientWithManager :: - Manager - -> ServerConfig - -> OpenAPIPetstoreClient a - -> ExceptT ServantError IO a +runOpenAPIPetstoreClientWithManager :: Manager -> ServerConfig -> OpenAPIPetstoreClient a -> ExceptT ServantError IO a runOpenAPIPetstoreClientWithManager manager clientConfig cl = - runClient cl manager $ - BaseUrl Http (configHost clientConfig) (configPort clientConfig) "" + runClient cl manager $ BaseUrl Http (configHost clientConfig) (configPort clientConfig) "" -- | Run the OpenAPIPetstore server at the provided host and port. -runOpenAPIPetstoreServer :: - MonadIO m - => ServerConfig - -> OpenAPIPetstoreBackend (ExceptT ServantErr IO) - -> m () -runOpenAPIPetstoreServer ServerConfig {..} backend = - liftIO $ - Warp.runSettings warpSettings $ - serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) +runOpenAPIPetstoreServer :: MonadIO m => ServerConfig -> OpenAPIPetstoreBackend (ExceptT ServantErr IO) -> m () +runOpenAPIPetstoreServer ServerConfig{..} backend = + liftIO $ Warp.runSettings warpSettings $ serve (Proxy :: Proxy OpenAPIPetstoreAPI) (serverFromBackend backend) where - warpSettings = - Warp.defaultSettings & Warp.setPort configPort & - Warp.setHost (fromString configHost) - serverFromBackend OpenAPIPetstoreBackend {..} = - (coerce addPet :<|> coerce deletePet :<|> coerce findPetsByStatus :<|> + warpSettings = Warp.defaultSettings & Warp.setPort configPort & Warp.setHost (fromString configHost) + serverFromBackend OpenAPIPetstoreBackend{..} = + (coerce addPet :<|> + coerce deletePet :<|> + coerce findPetsByStatus :<|> coerce findPetsByTags :<|> coerce getPetById :<|> coerce updatePet :<|> diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs index 96f2faa0335..542556438d2 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/Types.hs @@ -1,111 +1,105 @@ -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} -module OpenAPIPetstore.Types - ( ApiResponse(..) - , Category(..) - , Order(..) - , Pet(..) - , Tag(..) - , User(..) +module OpenAPIPetstore.Types ( + ApiResponse (..), + Category (..), + Order (..), + Pet (..), + Tag (..), + User (..), ) where -import Data.Aeson (FromJSON (..), ToJSON (..), Value, - genericParseJSON, genericToJSON) -import Data.Aeson.Types (Options (..), defaultOptions) -import Data.Function ((&)) -import Data.List (stripPrefix) -import qualified Data.Map as Map -import Data.Maybe (fromMaybe) -import Data.Text (Text) -import qualified Data.Text as T -import GHC.Generics (Generic) +import Data.List (stripPrefix) +import Data.Maybe (fromMaybe) +import Data.Aeson (Value, FromJSON(..), ToJSON(..), genericToJSON, genericParseJSON) +import Data.Aeson.Types (Options(..), defaultOptions) +import Data.Text (Text) +import qualified Data.Text as T +import qualified Data.Map as Map +import GHC.Generics (Generic) +import Data.Function ((&)) + -- | Describes the result of uploading an image resource data ApiResponse = ApiResponse - { apiResponseCode :: Int -- ^ - , apiResponseType :: Text -- ^ - , apiResponseMessage :: Text -- ^ + { apiResponseCode :: Int -- ^ + , apiResponseType :: Text -- ^ + , apiResponseMessage :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON ApiResponse where parseJSON = genericParseJSON (removeFieldLabelPrefix True "apiResponse") - instance ToJSON ApiResponse where toJSON = genericToJSON (removeFieldLabelPrefix False "apiResponse") -- | A category for a pet data Category = Category - { categoryId :: Integer -- ^ - , categoryName :: Text -- ^ + { categoryId :: Integer -- ^ + , categoryName :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON Category where parseJSON = genericParseJSON (removeFieldLabelPrefix True "category") - instance ToJSON Category where toJSON = genericToJSON (removeFieldLabelPrefix False "category") -- | An order for a pets from the pet store data Order = Order - { orderId :: Integer -- ^ - , orderPetId :: Integer -- ^ - , orderQuantity :: Int -- ^ - , orderShipDate :: Integer -- ^ - , orderStatus :: Text -- ^ Order Status - , orderComplete :: Bool -- ^ + { orderId :: Integer -- ^ + , orderPetId :: Integer -- ^ + , orderQuantity :: Int -- ^ + , orderShipDate :: Integer -- ^ + , orderStatus :: Text -- ^ Order Status + , orderComplete :: Bool -- ^ } deriving (Show, Eq, Generic) instance FromJSON Order where parseJSON = genericParseJSON (removeFieldLabelPrefix True "order") - instance ToJSON Order where toJSON = genericToJSON (removeFieldLabelPrefix False "order") -- | A pet for sale in the pet store data Pet = Pet - { petId :: Integer -- ^ - , petCategory :: Category -- ^ - , petName :: Text -- ^ - , petPhotoUrls :: [Text] -- ^ - , petTags :: [Tag] -- ^ - , petStatus :: Text -- ^ pet status in the store + { petId :: Integer -- ^ + , petCategory :: Category -- ^ + , petName :: Text -- ^ + , petPhotoUrls :: [Text] -- ^ + , petTags :: [Tag] -- ^ + , petStatus :: Text -- ^ pet status in the store } deriving (Show, Eq, Generic) instance FromJSON Pet where parseJSON = genericParseJSON (removeFieldLabelPrefix True "pet") - instance ToJSON Pet where toJSON = genericToJSON (removeFieldLabelPrefix False "pet") -- | A tag for a pet data Tag = Tag - { tagId :: Integer -- ^ - , tagName :: Text -- ^ + { tagId :: Integer -- ^ + , tagName :: Text -- ^ } deriving (Show, Eq, Generic) instance FromJSON Tag where parseJSON = genericParseJSON (removeFieldLabelPrefix True "tag") - instance ToJSON Tag where toJSON = genericToJSON (removeFieldLabelPrefix False "tag") -- | A User who is purchasing from the pet store data User = User - { userId :: Integer -- ^ - , userUsername :: Text -- ^ - , userFirstName :: Text -- ^ - , userLastName :: Text -- ^ - , userEmail :: Text -- ^ - , userPassword :: Text -- ^ - , userPhone :: Text -- ^ + { userId :: Integer -- ^ + , userUsername :: Text -- ^ + , userFirstName :: Text -- ^ + , userLastName :: Text -- ^ + , userEmail :: Text -- ^ + , userPassword :: Text -- ^ + , userPhone :: Text -- ^ , userUserStatus :: Int -- ^ User Status } deriving (Show, Eq, Generic) instance FromJSON User where parseJSON = genericParseJSON (removeFieldLabelPrefix True "user") - instance ToJSON User where toJSON = genericToJSON (removeFieldLabelPrefix False "user") @@ -114,13 +108,9 @@ instance ToJSON User where removeFieldLabelPrefix :: Bool -> String -> Options removeFieldLabelPrefix forParsing prefix = defaultOptions - { fieldLabelModifier = - fromMaybe (error ("did not find prefix " ++ prefix)) . - stripPrefix prefix . replaceSpecialChars - } + {fieldLabelModifier = fromMaybe (error ("did not find prefix " ++ prefix)) . stripPrefix prefix . replaceSpecialChars} where - replaceSpecialChars field = - foldl (&) field (map mkCharReplacement specialChars) + replaceSpecialChars field = foldl (&) field (map mkCharReplacement specialChars) specialChars = [ ("@", "'At") , ("\\", "'Back_Slash") @@ -157,8 +147,7 @@ removeFieldLabelPrefix forParsing prefix = , ("?", "'Question_Mark") , (">=", "'Greater_Than_Or_Equal_To") ] - mkCharReplacement (replaceStr, searchStr) = - T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack + mkCharReplacement (replaceStr, searchStr) = T.unpack . replacer (T.pack searchStr) (T.pack replaceStr) . T.pack replacer = if forParsing then flip T.replace -- GitLab From ab93f0eaf7882ac72990186e292776348bfe99ba Mon Sep 17 00:00:00 2001 From: Jon Schoning <jonschoning@gmail.com> Date: Thu, 20 Sep 2018 22:11:39 -0500 Subject: [PATCH 10/10] update example-app & tests-integration for OAS2 code --- bin/utils/ensure-up-to-date | 2 +- .../haskell-http-client/example-app/Main.hs | 18 ++++++++++++------ .../haskell-http-client/example-app/stack.yaml | 2 +- .../tests-integration/tests/Test.hs | 16 +++++++++++----- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 4f8e213f976..5125fe93d38 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -30,7 +30,7 @@ sleep 5 ./bin/typescript-node-petstore-all.sh > /dev/null 2>&1 ./bin/typescript-inversify-petstore.sh > /dev/null 2>&1 ./bin/rust-server-petstore.sh > /dev/null 2>&1 -./bin/openapi3/haskell-http-client-petstore.sh > /dev/null 2>&1 +./bin/haskell-http-client-petstore.sh > /dev/null 2>&1 ./bin/csharp-petstore.sh > /dev/null 2>&1 ./bin/meta-codegen.sh > /dev/null 2>&1 ./bin/utils/export_docs_generators.sh > /dev/null 2>&1 diff --git a/samples/client/petstore/haskell-http-client/example-app/Main.hs b/samples/client/petstore/haskell-http-client/example-app/Main.hs index f6f215fdb67..fa86cbbbe17 100644 --- a/samples/client/petstore/haskell-http-client/example-app/Main.hs +++ b/samples/client/petstore/haskell-http-client/example-app/Main.hs @@ -155,7 +155,8 @@ runPet mgr config = do -- * STORE - +instance S.Consumes S.PlaceOrder S.MimeJSON + runStore :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO () runStore mgr config = do @@ -167,7 +168,7 @@ runStore mgr config = do -- placeOrder now <- TI.getCurrentTime - let placeOrderRequest = S.placeOrder (S.Accept S.MimeJSON) (S.mkOrder { S.orderId = Just 21, S.orderQuantity = Just 210, S.orderShipDate = Just (S.DateTime now)}) + let placeOrderRequest = S.placeOrder (S.ContentType S.MimeJSON) (S.Accept S.MimeJSON) (S.mkOrder { S.orderId = Just 21, S.orderQuantity = Just 210, S.orderShipDate = Just (S.DateTime now)}) placeOrderResult <- S.dispatchMime mgr config placeOrderRequest mapM_ (\r -> putStrLn $ "placeOrderResult: " <> show r) placeOrderResult @@ -188,22 +189,27 @@ runStore mgr config = do -- * USER +instance S.Consumes S.CreateUser S.MimeJSON +instance S.Consumes S.CreateUsersWithArrayInput S.MimeJSON +instance S.Consumes S.CreateUsersWithListInput S.MimeJSON +instance S.Consumes S.UpdateUser S.MimeJSON + runUser :: NH.Manager -> S.OpenAPIPetstoreConfig -> IO () runUser mgr config = do let username = "hsusername" -- createUser let user = S.mkUser { S.userId = Just 21, S.userUsername = Just username } - let createUserRequest = S.createUser user + let createUserRequest = S.createUser (S.ContentType S.MimeJSON) user _ <- S.dispatchLbs mgr config createUserRequest -- can use lenses (model record names are appended L) to view or modify records let users = take 8 $ drop 1 $ iterate (L.over S.userUsernameL (fmap (<> "*")) . L.over S.userIdL (fmap (+ 1))) user - let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.User2 users) + let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.ContentType S.MimeJSON) (S.User2 users) _ <- S.dispatchLbs mgr config createUsersWithArrayInputRequest -- createUsersWithArrayInput - let createUsersWithListInputRequest = S.createUsersWithListInput (S.User2 users) + let createUsersWithListInputRequest = S.createUsersWithListInput (S.ContentType S.MimeJSON) (S.User2 users) _ <- S.dispatchLbs mgr config createUsersWithListInputRequest -- getUserByName @@ -217,7 +223,7 @@ runUser mgr config = do BCL.putStrLn $ "loginUser: " <> (NH.responseBody loginUserResult) -- updateUser - let updateUserRequest = S.updateUser (user { S.userEmail = Just "xyz@example.com" }) (S.Username username) + let updateUserRequest = S.updateUser (S.ContentType S.MimeJSON) (user { S.userEmail = Just "xyz@example.com" }) (S.Username username) _ <- S.dispatchLbs mgr config updateUserRequest -- logoutUser diff --git a/samples/client/petstore/haskell-http-client/example-app/stack.yaml b/samples/client/petstore/haskell-http-client/example-app/stack.yaml index de32b243730..76328ae5161 100644 --- a/samples/client/petstore/haskell-http-client/example-app/stack.yaml +++ b/samples/client/petstore/haskell-http-client/example-app/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-10.0 +resolver: lts-10.10 packages: - location: '.' - location: '..' diff --git a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs index 21e5157bc08..fa8a2bf8ddc 100644 --- a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs @@ -164,6 +164,7 @@ testPetOps mgr config = -- * STORE TESTS +instance S.Consumes S.PlaceOrder S.MimeJSON testStoreOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec testStoreOps mgr config = do @@ -183,7 +184,7 @@ testStoreOps mgr config = do it "placeOrder" $ do now <- TI.getCurrentTime - let placeOrderRequest = S.placeOrder (S.Accept S.MimeJSON) + let placeOrderRequest = S.placeOrder (S.ContentType S.MimeJSON) (S.Accept S.MimeJSON) (S.mkOrder { S.orderId = Just 21 , S.orderQuantity = Just 210 @@ -221,6 +222,11 @@ testStoreOps mgr config = do -- * USER TESTS +instance S.Consumes S.CreateUser S.MimeJSON +instance S.Consumes S.CreateUsersWithArrayInput S.MimeJSON +instance S.Consumes S.CreateUsersWithListInput S.MimeJSON +instance S.Consumes S.UpdateUser S.MimeJSON + testUserOps :: NH.Manager -> S.OpenAPIPetstoreConfig -> Spec testUserOps mgr config = do @@ -245,19 +251,19 @@ testUserOps mgr config = do before (pure _user) $ it "createUser" $ \user -> do - let createUserRequest = S.createUser user + let createUserRequest = S.createUser (S.ContentType S.MimeJSON) user createUserResult <- S.dispatchLbs mgr config createUserRequest NH.responseStatus createUserResult `shouldBe` NH.status200 before (pure _users) $ it "createUsersWithArrayInput" $ \users -> do - let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.User2 users) + let createUsersWithArrayInputRequest = S.createUsersWithArrayInput (S.ContentType S.MimeJSON) (S.User2 users) createUsersWithArrayInputResult <- S.dispatchLbs mgr config createUsersWithArrayInputRequest NH.responseStatus createUsersWithArrayInputResult `shouldBe` NH.status200 before (pure _users) $ it "createUsersWithListInput" $ \users -> do - let createUsersWithListInputRequest = S.createUsersWithListInput (S.User2 users) + let createUsersWithListInputRequest = S.createUsersWithListInput (S.ContentType S.MimeJSON) (S.User2 users) createUsersWithListInputResult <- S.dispatchLbs mgr config createUsersWithListInputRequest NH.responseStatus createUsersWithListInputResult `shouldBe` NH.status200 @@ -278,7 +284,7 @@ testUserOps mgr config = do before (pure (_username, _user)) $ it "updateUser" $ \(username, user) -> do - let updateUserRequest = S.updateUser user (S.Username username) + let updateUserRequest = S.updateUser (S.ContentType S.MimeJSON) user (S.Username username) updateUserResult <- S.dispatchLbs mgr config updateUserRequest NH.responseStatus updateUserResult `shouldBe` NH.status200 -- GitLab