From e45b3784f1665847c0e5cef4e4908797c7298ace Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 6 May 2018 23:56:59 +0800 Subject: [PATCH] Fix NPE with Haskell client generator with OAS3 spec (#334) * fix NPE with haskell client oas3, better type check * better unknown type check --- .../openapitools/codegen/DefaultCodegen.java | 23 +- .../languages/HaskellHttpClientCodegen.java | 8 +- .../petstore/haskell-http-client/README.md | 36 +- .../petstore/haskell-http-client/git_push.sh | 2 +- .../lib/SwaggerPetstore.hs | 4 +- .../lib/SwaggerPetstore/API.hs | 4 +- .../lib/SwaggerPetstore/API/AnotherFake.hs | 4 +- .../lib/SwaggerPetstore/API/Fake.hs | 81 +- .../API/FakeClassnameTags123.hs | 4 +- .../lib/SwaggerPetstore/API/Pet.hs | 12 +- .../lib/SwaggerPetstore/API/Store.hs | 16 +- .../lib/SwaggerPetstore/API/User.hs | 52 +- .../lib/SwaggerPetstore/Client.hs | 4 +- .../lib/SwaggerPetstore/Core.hs | 6 +- .../lib/SwaggerPetstore/Logging.hs | 4 +- .../lib/SwaggerPetstore/MimeTypes.hs | 4 +- .../lib/SwaggerPetstore/Model.hs | 81 +- .../lib/SwaggerPetstore/ModelLens.hs | 38 +- .../petstore/haskell-http-client/openapi.yaml | 1235 ++++++++--------- .../swagger-petstore.cabal | 4 +- .../haskell-http-client/tests/Instances.hs | 23 +- .../haskell-http-client/tests/Test.hs | 3 - 22 files changed, 798 insertions(+), 850 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 556afd426fb..0b74176e5b7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1233,7 +1233,7 @@ public class DefaultCodegen implements CodegenConfig { } } - if (StringUtils.isNotBlank(schema.get$ref())) { // object + if (StringUtils.isNotBlank(schema.get$ref())) { // reference to another definition/schema // get the schema/model name from $ref String schemaName = ModelUtils.getSimpleRef(schema.get$ref()); if (StringUtils.isNotEmpty(schemaName)) { @@ -1242,7 +1242,7 @@ public class DefaultCodegen implements CodegenConfig { LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'"); return "object"; } - } else { // primitive type (non-model) + } else { // primitive type or model return getAlias(getPrimitiveType(schema)); } } @@ -1255,7 +1255,9 @@ public class DefaultCodegen implements CodegenConfig { * @return type */ private static String getPrimitiveType(Schema schema) { - if (ModelUtils.isStringSchema(schema) && "number".equals(schema.getFormat())) { + if (schema == null) { + throw new RuntimeException("schema cannnot be null in getPrimitiveType"); + } else if (ModelUtils.isStringSchema(schema) && "number".equals(schema.getFormat())) { // special handle of type: string, format: number return "BigDecimal"; } else if (ModelUtils.isByteArraySchema(schema)) { @@ -1294,16 +1296,13 @@ public class DefaultCodegen implements CodegenConfig { return "UUID"; } else if (ModelUtils.isStringSchema(schema)) { return "string"; - } else { - if (schema != null) { - // TODO the following check should be covered by ModelUtils.isMapSchema(schema) above so can be removed - if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && schema.getAdditionalProperties() != null) { - return "map"; - } else { - return schema.getType(); - } - } + } else if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { // having property implies it's a model + return "object"; + } else if (StringUtils.isNotEmpty(schema.getType())) { + LOGGER.warn("Unknown type found in the schema: " + schema.getType()); + return schema.getType(); } + return "object"; } 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 4cd98a75a78..ab45e60ba18 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 @@ -954,8 +954,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC String xPath = "[\"" + escapeText(op.path) + "\"]"; if (op.getHasPathParams()) { for (CodegenParameter param : op.allParams) { - if(param.isPathParam) { - xPath = xPath.replaceAll("\\{" + param.baseName + "\\}", "\",toPath " + param.paramName + ",\""); + if (param.isPathParam) { + xPath = xPath.replaceAll("\\{" + param.baseName + "\\}", "\",toPath " + param.paramName + ",\""); } } xPath = xPath.replaceAll(",\"\",", ","); @@ -1195,8 +1195,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC cm.isEnum = genEnums && cm.isEnum; if (cm.isAlias) { String dataType = cm.dataType; - if(dataType == null && cm.isArrayModel) { // isAlias + arrayModelType missing "datatype" - dataType = "[" + cm.arrayModelType +"]" ; + if (dataType == null && cm.isArrayModel) { // isAlias + arrayModelType missing "datatype" + dataType = "[" + cm.arrayModelType + "]"; } cm.vendorExtensions.put(X_DATA_TYPE, dataType); } diff --git a/samples/client/petstore/haskell-http-client/README.md b/samples/client/petstore/haskell-http-client/README.md index e140466c0a3..d807a54167c 100644 --- a/samples/client/petstore/haskell-http-client/README.md +++ b/samples/client/petstore/haskell-http-client/README.md @@ -1,8 +1,8 @@ -## Swagger Auto-Generated [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) Bindings to `Swagger Petstore` +## OpenAPI Auto-Generated [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) Bindings to `Swagger Petstore` -The library in `lib` provides auto-generated-from-Swagger [http-client](https://www.stackage.org/lts-10.0/package/http-client-0.5.7.1) bindings to the Swagger Petstore API. +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 Swagger Petstore API. -OpenApi Version: 3.0.1 +OpenApi Version: 3.0.0 ## Installation @@ -29,12 +29,12 @@ from the stack.yaml file and run `stack haddock` again. stack test ``` -## Swagger-Codegen +## OpenAPI-Generator The code generator that produced this library, and which explains how -to obtain and use the swagger-codegen cli tool lives at +to obtain and use the openapi-generator cli tool lives at -https://github.com/swagger-api/swagger-codegen +https://openapi-generator.tech The _language_ argument (`--lang`) passed to the cli tool used should be @@ -42,7 +42,7 @@ The _language_ argument (`--lang`) passed to the cli tool used should be haskell-http-client ``` -### Unsupported Swagger Features +### Unsupported OpenAPI Features * Model Inheritance @@ -65,7 +65,7 @@ These options allow some customization of the code generation process. | configType | Set the name of the type used for configuration | | SwaggerPetstoreConfig | | dateFormat | format string used to parse/render a date | %Y-%m-%d | %Y-%m-%d | | dateTimeFormat | format string used to parse/render a datetime. (Defaults to [formatISO8601Millis][1] when not provided) | | | -| generateEnums | Generate specific datatypes for swagger enums | true | true | +| generateEnums | Generate specific datatypes for OpenAPI enums | true | true | | generateFormUrlEncodedInstances | Generate FromForm/ToForm instances for models used by x-www-form-urlencoded operations (model fields must be primitive types) | true | true | | generateLenses | Generate Lens optics for Models | true | true | | generateModelConstructors | Generate smart constructors (only supply required fields) for models | true | true | @@ -80,28 +80,28 @@ These options allow some customization of the code generation process. An example setting _strictFields_ and _dateTimeFormat_: ``` -java -jar swagger-codegen-cli.jar generate -i petstore.yaml -l haskell-http-client -o output/haskell-http-client -DstrictFields=true -DdateTimeFormat="%Y-%m-%dT%H:%M:%S%Q%z" +java -jar openapi-generator-cli.jar generate -i petstore.yaml -l haskell-http-client -o output/haskell-http-client -DstrictFields=true -DdateTimeFormat="%Y-%m-%dT%H:%M:%S%Q%z" ``` View the full list of Codegen "config option" parameters with the command: ``` -java -jar swagger-codegen-cli.jar config-help -l haskell-http-client +java -jar openapi-generator-cli.jar config-help -l haskell-http-client ``` ## Usage Notes -### Example SwaggerPetstore Haddock documentation +### Example Petstore Haddock documentation -An example of the generated haddock documentation targeting the server http://petstore.swagger.io/ (SwaggerPetstore) can be found [here][2] +An example of the generated haddock documentation targeting the server http://petstore.swagger.io/ (Petstore) can be found [here][2] [2]: https://hackage.haskell.org/package/swagger-petstore -### Example SwaggerPetstore App +### Example Petstore App An example application using the auto-generated haskell-http-client bindings for the server http://petstore.swagger.io/ can be found [here][3] -[3]: https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/haskell-http-client/example-app +[3]: https://github.com/openapitools/openapi-generator/master/samples/client/petstore/haskell-http-client/example-app This library is intended to be imported qualified. @@ -120,7 +120,7 @@ This library is intended to be imported qualified. ### MimeTypes -This library adds type safety around what swagger specifies as +This library adds type safety around what OpenAPI specifies as Produces and Consumes for each Operation (e.g. the list of MIME types an Operation can Produce (using 'accept' headers) and Consume (using 'content-type' headers). @@ -153,10 +153,10 @@ this would indicate that: * the _addFoo_ operation can set it's body param of _FooModel_ via `setBodyParam` * the _addFoo_ operation can set 2 different optional parameters via `applyOptionalParam` -If the swagger spec doesn't declare it can accept or produce a certain +If the OpenAPI spec doesn't declare it can accept or produce a certain MIME type for a given Operation, you should either add a Produces or Consumes instance for the desired MIME types (assuming the server -supports it), use `dispatchLbsUnsafe` or modify the swagger spec and +supports it), use `dispatchLbsUnsafe` or modify the OpenAPI spec and run the generator again. New MIME type instances can be added via MimeType/MimeRender/MimeUnrender @@ -168,7 +168,7 @@ Operations using x-www-form-urlencoded which use those models. ### Authentication -A haskell data type will be generated for each swagger authentication type. +A haskell data type will be generated for each OpenAPI authentication type. If for example the AuthMethod `AuthOAuthFoo` is generated for OAuth operations, then `addAuthMethod` should be used to add the AuthMethod config. diff --git a/samples/client/petstore/haskell-http-client/git_push.sh b/samples/client/petstore/haskell-http-client/git_push.sh index ae01b182ae9..8442b80bb44 100644 --- a/samples/client/petstore/haskell-http-client/git_push.sh +++ b/samples/client/petstore/haskell-http-client/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" git_user_id=$1 git_repo_id=$2 diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore.hs index 90ae8bf9b32..2ab40702d9f 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs index f2b59515fef..2e45deb375a 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/AnotherFake.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/AnotherFake.hs index 114b8372eac..7052a85931d 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/AnotherFake.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/AnotherFake.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Fake.hs index ec848695c92..99de9e2281f 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Fake.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -65,17 +65,19 @@ import qualified Prelude as P -- Test serialization of outer boolean types -- fakeOuterBooleanSerialize - :: (Consumes FakeOuterBooleanSerialize contentType) - => ContentType contentType -- ^ request content-type ('MimeType') - -> Accept accept -- ^ request accept ('MimeType') - -> SwaggerPetstoreRequest FakeOuterBooleanSerialize contentType OuterBoolean accept -fakeOuterBooleanSerialize _ _ = + :: (Consumes FakeOuterBooleanSerialize MimeJSON) + => Accept accept -- ^ request accept ('MimeType') + -> SwaggerPetstoreRequest FakeOuterBooleanSerialize MimeJSON Bool accept +fakeOuterBooleanSerialize _ = _mkRequest "POST" ["/fake/outer/boolean"] data FakeOuterBooleanSerialize --- | /Body Param/ "boolean_post_body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BooleanPostBody +-- | /Body Param/ "body" - Input boolean as post body +instance HasBodyParam FakeOuterBooleanSerialize BodyBool + +-- | @application/json@ +instance Consumes FakeOuterBooleanSerialize MimeJSON -- | @*/*@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype @@ -88,11 +90,10 @@ instance MimeType mtype => Produces FakeOuterBooleanSerialize mtype -- Test serialization of object with outer number type -- fakeOuterCompositeSerialize - :: (Consumes FakeOuterCompositeSerialize contentType) - => ContentType contentType -- ^ request content-type ('MimeType') - -> Accept accept -- ^ request accept ('MimeType') - -> SwaggerPetstoreRequest FakeOuterCompositeSerialize contentType OuterComposite accept -fakeOuterCompositeSerialize _ _ = + :: (Consumes FakeOuterCompositeSerialize MimeJSON) + => Accept accept -- ^ request accept ('MimeType') + -> SwaggerPetstoreRequest FakeOuterCompositeSerialize MimeJSON OuterComposite accept +fakeOuterCompositeSerialize _ = _mkRequest "POST" ["/fake/outer/composite"] data FakeOuterCompositeSerialize @@ -100,6 +101,9 @@ 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 @@ -111,11 +115,10 @@ instance MimeType mtype => Produces FakeOuterCompositeSerialize mtype -- Test serialization of outer number types -- fakeOuterNumberSerialize - :: (Consumes FakeOuterNumberSerialize contentType) - => ContentType contentType -- ^ request content-type ('MimeType') - -> Accept accept -- ^ request accept ('MimeType') - -> SwaggerPetstoreRequest FakeOuterNumberSerialize contentType OuterNumber accept -fakeOuterNumberSerialize _ _ = + :: (Consumes FakeOuterNumberSerialize MimeJSON) + => Accept accept -- ^ request accept ('MimeType') + -> SwaggerPetstoreRequest FakeOuterNumberSerialize MimeJSON Double accept +fakeOuterNumberSerialize _ = _mkRequest "POST" ["/fake/outer/number"] data FakeOuterNumberSerialize @@ -123,6 +126,9 @@ data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body instance HasBodyParam FakeOuterNumberSerialize Body +-- | @application/json@ +instance Consumes FakeOuterNumberSerialize MimeJSON + -- | @*/*@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype @@ -134,11 +140,10 @@ instance MimeType mtype => Produces FakeOuterNumberSerialize mtype -- Test serialization of outer string types -- fakeOuterStringSerialize - :: (Consumes FakeOuterStringSerialize contentType) - => ContentType contentType -- ^ request content-type ('MimeType') - -> Accept accept -- ^ request accept ('MimeType') - -> SwaggerPetstoreRequest FakeOuterStringSerialize contentType OuterString accept -fakeOuterStringSerialize _ _ = + :: (Consumes FakeOuterStringSerialize MimeJSON) + => Accept accept -- ^ request accept ('MimeType') + -> SwaggerPetstoreRequest FakeOuterStringSerialize MimeJSON Text accept +fakeOuterStringSerialize _ = _mkRequest "POST" ["/fake/outer/string"] data FakeOuterStringSerialize @@ -146,33 +151,13 @@ data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body instance HasBodyParam FakeOuterStringSerialize BodyText +-- | @application/json@ +instance Consumes FakeOuterStringSerialize MimeJSON + -- | @*/*@ instance MimeType mtype => Produces FakeOuterStringSerialize mtype --- *** testBodyWithQueryParams - --- | @PUT \/fake\/body-with-query-params@ --- -testBodyWithQueryParams - :: (Consumes TestBodyWithQueryParams MimeJSON, MimeRender MimeJSON User) - => User -- ^ "user" - -> Query -- ^ "query" - -> SwaggerPetstoreRequest TestBodyWithQueryParams MimeJSON NoContent MimeNoContent -testBodyWithQueryParams user (Query query) = - _mkRequest "PUT" ["/fake/body-with-query-params"] - `setBodyParam` user - `setQuery` toQuery ("query", Just query) - -data TestBodyWithQueryParams -instance HasBodyParam TestBodyWithQueryParams User - --- | @application/json@ -instance Consumes TestBodyWithQueryParams MimeJSON - -instance Produces TestBodyWithQueryParams MimeNoContent - - -- *** testClientModel -- | @PATCH \/fake@ @@ -323,7 +308,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 MultiParamArray ("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/SwaggerPetstore/API/FakeClassnameTags123.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/FakeClassnameTags123.hs index 260d3ed9218..51a9d556199 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/FakeClassnameTags123.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/FakeClassnameTags123.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Pet.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Pet.hs index 4abb0565bed..2ac90de7dce 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Pet.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Pet.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -81,10 +81,10 @@ data AddPet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store instance HasBodyParam AddPet Pet --- | @application/json@ -instance Consumes AddPet MimeJSON -- | @application/xml@ instance Consumes AddPet MimeXML +-- | @application/json@ +instance Consumes AddPet MimeJSON instance Produces AddPet MimeNoContent @@ -217,10 +217,10 @@ data UpdatePet -- | /Body Param/ "Pet" - Pet object that needs to be added to the store instance HasBodyParam UpdatePet Pet --- | @application/json@ -instance Consumes UpdatePet MimeJSON -- | @application/xml@ instance Consumes UpdatePet MimeXML +-- | @application/json@ +instance Consumes UpdatePet MimeJSON instance Produces UpdatePet MimeNoContent diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Store.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Store.hs index ca70d4242d8..8b121e0207b 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Store.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/Store.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -129,12 +129,11 @@ instance Produces GetOrderById MimeJSON -- Place an order for a pet -- placeOrder - :: (Consumes PlaceOrder contentType, MimeRender contentType Order) - => ContentType contentType -- ^ request content-type ('MimeType') - -> Accept accept -- ^ request accept ('MimeType') + :: (Consumes PlaceOrder MimeJSON, MimeRender MimeJSON Order) + => Accept accept -- ^ request accept ('MimeType') -> Order -- ^ "order" - order placed for purchasing the pet - -> SwaggerPetstoreRequest PlaceOrder contentType Order accept -placeOrder _ _ order = + -> SwaggerPetstoreRequest PlaceOrder MimeJSON Order accept +placeOrder _ order = _mkRequest "POST" ["/store/order"] `setBodyParam` order @@ -143,6 +142,9 @@ 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/SwaggerPetstore/API/User.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/User.hs index 4f0b2a046be..02bc77b7baf 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/User.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/API/User.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -67,11 +67,10 @@ import qualified Prelude as P -- This can only be done by the logged in user. -- createUser - :: (Consumes CreateUser contentType, MimeRender contentType User) - => ContentType contentType -- ^ request content-type ('MimeType') - -> User -- ^ "user" - Created user object - -> SwaggerPetstoreRequest CreateUser contentType NoContent MimeNoContent -createUser _ user = + :: (Consumes CreateUser MimeJSON, MimeRender MimeJSON User) + => User -- ^ "user" - Created user object + -> SwaggerPetstoreRequest CreateUser MimeJSON NoContent MimeNoContent +createUser user = _mkRequest "POST" ["/user"] `setBodyParam` user @@ -80,6 +79,9 @@ data CreateUser -- | /Body Param/ "User" - Created user object instance HasBodyParam CreateUser User +-- | @application/json@ +instance Consumes CreateUser MimeJSON + instance Produces CreateUser MimeNoContent @@ -90,11 +92,10 @@ instance Produces CreateUser MimeNoContent -- Creates list of users with given input array -- createUsersWithArrayInput - :: (Consumes CreateUsersWithArrayInput contentType, MimeRender contentType User2) - => ContentType contentType -- ^ request content-type ('MimeType') - -> User2 -- ^ "user" - List of user object - -> SwaggerPetstoreRequest CreateUsersWithArrayInput contentType NoContent MimeNoContent -createUsersWithArrayInput _ user = + :: (Consumes CreateUsersWithArrayInput MimeJSON, MimeRender MimeJSON User2) + => User2 -- ^ "user" - List of user object + -> SwaggerPetstoreRequest CreateUsersWithArrayInput MimeJSON NoContent MimeNoContent +createUsersWithArrayInput user = _mkRequest "POST" ["/user/createWithArray"] `setBodyParam` user @@ -103,6 +104,9 @@ data CreateUsersWithArrayInput -- | /Body Param/ "User" - List of user object instance HasBodyParam CreateUsersWithArrayInput User2 +-- | @application/json@ +instance Consumes CreateUsersWithArrayInput MimeJSON + instance Produces CreateUsersWithArrayInput MimeNoContent @@ -113,11 +117,10 @@ instance Produces CreateUsersWithArrayInput MimeNoContent -- Creates list of users with given input array -- createUsersWithListInput - :: (Consumes CreateUsersWithListInput contentType, MimeRender contentType User2) - => ContentType contentType -- ^ request content-type ('MimeType') - -> User2 -- ^ "user" - List of user object - -> SwaggerPetstoreRequest CreateUsersWithListInput contentType NoContent MimeNoContent -createUsersWithListInput _ user = + :: (Consumes CreateUsersWithListInput MimeJSON, MimeRender MimeJSON User2) + => User2 -- ^ "user" - List of user object + -> SwaggerPetstoreRequest CreateUsersWithListInput MimeJSON NoContent MimeNoContent +createUsersWithListInput user = _mkRequest "POST" ["/user/createWithList"] `setBodyParam` user @@ -126,6 +129,9 @@ data CreateUsersWithListInput -- | /Body Param/ "User" - List of user object instance HasBodyParam CreateUsersWithListInput User2 +-- | @application/json@ +instance Consumes CreateUsersWithListInput MimeJSON + instance Produces CreateUsersWithListInput MimeNoContent @@ -218,12 +224,11 @@ instance Produces LogoutUser MimeNoContent -- This can only be done by the logged in user. -- updateUser - :: (Consumes UpdateUser contentType, MimeRender contentType User) - => ContentType contentType -- ^ request content-type ('MimeType') - -> User -- ^ "user" - Updated user object + :: (Consumes UpdateUser MimeJSON, MimeRender MimeJSON User) + => User -- ^ "user" - Updated user object -> Username -- ^ "username" - name that need to be deleted - -> SwaggerPetstoreRequest UpdateUser contentType NoContent MimeNoContent -updateUser _ user (Username username) = + -> SwaggerPetstoreRequest UpdateUser MimeJSON NoContent MimeNoContent +updateUser user (Username username) = _mkRequest "PUT" ["/user/",toPath username] `setBodyParam` user @@ -232,5 +237,8 @@ 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/SwaggerPetstore/Client.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Client.hs index a82ced1025f..ab832b33773 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Client.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Client.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs index 0c06a14483a..30123608564 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Core.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -316,7 +316,7 @@ toQuery :: WH.ToHttpApiData a => (BC.ByteString, Maybe a) -> [NH.QueryItem] toQuery x = [(fmap . fmap) toQueryParam x] where toQueryParam = T.encodeUtf8 . WH.toQueryParam --- *** Swagger `CollectionFormat` Utils +-- *** OpenAPI `CollectionFormat` Utils -- | Determines the format of the array if type array is used. data CollectionFormat diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Logging.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Logging.hs index e74d8d04d9f..6cb71c73552 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Logging.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Logging.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/MimeTypes.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/MimeTypes.hs index a49dd8a57de..9f1b826760d 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/MimeTypes.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/MimeTypes.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs index 9c4cc0c28c8..d56c9f0fb9c 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/Model.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -76,12 +76,12 @@ newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) -- ** Body 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) + -- ** BodyText newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON) --- ** BooleanPostBody -newtype BooleanPostBody = BooleanPostBody { unBooleanPostBody :: Bool } deriving (P.Eq, P.Show, A.ToJSON) - -- ** Byte newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) @@ -92,7 +92,7 @@ newtype Callback = Callback { unCallback :: Text } 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) @@ -169,9 +169,6 @@ newtype PatternWithoutDelimiter = PatternWithoutDelimiter { unPatternWithoutDeli -- ** PetId newtype PetId = PetId { unPetId :: Integer } deriving (P.Eq, P.Show) --- ** Query -newtype Query = Query { unQuery :: Text } deriving (P.Eq, P.Show) - -- ** RequestBody newtype RequestBody = RequestBody { unRequestBody :: Text } deriving (P.Eq, P.Show, A.ToJSON) @@ -260,10 +257,31 @@ mkAnimal animalClassName = -- ** AnimalFarm -- | AnimalFarm -newtype AnimalFarm = AnimalFarm - { unAnimalFarm :: [Animal] - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON) +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 + [ + ] + + +-- | Construct a value of type 'AnimalFarm' (by applying it's required fields, if any) +mkAnimalFarm + :: AnimalFarm +mkAnimalFarm = + AnimalFarm + { + } -- ** ApiResponse -- | ApiResponse @@ -897,7 +915,7 @@ mkModel200Response = -- ** ModelList -- | ModelList data ModelList = ModelList - { modelList123List :: !(Maybe Text) -- ^ "123-list" + { modelList123list :: !(Maybe Text) -- ^ "123-list" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON ModelList @@ -910,7 +928,7 @@ instance A.FromJSON ModelList where instance A.ToJSON ModelList where toJSON ModelList {..} = _omitNulls - [ "123-list" .= modelList123List + [ "123-list" .= modelList123list ] @@ -919,7 +937,7 @@ mkModelList :: ModelList mkModelList = ModelList - { modelList123List = Nothing + { modelList123list = Nothing } -- ** ModelReturn @@ -958,7 +976,7 @@ data Name = Name { nameName :: !(Int) -- ^ /Required/ "name" , nameSnakeCase :: !(Maybe Int) -- ^ "snake_case" , nameProperty :: !(Maybe Text) -- ^ "property" - , name123Number :: !(Maybe Int) -- ^ "123Number" + , name123number :: !(Maybe Int) -- ^ "123Number" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON Name @@ -977,7 +995,7 @@ instance A.ToJSON Name where [ "name" .= nameName , "snake_case" .= nameSnakeCase , "property" .= nameProperty - , "123Number" .= name123Number + , "123Number" .= name123number ] @@ -990,7 +1008,7 @@ mkName nameName = { nameName , nameSnakeCase = Nothing , nameProperty = Nothing - , name123Number = Nothing + , name123number = Nothing } -- ** NumberOnly @@ -1069,19 +1087,12 @@ mkOrder = , orderComplete = Nothing } --- ** OuterBoolean --- | OuterBoolean -newtype OuterBoolean = OuterBoolean - { unOuterBoolean :: Bool - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON) - - -- ** OuterComposite -- | OuterComposite data OuterComposite = OuterComposite - { outerCompositeMyNumber :: !(Maybe OuterNumber) -- ^ "my_number" - , outerCompositeMyString :: !(Maybe OuterString) -- ^ "my_string" - , outerCompositeMyBoolean :: !(Maybe OuterBoolean) -- ^ "my_boolean" + { outerCompositeMyNumber :: !(Maybe Double) -- ^ "my_number" + , outerCompositeMyString :: !(Maybe Text) -- ^ "my_string" + , outerCompositeMyBoolean :: !(Maybe Bool) -- ^ "my_boolean" } deriving (P.Show, P.Eq, P.Typeable) -- | FromJSON OuterComposite @@ -1112,20 +1123,6 @@ mkOuterComposite = , outerCompositeMyBoolean = Nothing } --- ** OuterNumber --- | OuterNumber -newtype OuterNumber = OuterNumber - { unOuterNumber :: Double - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON) - - --- ** OuterString --- | OuterString -newtype OuterString = OuterString - { unOuterString :: Text - } deriving (P.Eq, P.Show, P.Typeable, A.ToJSON, A.FromJSON) - - -- ** Pet -- | Pet data Pet = Pet diff --git a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs index c87f7d1c266..d75c5e100f7 100644 --- a/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/SwaggerPetstore/ModelLens.hs @@ -3,10 +3,10 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - OpenAPI Version: 3.0.1 + OpenAPI Version: 3.0.0 Swagger Petstore API version: 1.0.0 Contact: apiteam@swagger.io - Generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + Generated by OpenAPI Generator (https://openapi-generator.tech) -} {-| @@ -408,10 +408,10 @@ model200ResponseClassL f Model200Response{..} = (\model200ResponseClass -> Model -- * ModelList --- | 'modelList123List' Lens -modelList123ListL :: Lens_' ModelList (Maybe Text) -modelList123ListL f ModelList{..} = (\modelList123List -> ModelList { modelList123List, ..} ) <$> f modelList123List -{-# INLINE modelList123ListL #-} +-- | 'modelList123list' Lens +modelList123listL :: Lens_' ModelList (Maybe Text) +modelList123listL f ModelList{..} = (\modelList123list -> ModelList { modelList123list, ..} ) <$> f modelList123list +{-# INLINE modelList123listL #-} @@ -441,10 +441,10 @@ namePropertyL :: Lens_' Name (Maybe Text) namePropertyL f Name{..} = (\nameProperty -> Name { nameProperty, ..} ) <$> f nameProperty {-# INLINE namePropertyL #-} --- | 'name123Number' Lens -name123NumberL :: Lens_' Name (Maybe Int) -name123NumberL f Name{..} = (\name123Number -> Name { name123Number, ..} ) <$> f name123Number -{-# INLINE name123NumberL #-} +-- | 'name123number' Lens +name123numberL :: Lens_' Name (Maybe Int) +name123numberL f Name{..} = (\name123number -> Name { name123number, ..} ) <$> f name123number +{-# INLINE name123numberL #-} @@ -491,24 +491,20 @@ orderCompleteL f Order{..} = (\orderComplete -> Order { orderComplete, ..} ) <$> --- * OuterBoolean - - - -- * OuterComposite -- | 'outerCompositeMyNumber' Lens -outerCompositeMyNumberL :: Lens_' OuterComposite (Maybe OuterNumber) +outerCompositeMyNumberL :: Lens_' OuterComposite (Maybe Double) outerCompositeMyNumberL f OuterComposite{..} = (\outerCompositeMyNumber -> OuterComposite { outerCompositeMyNumber, ..} ) <$> f outerCompositeMyNumber {-# INLINE outerCompositeMyNumberL #-} -- | 'outerCompositeMyString' Lens -outerCompositeMyStringL :: Lens_' OuterComposite (Maybe OuterString) +outerCompositeMyStringL :: Lens_' OuterComposite (Maybe Text) outerCompositeMyStringL f OuterComposite{..} = (\outerCompositeMyString -> OuterComposite { outerCompositeMyString, ..} ) <$> f outerCompositeMyString {-# INLINE outerCompositeMyStringL #-} -- | 'outerCompositeMyBoolean' Lens -outerCompositeMyBooleanL :: Lens_' OuterComposite (Maybe OuterBoolean) +outerCompositeMyBooleanL :: Lens_' OuterComposite (Maybe Bool) outerCompositeMyBooleanL f OuterComposite{..} = (\outerCompositeMyBoolean -> OuterComposite { outerCompositeMyBoolean, ..} ) <$> f outerCompositeMyBoolean {-# INLINE outerCompositeMyBooleanL #-} @@ -518,14 +514,6 @@ outerCompositeMyBooleanL f OuterComposite{..} = (\outerCompositeMyBoolean -> Out --- * OuterNumber - - - --- * OuterString - - - -- * Pet -- | 'petId' Lens diff --git a/samples/client/petstore/haskell-http-client/openapi.yaml b/samples/client/petstore/haskell-http-client/openapi.yaml index 92473d3aa8b..4e56265856e 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.1 +openapi: 3.0.0 info: title: Swagger Petstore description: 'This spec is mainly for testing Petstore server and contains fake @@ -37,25 +37,14 @@ paths: summary: Update an existing pet operationId: updatePet requestBody: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true + $ref: '#/components/requestBodies/Pet' responses: 400: description: Invalid ID supplied - content: {} 404: description: Pet not found - content: {} 405: description: Validation exception - content: {} security: - petstore_auth: - write:pets @@ -66,19 +55,10 @@ paths: summary: Add a new pet to the store operationId: addPet requestBody: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true + $ref: '#/components/requestBodies/Pet' responses: 405: description: Invalid input - content: {} security: - petstore_auth: - write:pets @@ -95,16 +75,17 @@ paths: in: query description: Status values that need to be considered for filter required: true + style: form explode: false schema: type: array items: type: string + default: available enum: - available - pending - sold - default: available responses: 200: description: successful operation @@ -121,7 +102,6 @@ paths: $ref: '#/components/schemas/Pet' 400: description: Invalid status value - content: {} security: - petstore_auth: - write:pets @@ -138,6 +118,7 @@ paths: in: query description: Tags to filter by required: true + style: form explode: false schema: type: array @@ -159,7 +140,6 @@ paths: $ref: '#/components/schemas/Pet' 400: description: Invalid tag value - content: {} deprecated: true security: - petstore_auth: @@ -177,6 +157,8 @@ paths: in: path description: ID of pet to return required: true + style: simple + explode: false schema: type: integer format: int64 @@ -192,10 +174,8 @@ paths: $ref: '#/components/schemas/Pet' 400: description: Invalid ID supplied - content: {} 404: description: Pet not found - content: {} security: - api_key: [] post: @@ -208,6 +188,8 @@ paths: in: path description: ID of pet that needs to be updated required: true + style: simple + explode: false schema: type: integer format: int64 @@ -215,17 +197,10 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - name: - type: string - description: Updated name of the pet - status: - type: string - description: Updated status of the pet + $ref: '#/components/schemas/body' responses: 405: description: Invalid input - content: {} security: - petstore_auth: - write:pets @@ -238,19 +213,23 @@ paths: parameters: - name: api_key in: header + required: false + style: simple + explode: false schema: type: string - name: petId in: path description: Pet id to delete required: true + style: simple + explode: false schema: type: integer format: int64 responses: 400: description: Invalid pet value - content: {} security: - petstore_auth: - write:pets @@ -266,6 +245,8 @@ paths: in: path description: ID of pet to update required: true + style: simple + explode: false schema: type: integer format: int64 @@ -273,14 +254,7 @@ paths: content: multipart/form-data: schema: - properties: - additionalMetadata: - type: string - description: Additional data to pass to server - file: - type: string - description: file to upload - format: binary + $ref: '#/components/schemas/body_1' responses: 200: description: successful operation @@ -320,7 +294,7 @@ paths: requestBody: description: order placed for purchasing the pet content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Order' required: true @@ -336,7 +310,6 @@ paths: $ref: '#/components/schemas/Order' 400: description: Invalid Order - content: {} /store/order/{order_id}: get: tags: @@ -349,6 +322,8 @@ paths: in: path description: ID of pet that needs to be fetched required: true + style: simple + explode: false schema: maximum: 5 minimum: 1 @@ -366,10 +341,8 @@ paths: $ref: '#/components/schemas/Order' 400: description: Invalid ID supplied - content: {} 404: description: Order not found - content: {} delete: tags: - store @@ -381,15 +354,15 @@ paths: in: path description: ID of the order that needs to be deleted required: true + style: simple + explode: false schema: type: string responses: 400: description: Invalid ID supplied - content: {} 404: description: Order not found - content: {} /user: post: tags: @@ -400,14 +373,13 @@ paths: requestBody: description: Created user object content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' required: true responses: default: description: successful operation - content: {} /user/createWithArray: post: tags: @@ -415,18 +387,10 @@ paths: summary: Creates list of users with given input array operationId: createUsersWithArrayInput requestBody: - description: List of user object - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: description: successful operation - content: {} /user/createWithList: post: tags: @@ -434,18 +398,10 @@ paths: summary: Creates list of users with given input array operationId: createUsersWithListInput requestBody: - description: List of user object - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: description: successful operation - content: {} /user/login: get: tags: @@ -457,12 +413,16 @@ paths: in: query description: The user name for login required: true + style: form + explode: true schema: type: string - name: password in: query description: The password for login in clear text required: true + style: form + explode: true schema: type: string responses: @@ -471,11 +431,15 @@ paths: headers: X-Rate-Limit: description: calls per hour allowed by the user + style: simple + explode: false schema: type: integer format: int32 X-Expires-After: - description: date in UTC when token expires + description: date in UTC when toekn expires + style: simple + explode: false schema: type: string format: date-time @@ -488,7 +452,6 @@ paths: type: string 400: description: Invalid username/password supplied - content: {} /user/logout: get: tags: @@ -498,7 +461,6 @@ paths: responses: default: description: successful operation - content: {} /user/{username}: get: tags: @@ -510,6 +472,8 @@ paths: in: path description: The name that needs to be fetched. Use user1 for testing. required: true + style: simple + explode: false schema: type: string responses: @@ -524,10 +488,8 @@ paths: $ref: '#/components/schemas/User' 400: description: Invalid username supplied - content: {} 404: description: User not found - content: {} put: tags: - user @@ -539,22 +501,22 @@ paths: in: path description: name that need to be deleted required: true + style: simple + explode: false schema: type: string requestBody: description: Updated user object content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' required: true responses: 400: description: Invalid user supplied - content: {} 404: description: User not found - content: {} delete: tags: - user @@ -566,15 +528,15 @@ paths: in: path description: The name that needs to be deleted required: true + style: simple + explode: false schema: type: string responses: 400: description: Invalid username supplied - content: {} 404: description: User not found - content: {} /fake_classname_test: patch: tags: @@ -583,12 +545,7 @@ paths: description: To test class name in snake case operationId: testClassname requestBody: - description: client model - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - required: true + $ref: '#/components/requestBodies/Client' responses: 200: description: successful operation @@ -609,49 +566,63 @@ paths: - name: enum_header_string_array in: header description: Header parameter enum test (string array) + required: false + style: simple + explode: true schema: type: array items: type: string + default: $ enum: - '>' - $ - default: $ - name: enum_header_string in: header description: Header parameter enum test (string) + required: false + style: simple + explode: false schema: type: string + default: -efg enum: - _abc - -efg - (xyz) - default: -efg - name: enum_query_string_array in: query description: Query parameter enum test (string array) - explode: false + required: false + style: form + explode: true schema: type: array items: type: string + default: $ enum: - '>' - $ - default: $ - name: enum_query_string in: query description: Query parameter enum test (string) + required: false + style: form + explode: true schema: type: string + default: -efg enum: - _abc - -efg - (xyz) - default: -efg - name: enum_query_integer in: query description: Query parameter enum test (double) + required: false + style: form + explode: true schema: type: integer format: int32 @@ -661,6 +632,9 @@ paths: - name: enum_query_double in: query description: Query parameter enum test (double) + required: false + style: form + explode: true schema: type: number format: double @@ -671,31 +645,12 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - enum_form_string_array: - type: array - description: Form parameter enum test (string array) - items: - type: string - enum: - - '>' - - $ - default: $ - enum_form_string: - type: string - description: Form parameter enum test (string) - enum: - - _abc - - -efg - - (xyz) - default: -efg + $ref: '#/components/schemas/body_2' responses: 400: description: Invalid request - content: {} 404: description: Not found - content: {} post: tags: - fake @@ -714,84 +669,12 @@ paths: content: application/x-www-form-urlencoded: schema: - required: - - byte - - double - - number - - pattern_without_delimiter - properties: - integer: - maximum: 100 - minimum: 10 - type: integer - description: None - int32: - maximum: 200 - minimum: 20 - type: integer - description: None - format: int32 - int64: - type: integer - description: None - format: int64 - number: - maximum: 543.2 - minimum: 32.1 - type: number - description: None - float: - maximum: 987.6 - type: number - description: None - format: float - double: - maximum: 123.4 - minimum: 67.8 - type: number - description: None - format: double - string: - pattern: /[a-z]/i - type: string - description: None - pattern_without_delimiter: - pattern: ^[A-Z].* - type: string - description: None - byte: - type: string - description: None - format: byte - binary: - type: string - description: None - format: binary - date: - type: string - description: None - format: date - dateTime: - type: string - description: None - format: date-time - password: - maxLength: 64 - minLength: 10 - type: string - description: None - format: password - callback: - type: string - description: None - required: true + $ref: '#/components/schemas/body_3' responses: 400: description: Invalid username supplied - content: {} 404: description: User not found - content: {} security: - http_basic_test: [] patch: @@ -801,12 +684,7 @@ paths: description: To test "client" model operationId: testClientModel requestBody: - description: client model - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - required: true + $ref: '#/components/requestBodies/Client' responses: 200: description: successful operation @@ -823,10 +701,9 @@ paths: requestBody: description: Input number as post body content: - '*/*': + application/json: schema: $ref: '#/components/schemas/OuterNumber' - required: false responses: 200: description: Output number @@ -843,10 +720,9 @@ paths: requestBody: description: Input string as post body content: - '*/*': + application/json: schema: $ref: '#/components/schemas/OuterString' - required: false responses: 200: description: Output string @@ -863,10 +739,9 @@ paths: requestBody: description: Input boolean as post body content: - '*/*': + application/json: schema: $ref: '#/components/schemas/OuterBoolean' - required: false responses: 200: description: Output boolean @@ -883,10 +758,9 @@ paths: requestBody: description: Input composite as post body content: - '*/*': + application/json: schema: $ref: '#/components/schemas/OuterComposite' - required: false responses: 200: description: Output composite @@ -904,21 +778,10 @@ paths: content: application/x-www-form-urlencoded: schema: - required: - - param - - param2 - properties: - param: - type: string - description: field1 - param2: - type: string - description: field2 - required: true + $ref: '#/components/schemas/body_4' responses: 200: description: successful operation - content: {} /fake/inline-additionalProperties: post: tags: @@ -937,28 +800,6 @@ paths: responses: 200: description: successful operation - content: {} - /fake/body-with-query-params: - put: - tags: - - fake - operationId: testBodyWithQueryParams - parameters: - - name: query - in: query - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/User' - required: true - responses: - 200: - description: Success - content: {} /another-fake/dummy: patch: tags: @@ -967,12 +808,7 @@ paths: description: To test special tags operationId: test_special_tags requestBody: - description: client model - content: - application/json: - schema: - $ref: '#/components/schemas/Client' - required: true + $ref: '#/components/requestBodies/Client' responses: 200: description: successful operation @@ -982,6 +818,40 @@ paths: $ref: '#/components/schemas/Client' components: schemas: + Order: + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed + xml: + name: Order Category: type: object properties: @@ -1029,388 +899,6 @@ components: username: username xml: name: User - OuterNumber: - type: number - ArrayOfNumberOnly: - type: object - properties: - ArrayNumber: - type: array - items: - type: number - Capitalization: - type: object - properties: - smallCamel: - type: string - CapitalCamel: - type: string - small_Snake: - type: string - Capital_Snake: - type: string - SCA_ETH_Flow_Points: - type: string - ATT_NAME: - type: string - description: | - Name of the pet - MixedPropertiesAndAdditionalPropertiesClass: - type: object - properties: - uuid: - type: string - format: uuid - dateTime: - type: string - format: date-time - map: - type: object - additionalProperties: - $ref: '#/components/schemas/Animal' - ApiResponse: - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string - example: - code: 0 - type: type - message: message - Name: - required: - - name - type: object - properties: - name: - type: integer - format: int32 - snake_case: - type: integer - format: int32 - readOnly: true - property: - type: string - 123Number: - type: integer - readOnly: true - description: Model for testing model name same as property name - xml: - name: Name - EnumClass: - type: string - enum: - - _abc - - -efg - - (xyz) - default: -efg - List: - type: object - properties: - 123-list: - type: string - NumberOnly: - type: object - properties: - JustNumber: - type: number - 200_response: - type: object - properties: - name: - type: integer - format: int32 - class: - type: string - description: Model for testing model name starting with number - xml: - name: Name - Client: - type: object - properties: - client: - type: string - example: - client: client - Dog: - allOf: - - $ref: '#/components/schemas/Animal' - - type: object - properties: - breed: - type: string - Enum_Test: - required: - - enum_string_required - type: object - properties: - enum_string: - type: string - enum: - - UPPER - - lower - - "" - enum_string_required: - type: string - enum: - - UPPER - - lower - - "" - enum_integer: - type: integer - format: int32 - enum: - - 1 - - -1 - enum_number: - type: number - format: double - enum: - - 1.1 - - -1.2 - outerEnum: - $ref: '#/components/schemas/OuterEnum' - Order: - type: object - properties: - id: - type: integer - format: int64 - petId: - type: integer - format: int64 - quantity: - type: integer - format: int32 - shipDate: - type: string - format: date-time - status: - type: string - description: Order Status - enum: - - placed - - approved - - delivered - complete: - type: boolean - default: false - example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed - xml: - name: Order - AdditionalPropertiesClass: - type: object - properties: - map_property: - type: object - additionalProperties: - type: string - map_of_map_property: - type: object - additionalProperties: - type: object - additionalProperties: - type: string - $special[model.name]: - type: object - properties: - $special[property.name]: - type: integer - format: int64 - xml: - name: $special[model.name] - Return: - type: object - properties: - return: - type: integer - format: int32 - description: Model for testing reserved words - xml: - name: Return - ReadOnlyFirst: - type: object - properties: - bar: - type: string - readOnly: true - baz: - type: string - ArrayOfArrayOfNumberOnly: - type: object - properties: - ArrayArrayNumber: - type: array - items: - type: array - items: - type: number - OuterEnum: - type: string - enum: - - placed - - approved - - delivered - ArrayTest: - type: object - properties: - array_of_string: - type: array - items: - type: string - array_array_of_integer: - type: array - items: - type: array - items: - type: integer - format: int64 - array_array_of_model: - type: array - items: - type: array - items: - $ref: '#/components/schemas/ReadOnlyFirst' - OuterComposite: - type: object - properties: - my_number: - $ref: '#/components/schemas/OuterNumber' - my_string: - $ref: '#/components/schemas/OuterString' - my_boolean: - $ref: '#/components/schemas/OuterBoolean' - example: {} - format_test: - required: - - byte - - date - - number - - password - type: object - properties: - integer: - maximum: 1E+2 - minimum: 1E+1 - type: integer - int32: - maximum: 2E+2 - minimum: 2E+1 - type: integer - format: int32 - int64: - type: integer - format: int64 - number: - maximum: 543.2 - minimum: 32.1 - type: number - float: - maximum: 987.6 - minimum: 54.3 - type: number - format: float - double: - maximum: 123.4 - minimum: 67.8 - type: number - format: double - string: - pattern: /[a-z]/i - type: string - byte: - pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ - type: string - format: byte - binary: - type: string - format: binary - date: - type: string - format: date - dateTime: - type: string - format: date-time - uuid: - type: string - format: uuid - password: - maxLength: 64 - minLength: 10 - type: string - format: password - EnumArrays: - type: object - properties: - just_symbol: - type: string - enum: - - '>=' - - $ - array_enum: - type: array - items: - type: string - enum: - - fish - - crab - OuterString: - type: string - ClassModel: - type: object - properties: - _class: - type: string - description: Model for testing model with "_class" property - OuterBoolean: - type: boolean - x-codegen-body-parameter-name: boolean_post_body - Animal: - required: - - className - type: object - properties: - className: - type: string - color: - type: string - default: red - discriminator: - propertyName: className - Cat: - allOf: - - $ref: '#/components/schemas/Animal' - - type: object - properties: - declawed: - type: boolean - MapTest: - type: object - properties: - map_map_of_string: - type: object - additionalProperties: - type: object - additionalProperties: - type: string - map_of_enum_string: - type: object - additionalProperties: - type: string - enum: - - UPPER - - lower Tag: type: object properties: @@ -1424,10 +912,6 @@ components: id: 1 xml: name: Tag - AnimalFarm: - type: array - items: - $ref: '#/components/schemas/Animal' Pet: required: - name @@ -1481,6 +965,234 @@ components: status: available xml: name: Pet + ApiResponse: + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + example: + code: 0 + type: type + message: message + Return: + properties: + return: + type: integer + format: int32 + description: Model for testing reserved words + xml: + name: Return + Name: + required: + - name + properties: + name: + type: integer + format: int32 + snake_case: + type: integer + format: int32 + readOnly: true + property: + type: string + 123Number: + type: integer + format: int32 + readOnly: true + description: Model for testing model name same as property name + xml: + name: Name + 200_response: + properties: + name: + type: integer + format: int32 + class: + type: string + description: Model for testing model name starting with number + xml: + name: Name + ClassModel: + properties: + _class: + type: string + description: Model for testing model with "_class" property + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + breed: + type: string + Cat: + allOf: + - $ref: '#/components/schemas/Animal' + - type: object + properties: + declawed: + type: boolean + Animal: + required: + - className + type: object + properties: + className: + type: string + color: + type: string + default: red + discriminator: + propertyName: className + AnimalFarm: + type: array + items: + $ref: '#/components/schemas/Animal' + format_test: + required: + - byte + - date + - number + - password + type: object + properties: + integer: + maximum: 100 + minimum: 10 + type: integer + format: int32 + int32: + maximum: 200 + minimum: 20 + type: integer + format: int32 + int64: + type: integer + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + float: + maximum: 987.6 + minimum: 54.3 + type: number + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + format: double + string: + type: string + byte: + type: string + format: byte + binary: + type: string + format: binary + date: + type: string + format: date + dateTime: + type: string + format: date-time + uuid: + type: string + format: uuid + password: + maxLength: 64 + minLength: 10 + type: string + format: password + EnumClass: + type: string + default: -efg + enum: + - _abc + - -efg + - (xyz) + Enum_Test: + required: + - enum_string_required + type: object + properties: + enum_string: + type: string + enum: + - UPPER + - lower + - "" + enum_string_required: + type: string + enum: + - UPPER + - lower + - "" + enum_integer: + type: integer + format: int32 + enum: + - 1 + - -1 + enum_number: + type: number + format: double + enum: + - 1.1 + - -1.2 + outerEnum: + $ref: '#/components/schemas/OuterEnum' + AdditionalPropertiesClass: + type: object + properties: + map_property: + type: object + additionalProperties: + type: string + map_of_map_property: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + MixedPropertiesAndAdditionalPropertiesClass: + type: object + properties: + uuid: + type: string + format: uuid + dateTime: + type: string + format: date-time + map: + type: object + additionalProperties: + $ref: '#/components/schemas/Animal' + List: + type: object + properties: + 123-list: + type: string + Client: + type: object + properties: + client: + type: string + example: + client: client + ReadOnlyFirst: + type: object + properties: + bar: + type: string + readOnly: true + baz: + type: string hasOnlyReadOnly: type: object properties: @@ -1490,6 +1202,273 @@ components: foo: type: string readOnly: true + Capitalization: + type: object + properties: + smallCamel: + type: string + CapitalCamel: + type: string + small_Snake: + type: string + Capital_Snake: + type: string + SCA_ETH_Flow_Points: + type: string + ATT_NAME: + type: string + description: | + Name of the pet + MapTest: + type: object + properties: + map_map_of_string: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + map_of_enum_string: + type: object + additionalProperties: + type: string + enum: + - UPPER + - lower + ArrayTest: + type: object + properties: + array_of_string: + type: array + items: + type: string + array_array_of_integer: + type: array + items: + type: array + items: + type: integer + format: int64 + array_array_of_model: + type: array + items: + type: array + items: + $ref: '#/components/schemas/ReadOnlyFirst' + NumberOnly: + type: object + properties: + JustNumber: + type: number + ArrayOfNumberOnly: + type: object + properties: + ArrayNumber: + type: array + items: + type: number + ArrayOfArrayOfNumberOnly: + type: object + properties: + ArrayArrayNumber: + type: array + items: + type: array + items: + type: number + EnumArrays: + type: object + properties: + just_symbol: + type: string + enum: + - '>=' + - $ + array_enum: + type: array + items: + type: string + enum: + - fish + - crab + OuterEnum: + type: string + enum: + - placed + - approved + - delivered + OuterComposite: + type: object + properties: + my_number: + $ref: '#/components/schemas/OuterNumber' + my_string: + $ref: '#/components/schemas/OuterString' + my_boolean: + $ref: '#/components/schemas/OuterBoolean' + example: {} + OuterNumber: + type: number + OuterString: + type: string + OuterBoolean: + type: boolean + _special_model.name_: + properties: + $special[property.name]: + type: integer + format: int64 + xml: + name: $special[model.name] + body: + type: object + properties: + name: + type: string + description: Updated name of the pet + status: + type: string + description: Updated status of the pet + body_1: + type: object + properties: + additionalMetadata: + type: string + description: Additional data to pass to server + file: + type: string + description: file to upload + format: binary + body_2: + type: object + properties: + enum_form_string_array: + type: array + description: Form parameter enum test (string array) + items: + type: string + default: $ + enum: + - '>' + - $ + enum_form_string: + type: string + description: Form parameter enum test (string) + default: -efg + enum: + - _abc + - -efg + - (xyz) + body_3: + required: + - byte + - double + - number + - pattern_without_delimiter + type: object + properties: + integer: + maximum: 100 + minimum: 10 + type: integer + description: None + format: int32 + int32: + maximum: 200 + minimum: 20 + type: integer + description: None + format: int32 + int64: + type: integer + description: None + format: int64 + number: + maximum: 543.2 + minimum: 32.1 + type: number + description: None + float: + maximum: 987.6 + type: number + description: None + format: float + double: + maximum: 123.4 + minimum: 67.8 + type: number + description: None + format: double + string: + type: string + description: None + pattern_without_delimiter: + type: string + description: None + byte: + type: string + description: None + format: byte + binary: + type: string + description: None + format: binary + date: + type: string + description: None + format: date + dateTime: + type: string + description: None + format: date-time + password: + maxLength: 64 + minLength: 10 + type: string + description: None + format: password + callback: + type: string + description: None + body_4: + required: + - param + - param2 + type: object + properties: + param: + type: string + description: field1 + param2: + type: string + description: field2 + requestBodies: + UserArray: + description: List of user object + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + required: true + Client: + description: client model + content: + application/json: + schema: + $ref: '#/components/schemas/Client' + required: true + Pet: + description: Pet object that needs to be added to the store + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + required: true securitySchemes: petstore_auth: type: oauth2 @@ -1499,9 +1478,6 @@ components: scopes: write:pets: modify pets in your account read:pets: read your pets - http_basic_test: - type: http - scheme: basic api_key: type: apiKey name: api_key @@ -1510,3 +1486,6 @@ components: type: apiKey name: api_key_query in: query + http_basic_test: + type: http + scheme: basic diff --git a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal index cabd62ab5cc..a7c5d44bd26 100644 --- a/samples/client/petstore/haskell-http-client/swagger-petstore.cabal +++ b/samples/client/petstore/haskell-http-client/swagger-petstore.cabal @@ -10,10 +10,10 @@ description: . . Swagger Petstore API version: 1.0.0 . - OpenAPI version: 3.0.1 + OpenAPI version: 3.0.0 . category: Web -homepage: https://github.com/swagger-api/swagger-codegen#readme +homepage: https://openapi-generator.tech author: Author Name Here maintainer: author.name@email.com copyright: YEAR - AUTHOR diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 89b1705fe5c..8ddd6dbbd24 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -103,7 +103,9 @@ instance Arbitrary Animal where instance Arbitrary AnimalFarm where arbitrary = - AnimalFarm <$> arbitrary + + pure AnimalFarm + instance Arbitrary ApiResponse where arbitrary = ApiResponse @@ -228,7 +230,7 @@ instance Arbitrary Model200Response where instance Arbitrary ModelList where arbitrary = ModelList - <$> arbitrary -- modelList123List :: Maybe Text + <$> arbitrary -- modelList123list :: Maybe Text instance Arbitrary ModelReturn where arbitrary = @@ -241,7 +243,7 @@ instance Arbitrary Name where <$> arbitrary -- nameName :: Int <*> arbitrary -- nameSnakeCase :: Maybe Int <*> arbitrary -- nameProperty :: Maybe Text - <*> arbitrary -- name123Number :: Maybe Int + <*> arbitrary -- name123number :: Maybe Int instance Arbitrary NumberOnly where arbitrary = @@ -258,22 +260,13 @@ instance Arbitrary Order where <*> arbitrary -- orderStatus :: Maybe Text <*> arbitrary -- orderComplete :: Maybe Bool -instance Arbitrary OuterBoolean where - arbitrary = - OuterBoolean <$> arbitrary instance Arbitrary OuterComposite where arbitrary = OuterComposite - <$> arbitrary -- outerCompositeMyNumber :: Maybe OuterNumber - <*> arbitrary -- outerCompositeMyString :: Maybe OuterString - <*> arbitrary -- outerCompositeMyBoolean :: Maybe OuterBoolean + <$> arbitrary -- outerCompositeMyNumber :: Maybe Double + <*> arbitrary -- outerCompositeMyString :: Maybe Text + <*> arbitrary -- outerCompositeMyBoolean :: Maybe Bool -instance Arbitrary OuterNumber where - arbitrary = - OuterNumber <$> arbitrary -instance Arbitrary OuterString where - arbitrary = - OuterString <$> arbitrary instance Arbitrary Pet where arbitrary = Pet diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index 88be73d0de1..bf1924b96c6 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -46,11 +46,8 @@ main = propMimeEq MimeJSON (Proxy :: Proxy Name) propMimeEq MimeJSON (Proxy :: Proxy NumberOnly) propMimeEq MimeJSON (Proxy :: Proxy Order) - propMimeEq MimeJSON (Proxy :: Proxy OuterBoolean) propMimeEq MimeJSON (Proxy :: Proxy OuterComposite) propMimeEq MimeJSON (Proxy :: Proxy OuterEnum) - propMimeEq MimeJSON (Proxy :: Proxy OuterNumber) - propMimeEq MimeJSON (Proxy :: Proxy OuterString) propMimeEq MimeJSON (Proxy :: Proxy Pet) propMimeEq MimeJSON (Proxy :: Proxy ReadOnlyFirst) propMimeEq MimeJSON (Proxy :: Proxy SpecialModelName)