diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 84f68f7ad5c..1580f694274 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/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..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 @@ -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; @@ -361,6 +362,10 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC public void processOpts() { super.processOpts(); + 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)) { setAllowFromJsonNulls(convertPropertyToBoolean(PROP_ALLOW_FROMJSON_NULLS)); } else { @@ -1345,4 +1350,31 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC .replace("\\", "\\\\") .replace("\"", "\\\"")); } + + @Override + public void postProcessFile(File file, String fileType) { + if (file == null) { + return; + } + 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 = haskellPostProcessFile + " " + file.toString(); + try { + Process p = Runtime.getRuntime().exec(command); + int exitValue = p.waitFor(); + if (exitValue != 0) { + LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue); + } else { + 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 62029b6065a..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 @@ -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( 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("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)"); + } + } + /** * 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> 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 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,30 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf return input.replace("{-", "{_-").replace("-}", "-_}"); } + @Override + public void postProcessFile(File file, String fileType) { + if (file == null) { + return; + } + 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 = haskellPostProcessFile + " " + file.toString(); + try { + Process p = Runtime.getRuntime().exec(command); + int exitValue = p.waitFor(); + if (exitValue != 0) { + LOGGER.error("Error running the command ({}). Exit value: {}", command, exitValue); + } else { + 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/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/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/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 58bdea3d9db..dcbcef0b83f 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 b6b3e77ec30..a093ca73ca0 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 a6081e59262..4009731809f 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,6 +1078,419 @@ components: type: object xml: name: User + OuterNumber: + type: number + ArrayOfNumberOnly: + properties: + 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 + MixedPropertiesAndAdditionalPropertiesClass: + properties: + uuid: + format: uuid + type: string + dateTime: + format: date-time + type: string + map: + additionalProperties: + $ref: '#/components/schemas/Animal' + type: object + type: object + ApiResponse: + example: + code: 0 + type: type + message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + type: string + type: object + Name: + description: Model for testing model name same as property name + properties: + name: + format: int32 + type: integer + snake_case: + format: int32 + readOnly: true + type: integer + property: + type: string + 123Number: + 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: + name: + format: int32 + type: integer + class: + type: string + type: object + xml: + name: Name + Client: + example: + client: client + properties: + client: + type: string + type: object + Dog: + allOf: + - $ref: '#/components/schemas/Animal' + - properties: + breed: + type: string + type: object + Enum_Test: + properties: + enum_string: + enum: + - UPPER + - lower + - "" + type: string + enum_string_required: + enum: + - UPPER + - lower + - "" + type: string + enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + enum_number: + enum: + - 1.1 + - -1.2 + format: double + type: number + outerEnum: + $ref: '#/components/schemas/OuterEnum' + 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: + additionalProperties: + type: string + type: object + map_of_map_property: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + type: object + $special[model.name]: + properties: + $special[property.name]: + format: int64 + type: integer + type: object + xml: + name: $special[model.name] + Return: + description: Model for testing reserved words + properties: + return: + format: int32 + type: integer + type: object + xml: + name: Return + ReadOnlyFirst: + properties: + bar: + readOnly: true + type: string + baz: + type: string + type: object + ArrayOfArrayOfNumberOnly: + properties: + ArrayArrayNumber: + items: + items: + type: number + type: array + type: array + type: object + OuterEnum: + enum: + - placed + - approved + - delivered + type: string + ArrayTest: + properties: + array_of_string: + items: + type: string + type: array + array_array_of_integer: + items: + items: + format: int64 + type: integer + type: array + type: array + array_array_of_model: + items: + items: + $ref: '#/components/schemas/ReadOnlyFirst' + type: array + type: array + type: object + OuterComposite: + example: + my_string: my_string + my_number: 0.80082819046101150206595775671303272247314453125 + my_boolean: true + properties: + my_number: + type: number + my_string: + type: string + my_boolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + type: object + format_test: + properties: + integer: + maximum: 1E+2 + minimum: 1E+1 + type: integer + int32: + format: int32 + maximum: 2E+2 + minimum: 2E+1 + 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 + pattern: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$ + 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 + 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 + OuterBoolean: + type: boolean + x-codegen-body-parameter-name: boolean_post_body + 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 + Animal: + discriminator: + propertyName: className + properties: + className: + type: string + color: + default: red + type: string + required: + - 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: + additionalProperties: + type: boolean + type: object + type: object Tag: example: name: name @@ -996,6 +1504,19 @@ components: 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: @@ -1049,235 +1570,6 @@ components: type: object xml: name: Pet - ApiResponse: - example: - code: 0 - type: type - message: message - properties: - code: - format: int32 - type: integer - type: - type: string - 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: - name: - format: int32 - type: integer - snake_case: - format: int32 - readOnly: true - type: integer - property: - type: string - 123Number: - format: int32 - readOnly: true - type: integer - required: - - name - xml: - name: Name - 200_response: - description: Model for testing model name starting with number - properties: - name: - format: int32 - type: integer - class: - type: string - xml: - name: Name - ClassModel: - description: Model for testing model with "_class" property - properties: - _class: - type: string - Dog: - allOf: - - $ref: '#/components/schemas/Animal' - - properties: - 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: - enum: - - UPPER - - lower - - "" - type: string - enum_string_required: - enum: - - UPPER - - lower - - "" - type: string - enum_integer: - enum: - - 1 - - -1 - format: int32 - type: integer - enum_number: - enum: - - 1.1 - - -1.2 - format: double - type: number - outerEnum: - $ref: '#/components/schemas/OuterEnum' - required: - - enum_string_required - type: object - AdditionalPropertiesClass: - properties: - map_property: - additionalProperties: - type: string - type: object - map_of_map_property: - additionalProperties: - additionalProperties: - type: string - type: object - type: object - type: object - MixedPropertiesAndAdditionalPropertiesClass: - 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 - type: object - Client: - example: - client: client - properties: - client: - type: string - type: object - ReadOnlyFirst: - properties: - bar: - readOnly: true - type: string - baz: - type: string - type: object hasOnlyReadOnly: properties: bar: @@ -1287,299 +1579,6 @@ components: 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: - 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: - additionalProperties: - type: boolean - type: object - ArrayTest: - properties: - array_of_string: - items: - type: string - type: array - array_array_of_integer: - items: - items: - format: int64 - type: integer - type: array - type: array - array_array_of_model: - items: - items: - $ref: '#/components/schemas/ReadOnlyFirst' - 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 - my_number: 0.80082819046101150206595775671303272247314453125 - my_boolean: true - properties: - my_number: - type: number - my_string: - type: string - my_boolean: - 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: - properties: - integer: - description: None - format: int32 - 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 - type: object - body_4: - properties: - param: - description: field1 - type: string - param2: - description: field2 - type: string - required: - - param - - param2 - type: object - body_5: - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - requiredFile: - description: file to upload - format: binary - type: string - required: - - requiredFile - type: object securitySchemes: petstore_auth: flows: @@ -1589,6 +1588,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 @@ -1597,6 +1599,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-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 diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index d9ea47570d2..dc1a79b93dd 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) 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