From 8582bc07cbcb1210beeefafb3990dcb4c403a123 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Wed, 14 Nov 2018 15:40:07 +0800 Subject: [PATCH 1/3] add file post processing to cpp generators --- .../languages/AbstractCSharpCodegen.java | 1 + .../codegen/languages/AbstractCppCodegen.java | 40 ++++++++++++++++++- .../codegen/languages/AbstractGoCodegen.java | 1 + .../languages/AbstractJavaCodegen.java | 1 + .../languages/AbstractScalaCodegen.java | 1 + .../codegen/languages/DartClientCodegen.java | 1 + .../codegen/languages/ElmClientCodegen.java | 1 + .../languages/JavascriptClientCodegen.java | 1 + .../codegen/languages/PerlClientCodegen.java | 1 + .../languages/PythonClientCodegen.java | 1 + .../PythonFlaskConnexionServerCodegen.java | 1 + .../codegen/languages/Swift3Codegen.java | 1 + .../codegen/languages/Swift4Codegen.java | 1 + .../cpp-restsdk/.openapi-generator/VERSION | 2 +- .../client/petstore/cpp-restsdk/ApiClient.cpp | 2 +- .../client/petstore/cpp-restsdk/ApiClient.h | 2 +- .../petstore/cpp-restsdk/ApiConfiguration.cpp | 2 +- .../petstore/cpp-restsdk/ApiConfiguration.h | 2 +- .../petstore/cpp-restsdk/ApiException.cpp | 2 +- .../petstore/cpp-restsdk/ApiException.h | 2 +- .../petstore/cpp-restsdk/HttpContent.cpp | 2 +- .../client/petstore/cpp-restsdk/HttpContent.h | 2 +- .../client/petstore/cpp-restsdk/IHttpBody.h | 2 +- .../client/petstore/cpp-restsdk/JsonBody.cpp | 2 +- .../client/petstore/cpp-restsdk/JsonBody.h | 2 +- .../client/petstore/cpp-restsdk/ModelBase.cpp | 2 +- .../client/petstore/cpp-restsdk/ModelBase.h | 2 +- .../cpp-restsdk/MultipartFormData.cpp | 2 +- .../petstore/cpp-restsdk/MultipartFormData.h | 2 +- .../client/petstore/cpp-restsdk/Object.cpp | 2 +- samples/client/petstore/cpp-restsdk/Object.h | 2 +- .../petstore/cpp-restsdk/api/PetApi.cpp | 2 +- .../client/petstore/cpp-restsdk/api/PetApi.h | 6 +-- .../petstore/cpp-restsdk/api/StoreApi.cpp | 2 +- .../petstore/cpp-restsdk/api/StoreApi.h | 4 +- .../petstore/cpp-restsdk/api/UserApi.cpp | 2 +- .../client/petstore/cpp-restsdk/api/UserApi.h | 4 +- .../cpp-restsdk/model/ApiResponse.cpp | 2 +- .../petstore/cpp-restsdk/model/ApiResponse.h | 2 +- .../petstore/cpp-restsdk/model/Category.cpp | 2 +- .../petstore/cpp-restsdk/model/Category.h | 2 +- .../petstore/cpp-restsdk/model/Order.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Order.h | 2 +- .../client/petstore/cpp-restsdk/model/Pet.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Pet.h | 2 +- .../client/petstore/cpp-restsdk/model/Tag.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Tag.h | 2 +- .../petstore/cpp-restsdk/model/User.cpp | 2 +- .../client/petstore/cpp-restsdk/model/User.h | 2 +- 49 files changed, 90 insertions(+), 42 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index bf9ef8322eb..85cc92c65e1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -216,6 +216,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co if (StringUtils.isEmpty(System.getenv("CSHARP_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable CSHARP_POST_PROCESS_FILE not defined so the C# code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export CSHARP_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } // {{packageVersion}} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java index 22f49a37e14..230453547f2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java @@ -19,6 +19,8 @@ package org.openapitools.codegen.languages; import io.swagger.v3.oas.models.media.Schema; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; import com.google.common.collect.ImmutableMap; import com.samskivert.mustache.Mustache; import org.openapitools.codegen.CodegenConfig; @@ -28,6 +30,7 @@ import org.openapitools.codegen.mustache.IndentedLambda; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.util.Arrays; import java.util.Map; @@ -226,8 +229,8 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg nameInCamelCase = sanitizeName(nameInCamelCase); } if (isReservedWord(nameInCamelCase) || nameInCamelCase.matches("^\\d.*")) { - nameInCamelCase = escapeReservedWord(nameInCamelCase); - } + nameInCamelCase = escapeReservedWord(nameInCamelCase); + } property.nameInCamelCase = nameInCamelCase; return property; } @@ -249,6 +252,12 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg public void processOpts() { super.processOpts(); + + if (StringUtils.isEmpty(System.getenv("CPP_POST_PROCESS_FILE"))) { + LOGGER.info("Environment variable CPP_POST_PROCESS_FILE not defined so the C++ code may not be properly formatted. To define it, try 'export CPP_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); + } + addMustacheLambdas(additionalProperties); } @@ -265,4 +274,31 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg objs.put("lambda", lambdas); } } + + @Override + public void postProcessFile(File file, String fileType) { + if (file == null) { + return; + } + String cppPostProcessFile = System.getenv("CPP_POST_PROCESS_FILE"); + if (StringUtils.isEmpty(cppPostProcessFile)) { + return; // skip if CPP_POST_PROCESS_FILE env variable is not defined + } + // only process files with cpp extension + if ("cpp".equals(FilenameUtils.getExtension(file.toString())) || "h".equals(FilenameUtils.getExtension(file.toString()))) { + String command = cppPostProcessFile + " " + file.toString(); + try { + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + int exitValue = p.exitValue(); + 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/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index 45779ac0af9..49aa9fe342d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -121,6 +121,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege if (StringUtils.isEmpty(System.getenv("GO_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try `export GO_POST_PROCESS_FILE=\"/usr/local/bin/gofmt -w\"` (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 03e31cc18cf..b400d31c6b6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -215,6 +215,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code if (StringUtils.isEmpty(System.getenv("JAVA_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable JAVA_POST_PROCESS_FILE not defined so the Java code may not be properly formatted. To define it, try 'export JAVA_POST_PROCESS_FILE=\"/usr/local/bin/clang-format -i\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } if (additionalProperties.containsKey(SUPPORT_JAVA6)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java index 0a4bc642e29..ebfd0330ff1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java @@ -116,6 +116,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen { if (StringUtils.isEmpty(System.getenv("SCALA_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable SCALA_POST_PROCESS_FILE not defined so the Scala code may not be properly formatted. To define it, try 'export SCALA_POST_PROCESS_FILE=/usr/local/bin/scalafmt' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java index cb6e20705cb..2c09ce148ef 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java @@ -152,6 +152,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { if (StringUtils.isEmpty(System.getenv("DART_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE=\"/usr/local/bin/dartfmt -w\"` (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } if (additionalProperties.containsKey(BROWSER_CLIENT)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java index 07d06a03b04..5050a10fb7f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java @@ -191,6 +191,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { } else { // 0.19 LOGGER.info("Environment variable ELM_POST_PROCESS_FILE not defined so the Elm code may not be properly formatted. To define it, try `export ELM_POST_PROCESS_FILE=\"/usr/local/bin/elm-format --elm-version={} --yes\"` (Linux/Mac)", "0.19"); } + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } switch (elmVersion) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java index ab94690dd86..4f85b35eeaa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java @@ -234,6 +234,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo if (StringUtils.isEmpty(System.getenv("JS_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable JS_POST_PROCESS_FILE not defined so the JS code may not be properly formatted. To define it, try 'export JS_POST_PROCESS_FILE=\"/usr/local/bin/js-beautify -r -f\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } if (additionalProperties.containsKey(PROJECT_NAME)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java index f2c52611a26..60e52c4e7fd 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PerlClientCodegen.java @@ -135,6 +135,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { if (StringUtils.isEmpty(System.getenv("PERL_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable PERL_POST_PROCESS_FILE not defined so the Perl code may not be properly formatted. To define it, try 'export PERL_POST_PROCESS_FILE=/usr/local/bin/perltidy -b -bext=\"/\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } if (additionalProperties.containsKey(MODULE_VERSION)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index f5aac3520d6..3bc13a1083c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -174,6 +174,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE=\"/usr/local/bin/yapf -i\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } Boolean excludeTests = false; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java index f29b757f0c9..9a2a92aa080 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonFlaskConnexionServerCodegen.java @@ -157,6 +157,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements if (StringUtils.isEmpty(System.getenv("PYTHON_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable PYTHON_POST_PROCESS_FILE not defined so the Python code may not be properly formatted. To define it, try 'export PYTHON_POST_PROCESS_FILE=\"/usr/local/bin/yapf -i\"' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } //apiTemplateFiles.clear(); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift3Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift3Codegen.java index 745c57ee42e..e4a90d91ae8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift3Codegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift3Codegen.java @@ -245,6 +245,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig { if (StringUtils.isEmpty(System.getenv("SWIFT_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable SWIFT_POST_PROCESS_FILE not defined so the Swift code may not be properly formatted. To define it, try 'export SWIFT_POST_PROCESS_FILE=/usr/local/bin/swiftformat' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } // Setup project name diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java index 561c9a815e8..ff69058cc95 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift4Codegen.java @@ -300,6 +300,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig { if (StringUtils.isEmpty(System.getenv("SWIFT_POST_PROCESS_FILE"))) { LOGGER.info("Environment variable SWIFT_POST_PROCESS_FILE not defined so the Swift code may not be properly formatted. To define it, try 'export SWIFT_POST_PROCESS_FILE=/usr/local/bin/swiftformat' (Linux/Mac)"); + LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI)."); } // Setup project name diff --git a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION index 6d94c9c2e12..e24c1f857e0 100644 --- a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION +++ b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.0-SNAPSHOT \ No newline at end of file +3.3.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/ApiClient.cpp index 1a9ac7df1f1..5df6b675e36 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiClient.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.h b/samples/client/petstore/cpp-restsdk/ApiClient.h index 0ce3eeb4916..8aea53688c5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.h +++ b/samples/client/petstore/cpp-restsdk/ApiClient.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp index 95a6c5fc1b9..abc0510b192 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h index 218c92b403f..35b7892cbf5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.cpp b/samples/client/petstore/cpp-restsdk/ApiException.cpp index f1eb81c2144..f8206bc56c9 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiException.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.h b/samples/client/petstore/cpp-restsdk/ApiException.h index 4958f09ad74..7de8a64e96d 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.h +++ b/samples/client/petstore/cpp-restsdk/ApiException.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/HttpContent.cpp index 3f94dd84a97..c64fc2e26ee 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.cpp +++ b/samples/client/petstore/cpp-restsdk/HttpContent.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.h b/samples/client/petstore/cpp-restsdk/HttpContent.h index 9cc76d8d114..a5edc34dd2a 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.h +++ b/samples/client/petstore/cpp-restsdk/HttpContent.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/IHttpBody.h b/samples/client/petstore/cpp-restsdk/IHttpBody.h index c5e173490f7..592a3e3bcf7 100644 --- a/samples/client/petstore/cpp-restsdk/IHttpBody.h +++ b/samples/client/petstore/cpp-restsdk/IHttpBody.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/JsonBody.cpp index 276f83abbb2..f058afe6e08 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.cpp +++ b/samples/client/petstore/cpp-restsdk/JsonBody.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.h b/samples/client/petstore/cpp-restsdk/JsonBody.h index ada2e9eb11b..028dd07bfcc 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.h +++ b/samples/client/petstore/cpp-restsdk/JsonBody.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/ModelBase.cpp index 8027f547dea..4abda808cb0 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.cpp +++ b/samples/client/petstore/cpp-restsdk/ModelBase.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.h b/samples/client/petstore/cpp-restsdk/ModelBase.h index 430b2f73621..e35de11673e 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/ModelBase.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp index af977862526..009c333ff06 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/MultipartFormData.h index 3cc52c4990c..50e8216f67a 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.h +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.cpp b/samples/client/petstore/cpp-restsdk/Object.cpp index ad213d11ad4..4edce53d791 100644 --- a/samples/client/petstore/cpp-restsdk/Object.cpp +++ b/samples/client/petstore/cpp-restsdk/Object.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.h b/samples/client/petstore/cpp-restsdk/Object.h index fe7c8669d50..1944f397bda 100644 --- a/samples/client/petstore/cpp-restsdk/Object.h +++ b/samples/client/petstore/cpp-restsdk/Object.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index eb912354ea0..63c11ca9b44 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h index b6c684e162a..81662ef543a 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.h +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -25,7 +25,7 @@ #include "HttpContent.h" #include "Pet.h" #include <cpprest/details/basic_types.h> -#include "../ModelBase.h" + #include <boost/optional.hpp> @@ -63,7 +63,7 @@ public: /// /// </remarks> /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional)</param> + /// <param name="apiKey"> (optional, default to utility::conversions::to_string_t(""))</param> pplx::task<void> deletePet( int64_t petId, boost::optional<utility::string_t> apiKey diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index 55cfb7850e9..36f501f54b6 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h index 3fded80876d..1c609872c38 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -24,7 +24,7 @@ #include "Order.h" #include <map> #include <cpprest/details/basic_types.h> -#include "../ModelBase.h" + #include <boost/optional.hpp> diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index 24376a87477..d62ba153544 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.h b/samples/client/petstore/cpp-restsdk/api/UserApi.h index de94d75ff56..3f5ef26bd18 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.h +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -24,7 +24,7 @@ #include "User.h" #include <vector> #include <cpprest/details/basic_types.h> -#include "../ModelBase.h" + #include <boost/optional.hpp> diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp index 8160c7dcdc3..2ed8acfaced 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h index 26aa0ae30b6..a65b2e83fc5 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.cpp b/samples/client/petstore/cpp-restsdk/model/Category.cpp index 8b74c5bb591..68baf3c6bb9 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Category.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.h b/samples/client/petstore/cpp-restsdk/model/Category.h index a6fc63beaec..0f3f9d55a32 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/model/Category.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.cpp b/samples/client/petstore/cpp-restsdk/model/Order.cpp index 60952756058..9e438173135 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Order.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.h b/samples/client/petstore/cpp-restsdk/model/Order.h index b679d1eb127..b7ea4c528c1 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/model/Order.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/model/Pet.cpp index 47e262d79df..8b6e77835f7 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Pet.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.h b/samples/client/petstore/cpp-restsdk/model/Pet.h index 7a932c2ad91..55a1b86af41 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/model/Pet.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/model/Tag.cpp index 3e19f14a9e6..d60ec0ecc42 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Tag.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.h b/samples/client/petstore/cpp-restsdk/model/Tag.h index e290b90b94b..6ac7947b63c 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/model/Tag.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.cpp b/samples/client/petstore/cpp-restsdk/model/User.cpp index 72e65d89fe3..ced6a96347d 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.cpp +++ b/samples/client/petstore/cpp-restsdk/model/User.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.h b/samples/client/petstore/cpp-restsdk/model/User.h index 30f78e134a4..1a177f06832 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.h +++ b/samples/client/petstore/cpp-restsdk/model/User.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ -- GitLab From 4399b1f7e59c2a6ba3f56bd1c5bd88ace3220c67 Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Wed, 14 Nov 2018 15:45:20 +0800 Subject: [PATCH 2/3] use clang to auto format cpp-restsdk code --- .../client/petstore/cpp-restsdk/ApiClient.cpp | 269 ++- .../client/petstore/cpp-restsdk/ApiClient.h | 88 +- .../petstore/cpp-restsdk/ApiConfiguration.cpp | 77 +- .../petstore/cpp-restsdk/ApiConfiguration.h | 49 +- .../petstore/cpp-restsdk/ApiException.cpp | 50 +- .../petstore/cpp-restsdk/ApiException.h | 44 +- .../petstore/cpp-restsdk/HttpContent.cpp | 76 +- .../client/petstore/cpp-restsdk/HttpContent.h | 55 +- .../client/petstore/cpp-restsdk/IHttpBody.h | 19 +- .../client/petstore/cpp-restsdk/JsonBody.cpp | 25 +- .../client/petstore/cpp-restsdk/JsonBody.h | 24 +- .../client/petstore/cpp-restsdk/ModelBase.cpp | 617 +++--- .../client/petstore/cpp-restsdk/ModelBase.h | 186 +- .../cpp-restsdk/MultipartFormData.cpp | 142 +- .../petstore/cpp-restsdk/MultipartFormData.h | 47 +- .../client/petstore/cpp-restsdk/Object.cpp | 86 +- samples/client/petstore/cpp-restsdk/Object.h | 45 +- .../petstore/cpp-restsdk/api/PetApi.cpp | 1869 +++++++++-------- .../client/petstore/cpp-restsdk/api/PetApi.h | 207 +- .../petstore/cpp-restsdk/api/StoreApi.cpp | 908 ++++---- .../petstore/cpp-restsdk/api/StoreApi.h | 105 +- .../petstore/cpp-restsdk/api/UserApi.cpp | 1771 +++++++++------- .../client/petstore/cpp-restsdk/api/UserApi.h | 186 +- .../cpp-restsdk/model/ApiResponse.cpp | 251 +-- .../petstore/cpp-restsdk/model/ApiResponse.h | 95 +- .../petstore/cpp-restsdk/model/Category.cpp | 188 +- .../petstore/cpp-restsdk/model/Category.h | 77 +- .../petstore/cpp-restsdk/model/Order.cpp | 468 ++--- .../client/petstore/cpp-restsdk/model/Order.h | 149 +- .../client/petstore/cpp-restsdk/model/Pet.cpp | 495 ++--- .../client/petstore/cpp-restsdk/model/Pet.h | 141 +- .../client/petstore/cpp-restsdk/model/Tag.cpp | 188 +- .../client/petstore/cpp-restsdk/model/Tag.h | 77 +- .../petstore/cpp-restsdk/model/User.cpp | 618 +++--- .../client/petstore/cpp-restsdk/model/User.h | 185 +- 35 files changed, 4954 insertions(+), 4923 deletions(-) diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/ApiClient.cpp index 5df6b675e36..1ce911edc27 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiClient.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,18 +11,17 @@ */ #include "ApiClient.h" -#include "MultipartFormData.h" #include "ModelBase.h" +#include "MultipartFormData.h" -#include <sstream> -#include <limits> #include <iomanip> +#include <limits> +#include <sstream> -template <typename T> -utility::string_t toString(const T value) -{ +template <typename T> utility::string_t toString(const T value) { std::ostringstream out; - out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed << value; + out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed + << value; return out.str(); } @@ -32,162 +32,143 @@ namespace api { using namespace org::openapitools::client::model; -ApiClient::ApiClient(std::shared_ptr<ApiConfiguration> configuration ) - : m_Configuration(configuration) -{ -} -ApiClient::~ApiClient() -{ -} +ApiClient::ApiClient(std::shared_ptr<ApiConfiguration> configuration) + : m_Configuration(configuration) {} +ApiClient::~ApiClient() {} -std::shared_ptr<ApiConfiguration> ApiClient::getConfiguration() const -{ - return m_Configuration; +std::shared_ptr<ApiConfiguration> ApiClient::getConfiguration() const { + return m_Configuration; } -void ApiClient::setConfiguration(std::shared_ptr<ApiConfiguration> configuration) -{ - m_Configuration = configuration; +void ApiClient::setConfiguration( + std::shared_ptr<ApiConfiguration> configuration) { + m_Configuration = configuration; } - -utility::string_t ApiClient::parameterToString(utility::string_t value) -{ - return value; +utility::string_t ApiClient::parameterToString(utility::string_t value) { + return value; } -utility::string_t ApiClient::parameterToString(int64_t value) -{ - std::stringstream valueAsStringStream; - valueAsStringStream << value; - return utility::conversions::to_string_t(valueAsStringStream.str()); +utility::string_t ApiClient::parameterToString(int64_t value) { + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); } -utility::string_t ApiClient::parameterToString(int32_t value) -{ - std::stringstream valueAsStringStream; - valueAsStringStream << value; - return utility::conversions::to_string_t(valueAsStringStream.str()); +utility::string_t ApiClient::parameterToString(int32_t value) { + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); } -utility::string_t ApiClient::parameterToString(float value) -{ - return utility::conversions::to_string_t(toString(value)); +utility::string_t ApiClient::parameterToString(float value) { + return utility::conversions::to_string_t(toString(value)); } -utility::string_t ApiClient::parameterToString(double value) -{ - return utility::conversions::to_string_t(toString(value)); +utility::string_t ApiClient::parameterToString(double value) { + return utility::conversions::to_string_t(toString(value)); } -utility::string_t ApiClient::parameterToString(const utility::datetime &value) -{ - return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601)); +utility::string_t ApiClient::parameterToString(const utility::datetime &value) { + return utility::conversions::to_string_t( + value.to_string(utility::datetime::ISO_8601)); } pplx::task<web::http::http_response> ApiClient::callApi( - const utility::string_t& path, - const utility::string_t& method, - const std::map<utility::string_t, utility::string_t>& queryParams, + const utility::string_t &path, const utility::string_t &method, + const std::map<utility::string_t, utility::string_t> &queryParams, const std::shared_ptr<IHttpBody> postBody, - const std::map<utility::string_t, utility::string_t>& headerParams, - const std::map<utility::string_t, utility::string_t>& formParams, - const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams, - const utility::string_t& contentType -) const -{ - if (postBody != nullptr && formParams.size() != 0) - { - throw ApiException(400, utility::conversions::to_string_t("Cannot have body and form params")); + const std::map<utility::string_t, utility::string_t> &headerParams, + const std::map<utility::string_t, utility::string_t> &formParams, + const std::map<utility::string_t, std::shared_ptr<HttpContent>> &fileParams, + const utility::string_t &contentType) const { + if (postBody != nullptr && formParams.size() != 0) { + throw ApiException(400, utility::conversions::to_string_t( + "Cannot have body and form params")); + } + + if (postBody != nullptr && fileParams.size() != 0) { + throw ApiException(400, utility::conversions::to_string_t( + "Cannot have body and file params")); + } + + if (fileParams.size() > 0 && + contentType != utility::conversions::to_string_t("multipart/form-data")) { + throw ApiException(400, utility::conversions::to_string_t( + "Operations with file parameters must be " + "called with multipart/form-data")); + } + + web::http::client::http_client client(m_Configuration->getBaseUrl(), + m_Configuration->getHttpConfig()); + + web::http::http_request request; + for (auto &kvp : headerParams) { + request.headers().add(kvp.first, kvp.second); + } + + if (fileParams.size() > 0) { + MultipartFormData uploadData; + for (auto &kvp : formParams) { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } - - if (postBody != nullptr && fileParams.size() != 0) - { - throw ApiException(400, utility::conversions::to_string_t("Cannot have body and file params")); + for (auto &kvp : fileParams) { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } - - if (fileParams.size() > 0 && contentType != utility::conversions::to_string_t("multipart/form-data")) - { - throw ApiException(400, utility::conversions::to_string_t("Operations with file parameters must be called with multipart/form-data")); - } - - web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig()); - - web::http::http_request request; - for ( auto& kvp : headerParams ) - { - request.headers().add(kvp.first, kvp.second); - } - - if (fileParams.size() > 0) - { - MultipartFormData uploadData; - for (auto& kvp : formParams) - { - uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + std::stringstream data; + uploadData.writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body( + concurrency::streams::bytestream::open_istream(std::move(bodyString)), + length, + utility::conversions::to_string_t("multipart/form-data; boundary=") + + uploadData.getBoundary()); + } else { + if (postBody != nullptr) { + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body( + concurrency::streams::bytestream::open_istream(std::move(bodyString)), + length, contentType); + } else { + if (contentType == + utility::conversions::to_string_t("application/json")) { + web::json::value body_data = web::json::value::object(); + for (auto &kvp : formParams) { + body_data[kvp.first] = ModelBase::toJson(kvp.second); } - for (auto& kvp : fileParams) - { - uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + if (!formParams.empty()) { + request.set_body(body_data); } - std::stringstream data; - uploadData.writeTo(data); - auto bodyString = data.str(); - auto length = bodyString.size(); - request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary()); - } - else - { - if (postBody != nullptr) - { - std::stringstream data; - postBody->writeTo(data); - auto bodyString = data.str(); - auto length = bodyString.size(); - request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + } else { + web::http::uri_builder formData; + for (auto &kvp : formParams) { + formData.append_query(kvp.first, kvp.second); } - else - { - if (contentType == utility::conversions::to_string_t("application/json")) - { - web::json::value body_data = web::json::value::object(); - for (auto& kvp : formParams) - { - body_data[kvp.first] = ModelBase::toJson(kvp.second); - } - if (!formParams.empty()) - { - request.set_body(body_data); - } - } - else - { - web::http::uri_builder formData; - for (auto& kvp : formParams) - { - formData.append_query(kvp.first, kvp.second); - } - if (!formParams.empty()) - { - request.set_body(formData.query(), utility::conversions::to_string_t("application/x-www-form-urlencoded")); - } - } + if (!formParams.empty()) { + request.set_body(formData.query(), + utility::conversions::to_string_t( + "application/x-www-form-urlencoded")); } + } } - - web::http::uri_builder builder(path); - for (auto& kvp : queryParams) - { - builder.append_query(kvp.first, kvp.second); - } - request.set_request_uri(builder.to_uri()); - request.set_method(method); - if ( !request.headers().has( web::http::header_names::user_agent ) ) - { - request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() ); - } - - return client.request(request); -} - -} -} -} -} + } + + web::http::uri_builder builder(path); + for (auto &kvp : queryParams) { + builder.append_query(kvp.first, kvp.second); + } + request.set_request_uri(builder.to_uri()); + request.set_method(method); + if (!request.headers().has(web::http::header_names::user_agent)) { + request.headers().add(web::http::header_names::user_agent, + m_Configuration->getUserAgent()); + } + + return client.request(request); +} + +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.h b/samples/client/petstore/cpp-restsdk/ApiClient.h index 8aea53688c5..9f686c09b6f 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.h +++ b/samples/client/petstore/cpp-restsdk/ApiClient.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,11 +19,10 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ - #include "ApiConfiguration.h" #include "ApiException.h" -#include "IHttpBody.h" #include "HttpContent.h" +#include "IHttpBody.h" #include <memory> #include <vector> @@ -37,57 +37,53 @@ namespace api { using namespace org::openapitools::client::model; -class ApiClient -{ +class ApiClient { public: - ApiClient( std::shared_ptr<ApiConfiguration> configuration = nullptr ); - virtual ~ApiClient(); - - std::shared_ptr<ApiConfiguration> getConfiguration() const; - void setConfiguration(std::shared_ptr<ApiConfiguration> configuration); - - static utility::string_t parameterToString(utility::string_t value); - static utility::string_t parameterToString(int32_t value); - static utility::string_t parameterToString(int64_t value); - static utility::string_t parameterToString(float value); - static utility::string_t parameterToString(double value); - static utility::string_t parameterToString(const utility::datetime &value); - template<class T> - static utility::string_t parameterToString(const std::vector<T>& value); - - pplx::task<web::http::http_response> callApi( - const utility::string_t& path, - const utility::string_t& method, - const std::map<utility::string_t, utility::string_t>& queryParams, - const std::shared_ptr<IHttpBody> postBody, - const std::map<utility::string_t, utility::string_t>& headerParams, - const std::map<utility::string_t, utility::string_t>& formParams, - const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams, - const utility::string_t& contentType - ) const; + ApiClient(std::shared_ptr<ApiConfiguration> configuration = nullptr); + virtual ~ApiClient(); + + std::shared_ptr<ApiConfiguration> getConfiguration() const; + void setConfiguration(std::shared_ptr<ApiConfiguration> configuration); + + static utility::string_t parameterToString(utility::string_t value); + static utility::string_t parameterToString(int32_t value); + static utility::string_t parameterToString(int64_t value); + static utility::string_t parameterToString(float value); + static utility::string_t parameterToString(double value); + static utility::string_t parameterToString(const utility::datetime &value); + template <class T> + static utility::string_t parameterToString(const std::vector<T> &value); + + pplx::task<web::http::http_response> + callApi(const utility::string_t &path, const utility::string_t &method, + const std::map<utility::string_t, utility::string_t> &queryParams, + const std::shared_ptr<IHttpBody> postBody, + const std::map<utility::string_t, utility::string_t> &headerParams, + const std::map<utility::string_t, utility::string_t> &formParams, + const std::map<utility::string_t, std::shared_ptr<HttpContent>> + &fileParams, + const utility::string_t &contentType) const; protected: - - std::shared_ptr<ApiConfiguration> m_Configuration; + std::shared_ptr<ApiConfiguration> m_Configuration; }; -template<class T> -utility::string_t ApiClient::parameterToString(const std::vector<T>& value) -{ - utility::stringstream_t ss; +template <class T> +utility::string_t ApiClient::parameterToString(const std::vector<T> &value) { + utility::stringstream_t ss; - for( size_t i = 0; i < value.size(); i++) - { - if( i > 0) ss << utility::conversions::to_string_t(", "); - ss << ApiClient::parameterToString(value[i]); - } + for (size_t i = 0; i < value.size(); i++) { + if (i > 0) + ss << utility::conversions::to_string_t(", "); + ss << ApiClient::parameterToString(value[i]); + } - return ss.str(); + return ss.str(); } -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp index abc0510b192..fff446fa43d 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,65 +17,51 @@ namespace openapitools { namespace client { namespace api { -ApiConfiguration::ApiConfiguration() -{ -} +ApiConfiguration::ApiConfiguration() {} -ApiConfiguration::~ApiConfiguration() -{ -} +ApiConfiguration::~ApiConfiguration() {} -web::http::client::http_client_config& ApiConfiguration::getHttpConfig() -{ - return m_HttpConfig; +web::http::client::http_client_config &ApiConfiguration::getHttpConfig() { + return m_HttpConfig; } -void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value ) -{ - m_HttpConfig = value; +void ApiConfiguration::setHttpConfig( + web::http::client::http_client_config &value) { + m_HttpConfig = value; } -utility::string_t ApiConfiguration::getBaseUrl() const -{ - return m_BaseUrl; -} +utility::string_t ApiConfiguration::getBaseUrl() const { return m_BaseUrl; } -void ApiConfiguration::setBaseUrl( const utility::string_t value ) -{ - m_BaseUrl = value; +void ApiConfiguration::setBaseUrl(const utility::string_t value) { + m_BaseUrl = value; } -utility::string_t ApiConfiguration::getUserAgent() const -{ - return m_UserAgent; -} +utility::string_t ApiConfiguration::getUserAgent() const { return m_UserAgent; } -void ApiConfiguration::setUserAgent( const utility::string_t value ) -{ - m_UserAgent = value; +void ApiConfiguration::setUserAgent(const utility::string_t value) { + m_UserAgent = value; } -std::map<utility::string_t, utility::string_t>& ApiConfiguration::getDefaultHeaders() -{ - return m_DefaultHeaders; +std::map<utility::string_t, utility::string_t> & +ApiConfiguration::getDefaultHeaders() { + return m_DefaultHeaders; } -utility::string_t ApiConfiguration::getApiKey( const utility::string_t& prefix) const -{ - auto result = m_ApiKeys.find(prefix); - if( result != m_ApiKeys.end() ) - { - return result->second; - } - return utility::conversions::to_string_t(""); +utility::string_t +ApiConfiguration::getApiKey(const utility::string_t &prefix) const { + auto result = m_ApiKeys.find(prefix); + if (result != m_ApiKeys.end()) { + return result->second; + } + return utility::conversions::to_string_t(""); } -void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ) -{ - m_ApiKeys[prefix] = apiKey; +void ApiConfiguration::setApiKey(const utility::string_t &prefix, + const utility::string_t &apiKey) { + m_ApiKeys[prefix] = apiKey; } -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h index 35b7892cbf5..1788a356517 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,8 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ - - #include <map> #include <cpprest/details/basic_types.h> @@ -29,36 +28,36 @@ namespace openapitools { namespace client { namespace api { -class ApiConfiguration -{ +class ApiConfiguration { public: - ApiConfiguration(); - virtual ~ApiConfiguration(); + ApiConfiguration(); + virtual ~ApiConfiguration(); - web::http::client::http_client_config& getHttpConfig(); - void setHttpConfig( web::http::client::http_client_config& value ); + web::http::client::http_client_config &getHttpConfig(); + void setHttpConfig(web::http::client::http_client_config &value); - utility::string_t getBaseUrl() const; - void setBaseUrl( const utility::string_t value ); + utility::string_t getBaseUrl() const; + void setBaseUrl(const utility::string_t value); - utility::string_t getUserAgent() const; - void setUserAgent( const utility::string_t value ); + utility::string_t getUserAgent() const; + void setUserAgent(const utility::string_t value); - std::map<utility::string_t, utility::string_t>& getDefaultHeaders(); + std::map<utility::string_t, utility::string_t> &getDefaultHeaders(); - utility::string_t getApiKey( const utility::string_t& prefix) const; - void setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ); + utility::string_t getApiKey(const utility::string_t &prefix) const; + void setApiKey(const utility::string_t &prefix, + const utility::string_t &apiKey); protected: - utility::string_t m_BaseUrl; - std::map<utility::string_t, utility::string_t> m_DefaultHeaders; - std::map<utility::string_t, utility::string_t> m_ApiKeys; - web::http::client::http_client_config m_HttpConfig; - utility::string_t m_UserAgent; + utility::string_t m_BaseUrl; + std::map<utility::string_t, utility::string_t> m_DefaultHeaders; + std::map<utility::string_t, utility::string_t> m_ApiKeys; + web::http::client::http_client_config m_HttpConfig; + utility::string_t m_UserAgent; }; -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.cpp b/samples/client/petstore/cpp-restsdk/ApiException.cpp index f8206bc56c9..7b278fe0c0c 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiException.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,38 +17,27 @@ namespace openapitools { namespace client { namespace api { -ApiException::ApiException( int errorCode - , const utility::string_t& message - , std::shared_ptr<std::istream> content /*= nullptr*/ ) - : web::http::http_exception( errorCode, message ) - , m_Content(content) -{ -} -ApiException::ApiException( int errorCode - , const utility::string_t& message - , std::map<utility::string_t, utility::string_t>& headers - , std::shared_ptr<std::istream> content /*= nullptr*/ ) - : web::http::http_exception( errorCode, message ) - , m_Content(content) - , m_Headers(headers) -{ -} +ApiException::ApiException(int errorCode, const utility::string_t &message, + std::shared_ptr<std::istream> content /*= nullptr*/) + : web::http::http_exception(errorCode, message), m_Content(content) {} +ApiException::ApiException( + int errorCode, const utility::string_t &message, + std::map<utility::string_t, utility::string_t> &headers, + std::shared_ptr<std::istream> content /*= nullptr*/) + : web::http::http_exception(errorCode, message), m_Content(content), + m_Headers(headers) {} -ApiException::~ApiException() -{ -} +ApiException::~ApiException() {} -std::shared_ptr<std::istream> ApiException::getContent() const -{ - return m_Content; +std::shared_ptr<std::istream> ApiException::getContent() const { + return m_Content; } -std::map<utility::string_t, utility::string_t>& ApiException::getHeaders() -{ - return m_Headers; +std::map<utility::string_t, utility::string_t> &ApiException::getHeaders() { + return m_Headers; } -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/ApiException.h b/samples/client/petstore/cpp-restsdk/ApiException.h index 7de8a64e96d..e9d44907853 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.h +++ b/samples/client/petstore/cpp-restsdk/ApiException.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,44 +19,37 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ - - -#include <memory> #include <map> +#include <memory> #include <cpprest/details/basic_types.h> #include <cpprest/http_msg.h> - namespace org { namespace openapitools { namespace client { namespace api { -class ApiException - : public web::http::http_exception -{ +class ApiException : public web::http::http_exception { public: - ApiException( int errorCode - , const utility::string_t& message - , std::shared_ptr<std::istream> content = nullptr ); - ApiException( int errorCode - , const utility::string_t& message - , std::map<utility::string_t, utility::string_t>& headers - , std::shared_ptr<std::istream> content = nullptr ); - virtual ~ApiException(); - - std::map<utility::string_t, utility::string_t>& getHeaders(); - std::shared_ptr<std::istream> getContent() const; + ApiException(int errorCode, const utility::string_t &message, + std::shared_ptr<std::istream> content = nullptr); + ApiException(int errorCode, const utility::string_t &message, + std::map<utility::string_t, utility::string_t> &headers, + std::shared_ptr<std::istream> content = nullptr); + virtual ~ApiException(); + + std::map<utility::string_t, utility::string_t> &getHeaders(); + std::shared_ptr<std::istream> getContent() const; protected: - std::shared_ptr<std::istream> m_Content; - std::map<utility::string_t, utility::string_t> m_Headers; + std::shared_ptr<std::istream> m_Content; + std::map<utility::string_t, utility::string_t> m_Headers; }; -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/HttpContent.cpp index c64fc2e26ee..83a810104b1 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.cpp +++ b/samples/client/petstore/cpp-restsdk/HttpContent.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,71 +17,46 @@ namespace openapitools { namespace client { namespace model { -HttpContent::HttpContent() -{ -} +HttpContent::HttpContent() {} -HttpContent::~HttpContent() -{ -} +HttpContent::~HttpContent() {} -utility::string_t HttpContent::getContentDisposition() -{ - return m_ContentDisposition; +utility::string_t HttpContent::getContentDisposition() { + return m_ContentDisposition; } -void HttpContent::setContentDisposition( const utility::string_t & value ) -{ - m_ContentDisposition = value; +void HttpContent::setContentDisposition(const utility::string_t &value) { + m_ContentDisposition = value; } -utility::string_t HttpContent::getName() -{ - return m_Name; -} +utility::string_t HttpContent::getName() { return m_Name; } -void HttpContent::setName( const utility::string_t & value ) -{ - m_Name = value; -} +void HttpContent::setName(const utility::string_t &value) { m_Name = value; } -utility::string_t HttpContent::getFileName() -{ - return m_FileName; -} +utility::string_t HttpContent::getFileName() { return m_FileName; } -void HttpContent::setFileName( const utility::string_t & value ) -{ - m_FileName = value; +void HttpContent::setFileName(const utility::string_t &value) { + m_FileName = value; } -utility::string_t HttpContent::getContentType() -{ - return m_ContentType; -} +utility::string_t HttpContent::getContentType() { return m_ContentType; } -void HttpContent::setContentType( const utility::string_t & value ) -{ - m_ContentType = value; +void HttpContent::setContentType(const utility::string_t &value) { + m_ContentType = value; } -std::shared_ptr<std::istream> HttpContent::getData() -{ - return m_Data; -} +std::shared_ptr<std::istream> HttpContent::getData() { return m_Data; } -void HttpContent::setData( std::shared_ptr<std::istream> value ) -{ - m_Data = value; +void HttpContent::setData(std::shared_ptr<std::istream> value) { + m_Data = value; } -void HttpContent::writeTo( std::ostream& stream ) -{ - m_Data->seekg( 0, m_Data->beg ); - stream << m_Data->rdbuf(); +void HttpContent::writeTo(std::ostream &stream) { + m_Data->seekg(0, m_Data->beg); + stream << m_Data->rdbuf(); } -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.h b/samples/client/petstore/cpp-restsdk/HttpContent.h index a5edc34dd2a..c28300c7099 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.h +++ b/samples/client/petstore/cpp-restsdk/HttpContent.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,8 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ - - #include <memory> #include <cpprest/details/basic_types.h> @@ -29,41 +28,41 @@ namespace openapitools { namespace client { namespace model { -class HttpContent -{ +class HttpContent { public: - HttpContent(); - virtual ~HttpContent(); + HttpContent(); + virtual ~HttpContent(); - virtual utility::string_t getContentDisposition(); - virtual void setContentDisposition( const utility::string_t& value ); + virtual utility::string_t getContentDisposition(); + virtual void setContentDisposition(const utility::string_t &value); - virtual utility::string_t getName(); - virtual void setName( const utility::string_t& value ); + virtual utility::string_t getName(); + virtual void setName(const utility::string_t &value); - virtual utility::string_t getFileName(); - virtual void setFileName( const utility::string_t& value ); + virtual utility::string_t getFileName(); + virtual void setFileName(const utility::string_t &value); - virtual utility::string_t getContentType(); - virtual void setContentType( const utility::string_t& value ); + virtual utility::string_t getContentType(); + virtual void setContentType(const utility::string_t &value); - virtual std::shared_ptr<std::istream> getData(); - virtual void setData( std::shared_ptr<std::istream> value ); + virtual std::shared_ptr<std::istream> getData(); + virtual void setData(std::shared_ptr<std::istream> value); - virtual void writeTo( std::ostream& stream ); + virtual void writeTo(std::ostream &stream); protected: - // NOTE: no utility::string_t here because those strings can only contain ascii - utility::string_t m_ContentDisposition; - utility::string_t m_Name; - utility::string_t m_FileName; - utility::string_t m_ContentType; - std::shared_ptr<std::istream> m_Data; + // NOTE: no utility::string_t here because those strings can only contain + // ascii + utility::string_t m_ContentDisposition; + utility::string_t m_Name; + utility::string_t m_FileName; + utility::string_t m_ContentType; + std::shared_ptr<std::istream> m_Data; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/IHttpBody.h b/samples/client/petstore/cpp-restsdk/IHttpBody.h index 592a3e3bcf7..1e8c061ac25 100644 --- a/samples/client/petstore/cpp-restsdk/IHttpBody.h +++ b/samples/client/petstore/cpp-restsdk/IHttpBody.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ - #include <iostream> namespace org { @@ -26,17 +26,16 @@ namespace openapitools { namespace client { namespace model { -class IHttpBody -{ +class IHttpBody { public: - virtual ~IHttpBody() { } + virtual ~IHttpBody() {} - virtual void writeTo( std::ostream& stream ) = 0; + virtual void writeTo(std::ostream &stream) = 0; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/JsonBody.cpp index f058afe6e08..8ee4289ba5a 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.cpp +++ b/samples/client/petstore/cpp-restsdk/JsonBody.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,21 +17,13 @@ namespace openapitools { namespace client { namespace model { -JsonBody::JsonBody( const web::json::value& json) - : m_Json(json) -{ -} +JsonBody::JsonBody(const web::json::value &json) : m_Json(json) {} -JsonBody::~JsonBody() -{ -} +JsonBody::~JsonBody() {} -void JsonBody::writeTo( std::ostream& target ) -{ - m_Json.serialize(target); -} +void JsonBody::writeTo(std::ostream &target) { m_Json.serialize(target); } -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.h b/samples/client/petstore/cpp-restsdk/JsonBody.h index 028dd07bfcc..20bb691bedd 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.h +++ b/samples/client/petstore/cpp-restsdk/JsonBody.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ - #include "IHttpBody.h" #include <cpprest/json.h> @@ -28,22 +28,20 @@ namespace openapitools { namespace client { namespace model { -class JsonBody - : public IHttpBody -{ +class JsonBody : public IHttpBody { public: - JsonBody( const web::json::value& value ); - virtual ~JsonBody(); + JsonBody(const web::json::value &value); + virtual ~JsonBody(); - void writeTo( std::ostream& target ) override; + void writeTo(std::ostream &target) override; protected: - web::json::value m_Json; + web::json::value m_Json; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/ModelBase.cpp index 4abda808cb0..21c0d80187c 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.cpp +++ b/samples/client/petstore/cpp-restsdk/ModelBase.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,363 +17,353 @@ namespace openapitools { namespace client { namespace model { -ModelBase::ModelBase() -{ +ModelBase::ModelBase() {} +ModelBase::~ModelBase() {} + +web::json::value ModelBase::toJson(const utility::string_t &value) { + return web::json::value::string(value); } -ModelBase::~ModelBase() -{ +web::json::value ModelBase::toJson(const utility::datetime &value) { + return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); +} +web::json::value ModelBase::toJson(int32_t value) { + return web::json::value::number(value); +} +web::json::value ModelBase::toJson(int64_t value) { + return web::json::value::number(value); +} +web::json::value ModelBase::toJson(double value) { + return web::json::value::number(value); } - -web::json::value ModelBase::toJson( const utility::string_t& value ) -{ - return web::json::value::string(value); -} -web::json::value ModelBase::toJson( const utility::datetime& value ) -{ - return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); -} -web::json::value ModelBase::toJson( int32_t value ) -{ - return web::json::value::number(value); -} -web::json::value ModelBase::toJson( int64_t value ) -{ - return web::json::value::number(value); -} -web::json::value ModelBase::toJson( double value ) -{ - return web::json::value::number(value); -} web::json::value ModelBase::toJson(bool value) { - return web::json::value::boolean(value); + return web::json::value::boolean(value); } -web::json::value ModelBase::toJson( std::shared_ptr<HttpContent> content ) -{ - web::json::value value; - value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition()); - value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType()); - value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName()); - value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) ); - return value; +web::json::value ModelBase::toJson(std::shared_ptr<HttpContent> content) { + web::json::value value; + value[utility::conversions::to_string_t("ContentDisposition")] = + ModelBase::toJson(content->getContentDisposition()); + value[utility::conversions::to_string_t("ContentType")] = + ModelBase::toJson(content->getContentType()); + value[utility::conversions::to_string_t("FileName")] = + ModelBase::toJson(content->getFileName()); + value[utility::conversions::to_string_t("InputStream")] = + web::json::value::string(ModelBase::toBase64(content->getData())); + return value; } -std::shared_ptr<HttpContent> ModelBase::fileFromJson(const web::json::value& val) -{ - std::shared_ptr<HttpContent> content(new HttpContent); +std::shared_ptr<HttpContent> +ModelBase::fileFromJson(const web::json::value &val) { + std::shared_ptr<HttpContent> content(new HttpContent); - if(val.has_field(utility::conversions::to_string_t("ContentDisposition"))) - { - content->setContentDisposition( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentDisposition"))) ); - } - if(val.has_field(utility::conversions::to_string_t("ContentType"))) - { - content->setContentType( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentType"))) ); - } - if(val.has_field(utility::conversions::to_string_t("FileName"))) - { - content->setFileName( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("FileName"))) ); - } - if(val.has_field(utility::conversions::to_string_t("InputStream"))) - { - content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("InputStream")))) ); - } + if (val.has_field(utility::conversions::to_string_t("ContentDisposition"))) { + content->setContentDisposition(ModelBase::stringFromJson( + val.at(utility::conversions::to_string_t("ContentDisposition")))); + } + if (val.has_field(utility::conversions::to_string_t("ContentType"))) { + content->setContentType(ModelBase::stringFromJson( + val.at(utility::conversions::to_string_t("ContentType")))); + } + if (val.has_field(utility::conversions::to_string_t("FileName"))) { + content->setFileName(ModelBase::stringFromJson( + val.at(utility::conversions::to_string_t("FileName")))); + } + if (val.has_field(utility::conversions::to_string_t("InputStream"))) { + content->setData(ModelBase::fromBase64(ModelBase::stringFromJson( + val.at(utility::conversions::to_string_t("InputStream"))))); + } - return content; + return content; } -web::json::value ModelBase::toJson( std::shared_ptr<ModelBase> content ) -{ - return content.get() ? content->toJson() : web::json::value::null(); +web::json::value ModelBase::toJson(std::shared_ptr<ModelBase> content) { + return content.get() ? content->toJson() : web::json::value::null(); } -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType) -{ - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) ); - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) ); - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( value->getContentDisposition() ); - content->setContentType( value->getContentType() ); - content->setData( value->getData() ); - content->setFileName( value->getFileName() ); - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) ); - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - std::stringstream* valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) ); - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - std::stringstream* valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ; - return content; -} -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType ) -{ - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - std::stringstream* valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) ); - return content; +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, + const utility::string_t &value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + content->setData(std::shared_ptr<std::istream>( + new std::stringstream(utility::conversions::to_utf8string(value)))); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, + const utility::datetime &value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + content->setData(std::shared_ptr<std::istream>( + new std::stringstream(utility::conversions::to_utf8string( + value.to_string(utility::datetime::ISO_8601))))); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, + std::shared_ptr<HttpContent> value) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition(value->getContentDisposition()); + content->setContentType(value->getContentType()); + content->setData(value->getData()); + content->setFileName(value->getFileName()); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, + const web::json::value &value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + content->setData(std::shared_ptr<std::istream>(new std::stringstream( + utility::conversions::to_utf8string(value.serialize())))); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, int32_t value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + std::stringstream *valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, int64_t value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + std::stringstream *valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); + return content; +} +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, double value, + const utility::string_t &contentType) { + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + std::stringstream *valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); + return content; } -// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B -const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +// base64 encoding/decoding based on : +// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B +const static char Base64Chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const static char Base64PadChar = '='; -utility::string_t ModelBase::toBase64( utility::string_t value ) -{ - std::shared_ptr<std::istream> source( new std::stringstream( utility::conversions::to_utf8string(value) ) ); - return ModelBase::toBase64(source); -} -utility::string_t ModelBase::toBase64( std::shared_ptr<std::istream> value ) -{ - value->seekg( 0, value->end ); - size_t length = value->tellg(); - value->seekg( 0, value->beg ); - utility::string_t base64; - base64.reserve( ((length / 3) + (length % 3 > 0)) * 4 ); - char read[3] = { 0 }; - uint32_t temp; - for ( size_t idx = 0; idx < length / 3; idx++ ) - { - value->read( read, 3 ); - temp = (read[0]) << 16; - temp += (read[1]) << 8; - temp += (read[2]); - base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); - base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); - base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); - base64.append( 1, Base64Chars[(temp & 0x0000003F)] ); - } - switch ( length % 3 ) - { - case 1: - value->read( read, 1 ); - temp = read[0] << 16; - base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); - base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); - base64.append( 2, Base64PadChar ); - break; - case 2: - value->read( read, 2 ); - temp = read[0] << 16; - temp += read[1] << 8; - base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); - base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); - base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); - base64.append( 1, Base64PadChar ); - break; - } - return base64; +utility::string_t ModelBase::toBase64(utility::string_t value) { + std::shared_ptr<std::istream> source( + new std::stringstream(utility::conversions::to_utf8string(value))); + return ModelBase::toBase64(source); +} +utility::string_t ModelBase::toBase64(std::shared_ptr<std::istream> value) { + value->seekg(0, value->end); + size_t length = value->tellg(); + value->seekg(0, value->beg); + utility::string_t base64; + base64.reserve(((length / 3) + (length % 3 > 0)) * 4); + char read[3] = {0}; + uint32_t temp; + for (size_t idx = 0; idx < length / 3; idx++) { + value->read(read, 3); + temp = (read[0]) << 16; + temp += (read[1]) << 8; + temp += (read[2]); + base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); + base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); + base64.append(1, Base64Chars[(temp & 0x00000FC0) >> 6]); + base64.append(1, Base64Chars[(temp & 0x0000003F)]); + } + switch (length % 3) { + case 1: + value->read(read, 1); + temp = read[0] << 16; + base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); + base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); + base64.append(2, Base64PadChar); + break; + case 2: + value->read(read, 2); + temp = read[0] << 16; + temp += read[1] << 8; + base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); + base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); + base64.append(1, Base64Chars[(temp & 0x00000FC0) >> 6]); + base64.append(1, Base64PadChar); + break; + } + return base64; } +std::shared_ptr<std::istream> +ModelBase::fromBase64(const utility::string_t &encoded) { + std::shared_ptr<std::stringstream> result(new std::stringstream); -std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded ) -{ - std::shared_ptr<std::stringstream> result(new std::stringstream); + char outBuf[3] = {0}; + uint32_t temp = 0; - char outBuf[3] = { 0 }; - uint32_t temp = 0; - - utility::string_t::const_iterator cursor = encoded.begin(); - while ( cursor < encoded.end() ) - { - for ( size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++ ) - { - temp <<= 6; - if ( *cursor >= 0x41 && *cursor <= 0x5A ) - { - temp |= *cursor - 0x41; - } - else if ( *cursor >= 0x61 && *cursor <= 0x7A ) - { - temp |= *cursor - 0x47; - } - else if ( *cursor >= 0x30 && *cursor <= 0x39 ) - { - temp |= *cursor + 0x04; - } - else if ( *cursor == 0x2B ) - { - temp |= 0x3E; //change to 0x2D for URL alphabet - } - else if ( *cursor == 0x2F ) - { - temp |= 0x3F; //change to 0x5F for URL alphabet - } - else if ( *cursor == Base64PadChar ) //pad - { - switch ( encoded.end() - cursor ) - { - case 1: //One pad character - outBuf[0] = (temp >> 16) & 0x000000FF; - outBuf[1] = (temp >> 8) & 0x000000FF; - result->write( outBuf, 2 ); - return result; - case 2: //Two pad characters - outBuf[0] = (temp >> 10) & 0x000000FF; - result->write( outBuf, 1 ); - return result; - default: - throw web::json::json_exception( utility::conversions::to_string_t( "Invalid Padding in Base 64!" ).c_str() ); - } - } - else - { - throw web::json::json_exception( utility::conversions::to_string_t( "Non-Valid Character in Base 64!" ).c_str() ); - } - ++cursor; + utility::string_t::const_iterator cursor = encoded.begin(); + while (cursor < encoded.end()) { + for (size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++) { + temp <<= 6; + if (*cursor >= 0x41 && *cursor <= 0x5A) { + temp |= *cursor - 0x41; + } else if (*cursor >= 0x61 && *cursor <= 0x7A) { + temp |= *cursor - 0x47; + } else if (*cursor >= 0x30 && *cursor <= 0x39) { + temp |= *cursor + 0x04; + } else if (*cursor == 0x2B) { + temp |= 0x3E; // change to 0x2D for URL alphabet + } else if (*cursor == 0x2F) { + temp |= 0x3F; // change to 0x5F for URL alphabet + } else if (*cursor == Base64PadChar) // pad + { + switch (encoded.end() - cursor) { + case 1: // One pad character + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + result->write(outBuf, 2); + return result; + case 2: // Two pad characters + outBuf[0] = (temp >> 10) & 0x000000FF; + result->write(outBuf, 1); + return result; + default: + throw web::json::json_exception( + utility::conversions::to_string_t("Invalid Padding in Base 64!") + .c_str()); } - - outBuf[0] = (temp >> 16) & 0x000000FF; - outBuf[1] = (temp >> 8) & 0x000000FF; - outBuf[2] = (temp) & 0x000000FF; - result->write( outBuf, 3 ); + } else { + throw web::json::json_exception( + utility::conversions::to_string_t("Non-Valid Character in Base 64!") + .c_str()); + } + ++cursor; } - return result; + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + outBuf[2] = (temp)&0x000000FF; + result->write(outBuf, 3); + } + + return result; } -int64_t ModelBase::int64_tFromJson(const web::json::value& val) -{ - return val.as_number().to_int64(); +int64_t ModelBase::int64_tFromJson(const web::json::value &val) { + return val.as_number().to_int64(); } -int32_t ModelBase::int32_tFromJson(const web::json::value& val) -{ - return val.as_integer(); +int32_t ModelBase::int32_tFromJson(const web::json::value &val) { + return val.as_integer(); } -float ModelBase::floatFromJson(const web::json::value& val) -{ - return static_cast<float>(val.as_double()); +float ModelBase::floatFromJson(const web::json::value &val) { + return static_cast<float>(val.as_double()); } -utility::string_t ModelBase::stringFromJson(const web::json::value& val) -{ - return val.is_string() ? val.as_string() : utility::conversions::to_string_t(""); +utility::string_t ModelBase::stringFromJson(const web::json::value &val) { + return val.is_string() ? val.as_string() + : utility::conversions::to_string_t(""); } -utility::datetime ModelBase::dateFromJson(const web::json::value& val) -{ - return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601); +utility::datetime ModelBase::dateFromJson(const web::json::value &val) { + return utility::datetime::from_string(val.as_string(), + utility::datetime::ISO_8601); } -bool ModelBase::boolFromJson(const web::json::value& val) -{ - return val.as_bool(); +bool ModelBase::boolFromJson(const web::json::value &val) { + return val.as_bool(); } -double ModelBase::doubleFromJson(const web::json::value& val) -{ - return val.as_double(); +double ModelBase::doubleFromJson(const web::json::value &val) { + return val.as_double(); } -int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); +int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - int64_t result = 0; - ss >> result; - return result; -} -int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); + utility::stringstream_t ss(str); + int64_t result = 0; + ss >> result; + return result; +} +int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - int32_t result = 0; - ss >> result; - return result; -} -float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); + utility::stringstream_t ss(str); + int32_t result = 0; + ss >> result; + return result; +} +float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - float result = 0; - ss >> result; - return result; -} -utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val) -{ - std::shared_ptr<std::istream> data = val->getData(); - data->seekg( 0, data->beg ); + utility::stringstream_t ss(str); + float result = 0; + ss >> result; + return result; +} +utility::string_t +ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val) { + std::shared_ptr<std::istream> data = val->getData(); + data->seekg(0, data->beg); - std::string str((std::istreambuf_iterator<char>(*data.get())), - std::istreambuf_iterator<char>()); + std::string str((std::istreambuf_iterator<char>(*data.get())), + std::istreambuf_iterator<char>()); - return utility::conversions::to_string_t(str); + return utility::conversions::to_string_t(str); } -utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); - return utility::datetime::from_string(str, utility::datetime::ISO_8601); +utility::datetime +ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); + return utility::datetime::from_string(str, utility::datetime::ISO_8601); } -bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); +bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - bool result = false; - ss >> result; - return result; -} -double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); - - utility::stringstream_t ss(str); - double result = 0.0; - ss >> result; - return result; + utility::stringstream_t ss(str); + bool result = false; + ss >> result; + return result; } +double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); -web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val) -{ - utility::string_t str = ModelBase::stringFromHttpContent(val); - return web::json::value::parse(str); + utility::stringstream_t ss(str); + double result = 0.0; + ss >> result; + return result; } +web::json::value +ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val) { + utility::string_t str = ModelBase::stringFromHttpContent(val); + return web::json::value::parse(str); } -} -} -} + +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.h b/samples/client/petstore/cpp-restsdk/ModelBase.h index e35de11673e..b37d7963f9d 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/ModelBase.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ - #include "HttpContent.h" #include "MultipartFormData.h" @@ -32,89 +32,121 @@ namespace openapitools { namespace client { namespace model { -class ModelBase -{ +class ModelBase { public: - ModelBase(); - virtual ~ModelBase(); - - virtual void validate() = 0; - - virtual web::json::value toJson() const = 0; - virtual void fromJson(const web::json::value& json) = 0; - - virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const = 0; - virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) = 0; - - static web::json::value toJson( const utility::string_t& value ); - static web::json::value toJson( const utility::datetime& value ); - static web::json::value toJson( std::shared_ptr<HttpContent> value ); - static web::json::value toJson( std::shared_ptr<ModelBase> value ); - static web::json::value toJson( int32_t value ); - static web::json::value toJson( int64_t value ); - static web::json::value toJson( double value ); - static web::json::value toJson( bool value ); - template<class T> - static web::json::value toJson(const std::vector<T>& value); - - static int64_t int64_tFromJson(const web::json::value& val); - static int32_t int32_tFromJson(const web::json::value& val); - static float floatFromJson(const web::json::value& val); - static utility::string_t stringFromJson(const web::json::value& val); - static utility::datetime dateFromJson(const web::json::value& val); - static double doubleFromJson(const web::json::value& val); - static bool boolFromJson(const web::json::value& val); - static std::shared_ptr<HttpContent> fileFromJson(const web::json::value& val); - - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value ); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); - template <class T> - static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); - - static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val); - static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val); - static float floatFromHttpContent(std::shared_ptr<HttpContent> val); - static utility::string_t stringFromHttpContent(std::shared_ptr<HttpContent> val); - static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val); - static bool boolFromHttpContent(std::shared_ptr<HttpContent> val); - static double doubleFromHttpContent(std::shared_ptr<HttpContent> val); - static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val); - - - static utility::string_t toBase64( utility::string_t value ); - static utility::string_t toBase64( std::shared_ptr<std::istream> value ); - static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded ); + ModelBase(); + virtual ~ModelBase(); + + virtual void validate() = 0; + + virtual web::json::value toJson() const = 0; + virtual void fromJson(const web::json::value &json) = 0; + + virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const = 0; + virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) = 0; + + static web::json::value toJson(const utility::string_t &value); + static web::json::value toJson(const utility::datetime &value); + static web::json::value toJson(std::shared_ptr<HttpContent> value); + static web::json::value toJson(std::shared_ptr<ModelBase> value); + static web::json::value toJson(int32_t value); + static web::json::value toJson(int64_t value); + static web::json::value toJson(double value); + static web::json::value toJson(bool value); + template <class T> + static web::json::value toJson(const std::vector<T> &value); + + static int64_t int64_tFromJson(const web::json::value &val); + static int32_t int32_tFromJson(const web::json::value &val); + static float floatFromJson(const web::json::value &val); + static utility::string_t stringFromJson(const web::json::value &val); + static utility::datetime dateFromJson(const web::json::value &val); + static double doubleFromJson(const web::json::value &val); + static bool boolFromJson(const web::json::value &val); + static std::shared_ptr<HttpContent> fileFromJson(const web::json::value &val); + + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, const utility::string_t &value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, const utility::datetime &value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, + std::shared_ptr<HttpContent> value); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, const web::json::value &value, + const utility::string_t &contentType = + utility::conversions::to_string_t("application/json")); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, int32_t value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, int64_t value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, double value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + template <class T> + static std::shared_ptr<HttpContent> + toHttpContent(const utility::string_t &name, const std::vector<T> &value, + const utility::string_t &contentType = + utility::conversions::to_string_t("")); + + static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val); + static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val); + static float floatFromHttpContent(std::shared_ptr<HttpContent> val); + static utility::string_t + stringFromHttpContent(std::shared_ptr<HttpContent> val); + static utility::datetime + dateFromHttpContent(std::shared_ptr<HttpContent> val); + static bool boolFromHttpContent(std::shared_ptr<HttpContent> val); + static double doubleFromHttpContent(std::shared_ptr<HttpContent> val); + static web::json::value + valueFromHttpContent(std::shared_ptr<HttpContent> val); + + static utility::string_t toBase64(utility::string_t value); + static utility::string_t toBase64(std::shared_ptr<std::istream> value); + static std::shared_ptr<std::istream> + fromBase64(const utility::string_t &encoded); }; -template<class T> -web::json::value ModelBase::toJson(const std::vector<T>& value) { - std::vector<web::json::value> ret; - for (auto& x : value) { - ret.push_back(toJson(x)); - } +template <class T> +web::json::value ModelBase::toJson(const std::vector<T> &value) { + std::vector<web::json::value> ret; + for (auto &x : value) { + ret.push_back(toJson(x)); + } - return web::json::value::array(ret); + return web::json::value::array(ret); } template <class T> -std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType ) { - web::json::value json_array = ModelBase::toJson(value); - std::shared_ptr<HttpContent> content( new HttpContent ); - content->setName( name ); - content->setContentDisposition( utility::conversions::to_string_t("form-data") ); - content->setContentType( contentType ); - content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); - return content; +std::shared_ptr<HttpContent> +ModelBase::toHttpContent(const utility::string_t &name, + const std::vector<T> &value, + const utility::string_t &contentType) { + web::json::value json_array = ModelBase::toJson(value); + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName(name); + content->setContentDisposition( + utility::conversions::to_string_t("form-data")); + content->setContentType(contentType); + content->setData(std::shared_ptr<std::istream>(new std::stringstream( + utility::conversions::to_utf8string(json_array.serialize())))); + return content; } -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp index 009c333ff06..2475bc915d3 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -20,93 +21,86 @@ namespace openapitools { namespace client { namespace model { -MultipartFormData::MultipartFormData() -{ - utility::stringstream_t uuidString; - uuidString << boost::uuids::random_generator()(); - m_Boundary = uuidString.str(); +MultipartFormData::MultipartFormData() { + utility::stringstream_t uuidString; + uuidString << boost::uuids::random_generator()(); + m_Boundary = uuidString.str(); } -MultipartFormData::MultipartFormData(const utility::string_t& boundary) - : m_Boundary(boundary) -{ +MultipartFormData::MultipartFormData(const utility::string_t &boundary) + : m_Boundary(boundary) {} -} +MultipartFormData::~MultipartFormData() {} -MultipartFormData::~MultipartFormData() -{ -} +utility::string_t MultipartFormData::getBoundary() { return m_Boundary; } -utility::string_t MultipartFormData::getBoundary() -{ - return m_Boundary; +void MultipartFormData::add(std::shared_ptr<HttpContent> content) { + m_Contents.push_back(content); + m_ContentLookup[content->getName()] = content; } -void MultipartFormData::add( std::shared_ptr<HttpContent> content ) -{ - m_Contents.push_back( content ); - m_ContentLookup[content->getName()] = content; +bool MultipartFormData::hasContent(const utility::string_t &name) const { + return m_ContentLookup.find(name) != m_ContentLookup.end(); } -bool MultipartFormData::hasContent(const utility::string_t& name) const -{ - return m_ContentLookup.find(name) != m_ContentLookup.end(); +std::shared_ptr<HttpContent> +MultipartFormData::getContent(const utility::string_t &name) const { + auto result = m_ContentLookup.find(name); + if (result == m_ContentLookup.end()) { + return std::shared_ptr<HttpContent>(nullptr); + } + return result->second; } -std::shared_ptr<HttpContent> MultipartFormData::getContent(const utility::string_t& name) const -{ - auto result = m_ContentLookup.find(name); - if(result == m_ContentLookup.end()) - { - return std::shared_ptr<HttpContent>(nullptr); +void MultipartFormData::writeTo(std::ostream &target) { + for (size_t i = 0; i < m_Contents.size(); i++) { + std::shared_ptr<HttpContent> content = m_Contents[i]; + + // boundary + target << "\r\n" + << "--" << utility::conversions::to_utf8string(m_Boundary) << "\r\n"; + + // headers + target << "Content-Disposition: " + << utility::conversions::to_utf8string( + content->getContentDisposition()); + if (content->getName().size() > 0) { + target << "; name=\"" + << utility::conversions::to_utf8string(content->getName()) << "\""; } - return result->second; -} + if (content->getFileName().size() > 0) { + target << "; filename=\"" + << utility::conversions::to_utf8string(content->getFileName()) + << "\""; + } + target << "\r\n"; -void MultipartFormData::writeTo( std::ostream& target ) -{ - for ( size_t i = 0; i < m_Contents.size(); i++ ) - { - std::shared_ptr<HttpContent> content = m_Contents[i]; - - // boundary - target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n"; - - // headers - target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() ); - if ( content->getName().size() > 0 ) - { - target << "; name=\"" << utility::conversions::to_utf8string( content->getName() ) << "\""; - } - if ( content->getFileName().size() > 0 ) - { - target << "; filename=\"" << utility::conversions::to_utf8string( content->getFileName() ) << "\""; - } - target << "\r\n"; - - if ( content->getContentType().size() > 0 ) - { - target << "Content-Type: " << utility::conversions::to_utf8string( content->getContentType() ) << "\r\n"; - } - - target << "\r\n"; - - // body - std::shared_ptr<std::istream> data = content->getData(); - - data->seekg( 0, data->end ); - std::vector<char> dataBytes( data->tellg() ); - - data->seekg( 0, data->beg ); - data->read( &dataBytes[0], dataBytes.size() ); - - std::copy( dataBytes.begin(), dataBytes.end(), std::ostreambuf_iterator<char>( target ) ); + if (content->getContentType().size() > 0) { + target << "Content-Type: " + << utility::conversions::to_utf8string(content->getContentType()) + << "\r\n"; } - target << "\r\n--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n"; -} + target << "\r\n"; + // body + std::shared_ptr<std::istream> data = content->getData(); + + data->seekg(0, data->end); + std::vector<char> dataBytes(data->tellg()); + + data->seekg(0, data->beg); + data->read(&dataBytes[0], dataBytes.size()); + + std::copy(dataBytes.begin(), dataBytes.end(), + std::ostreambuf_iterator<char>(target)); + } + + target << "\r\n--" << utility::conversions::to_utf8string(m_Boundary) + << "--\r\n"; } -} -} -} + +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/MultipartFormData.h index 50e8216f67a..2794b30a84d 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.h +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -12,51 +13,49 @@ /* * MultipartFormData.h * - * This class represents a container for building application/x-multipart-formdata requests. + * This class represents a container for building + * application/x-multipart-formdata requests. */ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ - -#include "IHttpBody.h" #include "HttpContent.h" +#include "IHttpBody.h" -#include <vector> #include <map> #include <memory> +#include <vector> #include <cpprest/details/basic_types.h> - namespace org { namespace openapitools { namespace client { namespace model { -class MultipartFormData - : public IHttpBody -{ +class MultipartFormData : public IHttpBody { public: - MultipartFormData(); - MultipartFormData(const utility::string_t& boundary); - virtual ~MultipartFormData(); + MultipartFormData(); + MultipartFormData(const utility::string_t &boundary); + virtual ~MultipartFormData(); - virtual void add( std::shared_ptr<HttpContent> content ); - virtual utility::string_t getBoundary(); - virtual std::shared_ptr<HttpContent> getContent(const utility::string_t& name) const; - virtual bool hasContent(const utility::string_t& name) const; - virtual void writeTo( std::ostream& target ); + virtual void add(std::shared_ptr<HttpContent> content); + virtual utility::string_t getBoundary(); + virtual std::shared_ptr<HttpContent> + getContent(const utility::string_t &name) const; + virtual bool hasContent(const utility::string_t &name) const; + virtual void writeTo(std::ostream &target); protected: - std::vector<std::shared_ptr<HttpContent>> m_Contents; - utility::string_t m_Boundary; - std::map<utility::string_t, std::shared_ptr<HttpContent>> m_ContentLookup; + std::vector<std::shared_ptr<HttpContent>> m_Contents; + utility::string_t m_Boundary; + std::map<utility::string_t, std::shared_ptr<HttpContent>> m_ContentLookup; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/Object.cpp b/samples/client/petstore/cpp-restsdk/Object.cpp index 4edce53d791..7b510f78274 100644 --- a/samples/client/petstore/cpp-restsdk/Object.cpp +++ b/samples/client/petstore/cpp-restsdk/Object.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -16,66 +17,55 @@ namespace openapitools { namespace client { namespace model { -Object::Object() -{ - m_object = web::json::value::object(); -} +Object::Object() { m_object = web::json::value::object(); } -Object::~Object() -{ -} +Object::~Object() {} -void Object::validate() -{ - // TODO: implement validation +void Object::validate() { + // TODO: implement validation } -web::json::value Object::toJson() const -{ - return m_object; -} +web::json::value Object::toJson() const { return m_object; } -void Object::fromJson(const web::json::value& val) -{ - if (val.is_object()) - { - m_object = val; - } +void Object::fromJson(const web::json::value &val) { + if (val.is_object()) { + m_object = val; + } } -void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object)); +void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("object"), m_object)); } -void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } - m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object"))); + m_object = ModelBase::valueFromHttpContent(multipart->getContent( + namePrefix + utility::conversions::to_string_t("object"))); } -web::json::value Object::getValue(const utility::string_t& key) const -{ - return m_object.at(key); +web::json::value Object::getValue(const utility::string_t &key) const { + return m_object.at(key); } - -void Object::setValue(const utility::string_t& key, const web::json::value& value) -{ - m_object[key] = value; +void Object::setValue(const utility::string_t &key, + const web::json::value &value) { + m_object[key] = value; } -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/Object.h b/samples/client/petstore/cpp-restsdk/Object.h index 1944f397bda..b2c848a955a 100644 --- a/samples/client/petstore/cpp-restsdk/Object.h +++ b/samples/client/petstore/cpp-restsdk/Object.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ - #include "ModelBase.h" #include <cpprest/details/basic_types.h> @@ -29,34 +29,35 @@ namespace openapitools { namespace client { namespace model { -class Object : public ModelBase -{ +class Object : public ModelBase { public: - Object(); - virtual ~Object(); + Object(); + virtual ~Object(); - ///////////////////////////////////////////// - /// ModelBase overrides - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides + void validate() override; - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - ///////////////////////////////////////////// - /// Object manipulation - web::json::value getValue(const utility::string_t& key) const; - void setValue(const utility::string_t& key, const web::json::value& value); + ///////////////////////////////////////////// + /// Object manipulation + web::json::value getValue(const utility::string_t &key) const; + void setValue(const utility::string_t &key, const web::json::value &value); private: - web::json::value m_object; + web::json::value m_object; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index 63c11ca9b44..e1520d312ae 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,7 +10,6 @@ * Do not edit the class manually. */ - #include "PetApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,963 +26,1178 @@ namespace api { using namespace org::openapitools::client::model; -PetApi::PetApi( std::shared_ptr<ApiClient> apiClient ) - : m_ApiClient(apiClient) -{ -} - -PetApi::~PetApi() -{ -} - -pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> pet) -{ - - // verify the required parameter 'pet' is set - if (pet == nullptr) - { - throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->addPet")); - } - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->addPet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(pet); - - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if(pet.get()) - { - pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->addPet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +PetApi::PetApi(std::shared_ptr<ApiClient> apiClient) : m_ApiClient(apiClient) {} + +PetApi::~PetApi() {} + +pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> pet) { + + // verify the required parameter 'pet' is set + if (pet == nullptr) { + throw ApiException( + 400, + utility::conversions::to_string_t( + "Missing required parameter 'pet' when calling PetApi->addPet")); + } + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, utility::conversions::to_string_t( + "PetApi->addPet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if (pet.get()) { + pet->toMultipart(localVarMultipart, + utility::conversions::to_string_t("pet")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException( + 415, utility::conversions::to_string_t( + "PetApi->addPet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling addPet: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling addPet: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling addPet: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling addPet: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> PetApi::deletePet(int64_t petId, boost::optional<utility::string_t> apiKey) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->deletePet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - if (apiKey) - { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = ApiClient::parameterToString(*apiKey); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->deletePet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<void> PetApi::deletePet(int64_t petId, + boost::optional<utility::string_t> apiKey) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("petId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "PetApi->deletePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + if (apiKey) { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = + ApiClient::parameterToString(*apiKey); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "PetApi->deletePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling deletePet: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling deletePet: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling deletePet: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling deletePet: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vector<utility::string_t> status) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByStatus"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByStatus does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("status")] = ApiClient::parameterToString(status); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByStatus does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::vector<std::shared_ptr<Pet>>> +PetApi::findPetsByStatus(std::vector<utility::string_t> status) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/findByStatus"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "PetApi->findPetsByStatus does not produce any " + "supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("status")] = + ApiClient::parameterToString(status); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "PetApi->findPetsByStatus does not consume any " + "supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling findPetsByStatus: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling findPetsByStatus: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByStatus: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling findPetsByStatus: unexpected response " + "type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::vector<std::shared_ptr<Pet>> localVarResult; - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); - - for( auto& localVarItem : localVarJson.as_array() ) - { - std::shared_ptr<Pet> localVarItemObj(new Pet()); - localVarItemObj->fromJson(localVarItem); - localVarResult.push_back(localVarItemObj); - - } - + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); + + for (auto &localVarItem : localVarJson.as_array()) { + std::shared_ptr<Pet> localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); + } + } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByStatus: unsupported response type")); + else { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling findPetsByStatus: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector<utility::string_t> tags) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByTags"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByTags does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("tags")] = ApiClient::parameterToString(tags); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByTags does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::vector<std::shared_ptr<Pet>>> +PetApi::findPetsByTags(std::vector<utility::string_t> tags) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/findByTags"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "PetApi->findPetsByTags does not produce any " + "supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("tags")] = + ApiClient::parameterToString(tags); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "PetApi->findPetsByTags does not consume any " + "supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling findPetsByTags: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling findPetsByTags: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByTags: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling findPetsByTags: unexpected response " + "type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::vector<std::shared_ptr<Pet>> localVarResult; - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); - - for( auto& localVarItem : localVarJson.as_array() ) - { - std::shared_ptr<Pet> localVarItemObj(new Pet()); - localVarItemObj->fromJson(localVarItem); - localVarResult.push_back(localVarItemObj); - - } - + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); + + for (auto &localVarItem : localVarJson.as_array()) { + std::shared_ptr<Pet> localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); + } + } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByTags: unsupported response type")); + else { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling findPetsByTags: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->getPetById does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->getPetById does not consume any supported media type")); - } - - // authentication (api_key) required - { - utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); - if ( localVarApiKey.size() > 0 ) - { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; - } - } - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("petId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "PetApi->getPetById does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "PetApi->getPetById does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey( + utility::conversions::to_string_t("api_key")); + if (localVarApiKey.size() > 0) { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = + localVarApiKey; + } + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling getPetById: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling getPetById: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getPetById: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getPetById: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::shared_ptr<Pet> localVarResult(new Pet()); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getPetById: unsupported response type")); + else { + throw ApiException( + 500, utility::conversions::to_string_t( + "error calling getPetById: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> pet) -{ - - // verify the required parameter 'pet' is set - if (pet == nullptr) - { - throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->updatePet")); - } - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(pet); - - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if(pet.get()) - { - pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> pet) { + + // verify the required parameter 'pet' is set + if (pet == nullptr) { + throw ApiException( + 400, + utility::conversions::to_string_t( + "Missing required parameter 'pet' when calling PetApi->updatePet")); + } + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "PetApi->updatePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if (pet.get()) { + pet->toMultipart(localVarMultipart, + utility::conversions::to_string_t("pet")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "PetApi->updatePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("PUT"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling updatePet: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling updatePet: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling updatePet: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling updatePet: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> PetApi::updatePetWithForm(int64_t petId, boost::optional<utility::string_t> name, boost::optional<utility::string_t> status) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePetWithForm does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/x-www-form-urlencoded") ); - - if (name) - { - localVarFormParams[ utility::conversions::to_string_t("name") ] = ApiClient::parameterToString(*name); - } - if (status) - { - localVarFormParams[ utility::conversions::to_string_t("status") ] = ApiClient::parameterToString(*status); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePetWithForm does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<void> +PetApi::updatePetWithForm(int64_t petId, + boost::optional<utility::string_t> name, + boost::optional<utility::string_t> status) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("petId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "PetApi->updatePetWithForm does not produce " + "any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("application/x-www-form-urlencoded")); + + if (name) { + localVarFormParams[utility::conversions::to_string_t("name")] = + ApiClient::parameterToString(*name); + } + if (status) { + localVarFormParams[utility::conversions::to_string_t("status")] = + ApiClient::parameterToString(*status); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "PetApi->updatePetWithForm does not consume " + "any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling updatePetWithForm: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling updatePetWithForm: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling updatePetWithForm: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling updatePetWithForm: unexpected response " + "type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, boost::optional<utility::string_t> additionalMetadata, boost::optional<std::shared_ptr<HttpContent>> file) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}/uploadImage"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("PetApi->uploadFile does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") ); - - if (additionalMetadata) - { - localVarFormParams[ utility::conversions::to_string_t("additionalMetadata") ] = ApiClient::parameterToString(*additionalMetadata); - } - if (file && *file != nullptr) - { - localVarFileParams[ utility::conversions::to_string_t("file") ] = *file; - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("PetApi->uploadFile does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the http_client_config - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::shared_ptr<ApiResponse>> +PetApi::uploadFile(int64_t petId, + boost::optional<utility::string_t> additionalMetadata, + boost::optional<std::shared_ptr<HttpContent>> file) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/pet/{petId}/uploadImage"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("petId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "PetApi->uploadFile does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( + utility::conversions::to_string_t("multipart/form-data")); + + if (additionalMetadata) { + localVarFormParams[utility::conversions::to_string_t( + "additionalMetadata")] = + ApiClient::parameterToString(*additionalMetadata); + } + if (file && *file != nullptr) { + localVarFileParams[utility::conversions::to_string_t("file")] = *file; + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "PetApi->uploadFile does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the + // http_client_config + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling uploadFile: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling uploadFile: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling uploadFile: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling uploadFile: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::shared_ptr<ApiResponse> localVarResult(new ApiResponse()); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling uploadFile: unsupported response type")); + else { + throw ApiException( + 500, utility::conversions::to_string_t( + "error calling uploadFile: unsupported response type")); } return localVarResult; - }); -} - -} -} -} + }); } +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h index 81662ef543a..0e275040639 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.h +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -12,13 +13,12 @@ /* * PetApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ - #include "../ApiClient.h" #include "ApiResponse.h" @@ -26,7 +26,6 @@ #include "Pet.h" #include <cpprest/details/basic_types.h> - #include <boost/optional.hpp> namespace org { @@ -36,115 +35,105 @@ namespace api { using namespace org::openapitools::client::model; - - -class PetApi -{ +class PetApi { public: - - explicit PetApi( std::shared_ptr<ApiClient> apiClient ); - - virtual ~PetApi(); - - /// <summary> - /// Add a new pet to the store - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="pet">Pet object that needs to be added to the store</param> - pplx::task<void> addPet( - std::shared_ptr<Pet> pet - ); - /// <summary> - /// Deletes a pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional, default to utility::conversions::to_string_t(""))</param> - pplx::task<void> deletePet( - int64_t petId, - boost::optional<utility::string_t> apiKey - ); - /// <summary> - /// Finds Pets by status - /// </summary> - /// <remarks> - /// Multiple status values can be provided with comma separated strings - /// </remarks> - /// <param name="status">Status values that need to be considered for filter</param> - pplx::task<std::vector<std::shared_ptr<Pet>>> findPetsByStatus( - std::vector<utility::string_t> status - ); - /// <summary> - /// Finds Pets by tags - /// </summary> - /// <remarks> - /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - /// </remarks> - /// <param name="tags">Tags to filter by</param> - pplx::task<std::vector<std::shared_ptr<Pet>>> findPetsByTags( - std::vector<utility::string_t> tags - ); - /// <summary> - /// Find pet by ID - /// </summary> - /// <remarks> - /// Returns a single pet - /// </remarks> - /// <param name="petId">ID of pet to return</param> - pplx::task<std::shared_ptr<Pet>> getPetById( - int64_t petId - ); - /// <summary> - /// Update an existing pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="pet">Pet object that needs to be added to the store</param> - pplx::task<void> updatePet( - std::shared_ptr<Pet> pet - ); - /// <summary> - /// Updates a pet in the store with form data - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">ID of pet that needs to be updated</param> - /// <param name="name">Updated name of the pet (optional, default to utility::conversions::to_string_t(""))</param> - /// <param name="status">Updated status of the pet (optional, default to utility::conversions::to_string_t(""))</param> - pplx::task<void> updatePetWithForm( - int64_t petId, - boost::optional<utility::string_t> name, - boost::optional<utility::string_t> status - ); - /// <summary> - /// uploads an image - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">ID of pet to update</param> - /// <param name="additionalMetadata">Additional data to pass to server (optional, default to utility::conversions::to_string_t(""))</param> - /// <param name="file">file to upload (optional, default to utility::conversions::to_string_t(""))</param> - pplx::task<std::shared_ptr<ApiResponse>> uploadFile( - int64_t petId, - boost::optional<utility::string_t> additionalMetadata, - boost::optional<std::shared_ptr<HttpContent>> file - ); + explicit PetApi(std::shared_ptr<ApiClient> apiClient); + + virtual ~PetApi(); + + /// <summary> + /// Add a new pet to the store + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="pet">Pet object that needs to be added to the store</param> + pplx::task<void> addPet(std::shared_ptr<Pet> pet); + /// <summary> + /// Deletes a pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">Pet id to delete</param> + /// <param name="apiKey"> (optional, default to + /// utility::conversions::to_string_t(""))</param> + pplx::task<void> deletePet(int64_t petId, + boost::optional<utility::string_t> apiKey); + /// <summary> + /// Finds Pets by status + /// </summary> + /// <remarks> + /// Multiple status values can be provided with comma separated strings + /// </remarks> + /// <param name="status">Status values that need to be considered for + /// filter</param> + pplx::task<std::vector<std::shared_ptr<Pet>>> + findPetsByStatus(std::vector<utility::string_t> status); + /// <summary> + /// Finds Pets by tags + /// </summary> + /// <remarks> + /// Multiple tags can be provided with comma separated strings. Use tag1, + /// tag2, tag3 for testing. + /// </remarks> + /// <param name="tags">Tags to filter by</param> + pplx::task<std::vector<std::shared_ptr<Pet>>> + findPetsByTags(std::vector<utility::string_t> tags); + /// <summary> + /// Find pet by ID + /// </summary> + /// <remarks> + /// Returns a single pet + /// </remarks> + /// <param name="petId">ID of pet to return</param> + pplx::task<std::shared_ptr<Pet>> getPetById(int64_t petId); + /// <summary> + /// Update an existing pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="pet">Pet object that needs to be added to the store</param> + pplx::task<void> updatePet(std::shared_ptr<Pet> pet); + /// <summary> + /// Updates a pet in the store with form data + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">ID of pet that needs to be updated</param> + /// <param name="name">Updated name of the pet (optional, default to + /// utility::conversions::to_string_t(""))</param> <param + /// name="status">Updated status of the pet (optional, default to + /// utility::conversions::to_string_t(""))</param> + pplx::task<void> updatePetWithForm(int64_t petId, + boost::optional<utility::string_t> name, + boost::optional<utility::string_t> status); + /// <summary> + /// uploads an image + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">ID of pet to update</param> + /// <param name="additionalMetadata">Additional data to pass to server + /// (optional, default to + /// utility::conversions::to_string_t(""))</param> <param + /// name="file">file to upload (optional, default to + /// utility::conversions::to_string_t(""))</param> + pplx::task<std::shared_ptr<ApiResponse>> + uploadFile(int64_t petId, + boost::optional<utility::string_t> additionalMetadata, + boost::optional<std::shared_ptr<HttpContent>> file); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ */ - diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index 36f501f54b6..0687e1ac70c 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,7 +10,6 @@ * Do not edit the class manually. */ - #include "StoreApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,489 +26,585 @@ namespace api { using namespace org::openapitools::client::model; -StoreApi::StoreApi( std::shared_ptr<ApiClient> apiClient ) - : m_ApiClient(apiClient) -{ -} - -StoreApi::~StoreApi() -{ -} - -pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("StoreApi->deleteOrder does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("StoreApi->deleteOrder does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +StoreApi::StoreApi(std::shared_ptr<ApiClient> apiClient) + : m_ApiClient(apiClient) {} + +StoreApi::~StoreApi() {} + +pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("orderId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(orderId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "StoreApi->deleteOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "StoreApi->deleteOrder does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling deleteOrder: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling deleteOrder: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling deleteOrder: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling deleteOrder: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/store/inventory"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); +pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/store/inventory"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "StoreApi->getInventory does not produce any " + "supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "StoreApi->getInventory does not consume any " + "supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey( + utility::conversions::to_string_t("api_key")); + if (localVarApiKey.size() > 0) { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = + localVarApiKey; } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("StoreApi->getInventory does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("StoreApi->getInventory does not consume any supported media type")); - } - - // authentication (api_key) required - { - utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); - if ( localVarApiKey.size() > 0 ) - { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; - } - } - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling getInventory: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling getInventory: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getInventory: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getInventory: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::map<utility::string_t, int32_t> localVarResult; - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); + + for (auto &localVarItem : localVarJson.as_object()) { + localVarResult[localVarItem.first] = + ModelBase::int32_tFromJson(localVarItem.second); + } - for( auto& localVarItem : localVarJson.as_object() ) - { - localVarResult[localVarItem.first] = ModelBase::int32_tFromJson(localVarItem.second); - - } - } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getInventory: unsupported response type")); + else { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getInventory: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("StoreApi->getOrderById does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("StoreApi->getOrderById does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("orderId") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(orderId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "StoreApi->getOrderById does not produce any " + "supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "StoreApi->getOrderById does not consume any " + "supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling getOrderById: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling getOrderById: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getOrderById: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getOrderById: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::shared_ptr<Order> localVarResult(new Order()); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getOrderById: unsupported response type")); + else { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getOrderById: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> order) -{ - - // verify the required parameter 'order' is set - if (order == nullptr) - { - throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'order' when calling StoreApi->placeOrder")); +pplx::task<std::shared_ptr<Order>> +StoreApi::placeOrder(std::shared_ptr<Order> order) { + + // verify the required parameter 'order' is set + if (order == nullptr) { + throw ApiException(400, utility::conversions::to_string_t( + "Missing required parameter 'order' when " + "calling StoreApi->placeOrder")); + } + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/store/order"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "StoreApi->placeOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(order); + + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if (order.get()) { + order->toMultipart(localVarMultipart, + utility::conversions::to_string_t("order")); } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/store/order"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("StoreApi->placeOrder does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(order); - - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if(order.get()) - { - order->toMultipart(localVarMultipart, utility::conversions::to_string_t("order")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("StoreApi->placeOrder does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "StoreApi->placeOrder does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling placeOrder: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling placeOrder: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling placeOrder: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling placeOrder: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::shared_ptr<Order> localVarResult(new Order()); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling placeOrder: unsupported response type")); + else { + throw ApiException( + 500, utility::conversions::to_string_t( + "error calling placeOrder: unsupported response type")); } return localVarResult; - }); -} - -} -} -} + }); } +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h index 1c609872c38..c51d2eb13ec 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -12,19 +13,17 @@ /* * StoreApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ - #include "../ApiClient.h" #include "Order.h" -#include <map> #include <cpprest/details/basic_types.h> - +#include <map> #include <boost/optional.hpp> @@ -35,63 +34,53 @@ namespace api { using namespace org::openapitools::client::model; - - -class StoreApi -{ +class StoreApi { public: - - explicit StoreApi( std::shared_ptr<ApiClient> apiClient ); - - virtual ~StoreApi(); - - /// <summary> - /// Delete purchase order by ID - /// </summary> - /// <remarks> - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// </remarks> - /// <param name="orderId">ID of the order that needs to be deleted</param> - pplx::task<void> deleteOrder( - utility::string_t orderId - ); - /// <summary> - /// Returns pet inventories by status - /// </summary> - /// <remarks> - /// Returns a map of status codes to quantities - /// </remarks> - pplx::task<std::map<utility::string_t, int32_t>> getInventory( - ); - /// <summary> - /// Find purchase order by ID - /// </summary> - /// <remarks> - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// </remarks> - /// <param name="orderId">ID of pet that needs to be fetched</param> - pplx::task<std::shared_ptr<Order>> getOrderById( - int64_t orderId - ); - /// <summary> - /// Place an order for a pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="order">order placed for purchasing the pet</param> - pplx::task<std::shared_ptr<Order>> placeOrder( - std::shared_ptr<Order> order - ); + explicit StoreApi(std::shared_ptr<ApiClient> apiClient); + + virtual ~StoreApi(); + + /// <summary> + /// Delete purchase order by ID + /// </summary> + /// <remarks> + /// For valid response try integer IDs with value < 1000. Anything above + /// 1000 or nonintegers will generate API errors + /// </remarks> + /// <param name="orderId">ID of the order that needs to be deleted</param> + pplx::task<void> deleteOrder(utility::string_t orderId); + /// <summary> + /// Returns pet inventories by status + /// </summary> + /// <remarks> + /// Returns a map of status codes to quantities + /// </remarks> + pplx::task<std::map<utility::string_t, int32_t>> getInventory(); + /// <summary> + /// Find purchase order by ID + /// </summary> + /// <remarks> + /// For valid response try integer IDs with value <= 5 or > 10. + /// Other values will generated exceptions + /// </remarks> + /// <param name="orderId">ID of pet that needs to be fetched</param> + pplx::task<std::shared_ptr<Order>> getOrderById(int64_t orderId); + /// <summary> + /// Place an order for a pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="order">order placed for purchasing the pet</param> + pplx::task<std::shared_ptr<Order>> placeOrder(std::shared_ptr<Order> order); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ */ - diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index d62ba153544..fa70d0247e3 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,7 +10,6 @@ * Do not edit the class manually. */ - #include "UserApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,923 +26,1108 @@ namespace api { using namespace org::openapitools::client::model; -UserApi::UserApi( std::shared_ptr<ApiClient> apiClient ) - : m_ApiClient(apiClient) -{ -} - -UserApi::~UserApi() -{ -} - -pplx::task<void> UserApi::createUser(std::shared_ptr<User> user) -{ - - // verify the required parameter 'user' is set - if (user == nullptr) - { - throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->createUser")); - } - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(user); - - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if(user.get()) - { - user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type")); +UserApi::UserApi(std::shared_ptr<ApiClient> apiClient) + : m_ApiClient(apiClient) {} + +UserApi::~UserApi() {} + +pplx::task<void> UserApi::createUser(std::shared_ptr<User> user) { + + // verify the required parameter 'user' is set + if (user == nullptr) { + throw ApiException(400, utility::conversions::to_string_t( + "Missing required parameter 'user' when " + "calling UserApi->createUser")); + } + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = utility::conversions::to_string_t("/user"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "UserApi->createUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if (user.get()) { + user->toMultipart(localVarMultipart, + utility::conversions::to_string_t("user")); } - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "UserApi->createUser does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling createUser: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling createUser: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling createUser: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type")); +pplx::task<void> +UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/createWithArray"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "UserApi->createUsersWithArrayInput does not " + "produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector<web::json::value> localVarJsonArray; + for (auto &localVarItem : user) { + localVarJsonArray.push_back(localVarItem.get() + ? localVarItem->toJson() + : web::json::value::null()); + } + localVarJson = web::json::value::array(localVarJsonArray); } - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - { - std::vector<web::json::value> localVarJsonArray; - for( auto& localVarItem : user ) - { - localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); - - } - localVarJson = web::json::value::array(localVarJsonArray); - } - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - { - std::vector<web::json::value> localVarJsonArray; - for( auto& localVarItem : user ) - { - localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); - - } - localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type")); + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + { + std::vector<web::json::value> localVarJsonArray; + for (auto &localVarItem : user) { + localVarJsonArray.push_back(localVarItem.get() + ? localVarItem->toJson() + : web::json::value::null()); + } + localVarMultipart->add(ModelBase::toHttpContent( + utility::conversions::to_string_t("user"), + web::json::value::array(localVarJsonArray), + utility::conversions::to_string_t("application/json"))); } - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "UserApi->createUsersWithArrayInput does not " + "consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling createUsersWithArrayInput: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling createUsersWithArrayInput: unexpected " + "response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<User>> user) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type")); +pplx::task<void> +UserApi::createUsersWithListInput(std::vector<std::shared_ptr<User>> user) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/createWithList"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "UserApi->createUsersWithListInput does not " + "produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector<web::json::value> localVarJsonArray; + for (auto &localVarItem : user) { + localVarJsonArray.push_back(localVarItem.get() + ? localVarItem->toJson() + : web::json::value::null()); + } + localVarJson = web::json::value::array(localVarJsonArray); } - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - { - std::vector<web::json::value> localVarJsonArray; - for( auto& localVarItem : user ) - { - localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); - - } - localVarJson = web::json::value::array(localVarJsonArray); - } - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - { - std::vector<web::json::value> localVarJsonArray; - for( auto& localVarItem : user ) - { - localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); - - } - localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type")); + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + { + std::vector<web::json::value> localVarJsonArray; + for (auto &localVarItem : user) { + localVarJsonArray.push_back(localVarItem.get() + ? localVarItem->toJson() + : web::json::value::null()); + } + localVarMultipart->add(ModelBase::toHttpContent( + utility::conversions::to_string_t("user"), + web::json::value::array(localVarJsonArray), + utility::conversions::to_string_t("application/json"))); } - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "UserApi->createUsersWithListInput does not " + "consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("POST"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling createUsersWithListInput: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling createUsersWithListInput: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling createUsersWithListInput: unexpected " + "response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> UserApi::deleteUser(utility::string_t username) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<void> UserApi::deleteUser(utility::string_t username) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("username") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "UserApi->deleteUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "UserApi->deleteUser does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling deleteUser: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling deleteUser: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling deleteUser: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t username) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<std::shared_ptr<User>> +UserApi::getUserByName(utility::string_t username) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("username") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(400, utility::conversions::to_string_t( + "UserApi->getUserByName does not produce any " + "supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException(415, utility::conversions::to_string_t( + "UserApi->getUserByName does not consume any " + "supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling getUserByName: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t( + "error calling getUserByName: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getUserByName: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { std::shared_ptr<User> localVarResult(new User()); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling getUserByName: unsupported response type")); + else { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling getUserByName: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, utility::string_t password) -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/login"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - // plain text - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); - } - { - localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, + utility::string_t password) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/login"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/xml")); + localVarResponseHttpContentTypes.insert( + utility::conversions::to_string_t("application/json")); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("text/plain"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } + // plain text + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("text/plain")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("text/plain"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "UserApi->loginUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("username")] = + ApiClient::parameterToString(username); + } + { + localVarQueryParams[utility::conversions::to_string_t("password")] = + ApiClient::parameterToString(password); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "UserApi->loginUser does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling loginUser: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling loginUser: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling loginUser: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { + }) + .then([=](utility::string_t localVarResponse) { utility::string_t localVarResult(utility::conversions::to_string_t("")); - if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) - { - web::json::value localVarJson = web::json::value::parse(localVarResponse); + if (localVarResponseHttpContentType == + utility::conversions::to_string_t("application/json")) { + web::json::value localVarJson = + web::json::value::parse(localVarResponse); - localVarResult = ModelBase::stringFromJson(localVarJson); - - } - else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain")) - { - localVarResult = localVarResponse; + localVarResult = ModelBase::stringFromJson(localVarJson); + + } else if (localVarResponseHttpContentType == + utility::conversions::to_string_t("text/plain")) { + localVarResult = localVarResponse; } - // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == + // utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling loginUser: unsupported response type")); + else { + throw ApiException( + 500, utility::conversions::to_string_t( + "error calling loginUser: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<void> UserApi::logoutUser() -{ - - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { +pplx::task<void> UserApi::logoutUser() { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/logout"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "UserApi->logoutUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "UserApi->logoutUser does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("GET"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling logoutUser: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling logoutUser: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling logoutUser: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } -pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr<User> user) -{ - - // verify the required parameter 'user' is set - if (user == nullptr) - { - throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->updateUser")); +pplx::task<void> UserApi::updateUser(utility::string_t username, + std::shared_ptr<User> user) { + + // verify the required parameter 'user' is set + if (user == nullptr) { + throw ApiException(400, utility::conversions::to_string_t( + "Missing required parameter 'user' when " + "calling UserApi->updateUser")); + } + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( + m_ApiClient->getConfiguration()); + utility::string_t localVarPath = + utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, + utility::conversions::to_string_t("{") + + utility::conversions::to_string_t("username") + + utility::conversions::to_string_t("}"), + ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( + localVarApiConfiguration->getDefaultHeaders()); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if (localVarResponseHttpContentTypes.size() == 0) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // JSON + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("application/json")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if (localVarResponseHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarResponseHttpContentTypes.end()) { + localVarResponseHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + } else { + throw ApiException( + 400, + utility::conversions::to_string_t( + "UserApi->updateUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = + localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if (localVarConsumeHttpContentTypes.size() == 0 || + localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( + "application/json")) != localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); + } + // multipart formdata + else if (localVarConsumeHttpContentTypes.find( + utility::conversions::to_string_t("multipart/form-data")) != + localVarConsumeHttpContentTypes.end()) { + localVarRequestHttpContentType = + utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if (user.get()) { + user->toMultipart(localVarMultipart, + utility::conversions::to_string_t("user")); } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if ( localVarResponseHttpContentTypes.size() == 0 ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // JSON - else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) - { - localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - } - else - { - throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(user); - - - localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); - } - // multipart formdata - else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) - { - localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if(user.get()) - { - user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); - } - else - { - throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type")); - } - - - return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) - { + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += + utility::conversions::to_string_t("; boundary=") + + localVarMultipart->getBoundary(); + } else { + throw ApiException( + 415, + utility::conversions::to_string_t( + "UserApi->updateUser does not consume any supported media type")); + } + + return m_ApiClient + ->callApi(localVarPath, utility::conversions::to_string_t("PUT"), + localVarQueryParams, localVarHttpBody, localVarHeaderParams, + localVarFormParams, localVarFileParams, + localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) - { - throw ApiException(localVarResponse.status_code() - , utility::conversions::to_string_t("error calling updateUser: ") + localVarResponse.reason_phrase() - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) { + throw ApiException( + localVarResponse.status_code(), + utility::conversions::to_string_t("error calling updateUser: ") + + localVarResponse.reason_phrase(), + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); } // check response content type - if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) - { - utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; - if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) - { - throw ApiException(500 - , utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + localVarContentType - , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); - } + if (localVarResponse.headers().has( + utility::conversions::to_string_t("Content-Type"))) { + utility::string_t localVarContentType = + localVarResponse + .headers()[utility::conversions::to_string_t("Content-Type")]; + if (localVarContentType.find(localVarResponseHttpContentType) == + std::string::npos) { + throw ApiException( + 500, + utility::conversions::to_string_t( + "error calling updateUser: unexpected response type: ") + + localVarContentType, + std::make_shared<std::stringstream>( + localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) - { - return void(); - }); -} - -} -} -} + }) + .then([=](utility::string_t localVarResponse) { return void(); }); } +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.h b/samples/client/petstore/cpp-restsdk/api/UserApi.h index 3f5ef26bd18..19e763b31ca 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.h +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -12,19 +13,17 @@ /* * UserApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ - #include "../ApiClient.h" #include "User.h" -#include <vector> #include <cpprest/details/basic_types.h> - +#include <vector> #include <boost/optional.hpp> @@ -35,107 +34,90 @@ namespace api { using namespace org::openapitools::client::model; - - -class UserApi -{ +class UserApi { public: - - explicit UserApi( std::shared_ptr<ApiClient> apiClient ); - - virtual ~UserApi(); - - /// <summary> - /// Create user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="user">Created user object</param> - pplx::task<void> createUser( - std::shared_ptr<User> user - ); - /// <summary> - /// Creates list of users with given input array - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="user">List of user object</param> - pplx::task<void> createUsersWithArrayInput( - std::vector<std::shared_ptr<User>> user - ); - /// <summary> - /// Creates list of users with given input array - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="user">List of user object</param> - pplx::task<void> createUsersWithListInput( - std::vector<std::shared_ptr<User>> user - ); - /// <summary> - /// Delete user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="username">The name that needs to be deleted</param> - pplx::task<void> deleteUser( - utility::string_t username - ); - /// <summary> - /// Get user by user name - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="username">The name that needs to be fetched. Use user1 for testing.</param> - pplx::task<std::shared_ptr<User>> getUserByName( - utility::string_t username - ); - /// <summary> - /// Logs user into the system - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="username">The user name for login</param> - /// <param name="password">The password for login in clear text</param> - pplx::task<utility::string_t> loginUser( - utility::string_t username, - utility::string_t password - ); - /// <summary> - /// Logs out current logged in user session - /// </summary> - /// <remarks> - /// - /// </remarks> - pplx::task<void> logoutUser( - ); - /// <summary> - /// Updated user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="username">name that need to be deleted</param> - /// <param name="user">Updated user object</param> - pplx::task<void> updateUser( - utility::string_t username, - std::shared_ptr<User> user - ); + explicit UserApi(std::shared_ptr<ApiClient> apiClient); + + virtual ~UserApi(); + + /// <summary> + /// Create user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="user">Created user object</param> + pplx::task<void> createUser(std::shared_ptr<User> user); + /// <summary> + /// Creates list of users with given input array + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="user">List of user object</param> + pplx::task<void> + createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user); + /// <summary> + /// Creates list of users with given input array + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="user">List of user object</param> + pplx::task<void> + createUsersWithListInput(std::vector<std::shared_ptr<User>> user); + /// <summary> + /// Delete user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="username">The name that needs to be deleted</param> + pplx::task<void> deleteUser(utility::string_t username); + /// <summary> + /// Get user by user name + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="username">The name that needs to be fetched. Use user1 for + /// testing.</param> + pplx::task<std::shared_ptr<User>> getUserByName(utility::string_t username); + /// <summary> + /// Logs user into the system + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="username">The user name for login</param> + /// <param name="password">The password for login in clear text</param> + pplx::task<utility::string_t> loginUser(utility::string_t username, + utility::string_t password); + /// <summary> + /// Logs out current logged in user session + /// </summary> + /// <remarks> + /// + /// </remarks> + pplx::task<void> logoutUser(); + /// <summary> + /// Updated user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="username">name that need to be deleted</param> + /// <param name="user">Updated user object</param> + pplx::task<void> updateUser(utility::string_t username, + std::shared_ptr<User> user); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} -} -} -} +} // namespace api +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ */ - diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp index 2ed8acfaced..5a3c672cb9e 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "ApiResponse.h" namespace org { @@ -18,182 +17,140 @@ namespace openapitools { namespace client { namespace model { -ApiResponse::ApiResponse() -{ - m_Code = 0; - m_CodeIsSet = false; - m_Type = utility::conversions::to_string_t(""); - m_TypeIsSet = false; - m_Message = utility::conversions::to_string_t(""); - m_MessageIsSet = false; +ApiResponse::ApiResponse() { + m_Code = 0; + m_CodeIsSet = false; + m_Type = utility::conversions::to_string_t(""); + m_TypeIsSet = false; + m_Message = utility::conversions::to_string_t(""); + m_MessageIsSet = false; } -ApiResponse::~ApiResponse() -{ -} +ApiResponse::~ApiResponse() {} -void ApiResponse::validate() -{ - // TODO: implement validation +void ApiResponse::validate() { + // TODO: implement validation } -web::json::value ApiResponse::toJson() const -{ - web::json::value val = web::json::value::object(); +web::json::value ApiResponse::toJson() const { + web::json::value val = web::json::value::object(); - if(m_CodeIsSet) - { - val[utility::conversions::to_string_t("code")] = ModelBase::toJson(m_Code); - } - if(m_TypeIsSet) - { - val[utility::conversions::to_string_t("type")] = ModelBase::toJson(m_Type); - } - if(m_MessageIsSet) - { - val[utility::conversions::to_string_t("message")] = ModelBase::toJson(m_Message); - } + if (m_CodeIsSet) { + val[utility::conversions::to_string_t("code")] = ModelBase::toJson(m_Code); + } + if (m_TypeIsSet) { + val[utility::conversions::to_string_t("type")] = ModelBase::toJson(m_Type); + } + if (m_MessageIsSet) { + val[utility::conversions::to_string_t("message")] = + ModelBase::toJson(m_Message); + } - return val; + return val; } -void ApiResponse::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("code"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("code")); - if(!fieldValue.is_null()) - { - setCode(ModelBase::int32_tFromJson(fieldValue)); - } +void ApiResponse::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("code"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("code")); + if (!fieldValue.is_null()) { + setCode(ModelBase::int32_tFromJson(fieldValue)); } - if(val.has_field(utility::conversions::to_string_t("type"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type")); - if(!fieldValue.is_null()) - { - setType(ModelBase::stringFromJson(fieldValue)); - } + } + if (val.has_field(utility::conversions::to_string_t("type"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("type")); + if (!fieldValue.is_null()) { + setType(ModelBase::stringFromJson(fieldValue)); } - if(val.has_field(utility::conversions::to_string_t("message"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("message")); - if(!fieldValue.is_null()) - { - setMessage(ModelBase::stringFromJson(fieldValue)); - } + } + if (val.has_field(utility::conversions::to_string_t("message"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("message")); + if (!fieldValue.is_null()) { + setMessage(ModelBase::stringFromJson(fieldValue)); } + } } -void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } - if(m_CodeIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("code"), m_Code)); - } - if(m_TypeIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("type"), m_Type)); - } - if(m_MessageIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("message"), m_Message)); - } + if (m_CodeIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("code"), m_Code)); + } + if (m_TypeIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("type"), m_Type)); + } + if (m_MessageIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("message"), m_Message)); + } } -void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(multipart->hasContent(utility::conversions::to_string_t("code"))) - { - setCode(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("code")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("type"))) - { - setType(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("type")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("message"))) - { - setMessage(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("message")))); - } -} +void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } -int32_t ApiResponse::getCode() const -{ - return m_Code; + if (multipart->hasContent(utility::conversions::to_string_t("code"))) { + setCode(ModelBase::int32_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("code")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("type"))) { + setType(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("type")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("message"))) { + setMessage(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("message")))); + } } -void ApiResponse::setCode(int32_t value) -{ - m_Code = value; - m_CodeIsSet = true; -} +int32_t ApiResponse::getCode() const { return m_Code; } -bool ApiResponse::codeIsSet() const -{ - return m_CodeIsSet; +void ApiResponse::setCode(int32_t value) { + m_Code = value; + m_CodeIsSet = true; } -void ApiResponse::unsetCode() -{ - m_CodeIsSet = false; -} +bool ApiResponse::codeIsSet() const { return m_CodeIsSet; } -utility::string_t ApiResponse::getType() const -{ - return m_Type; -} +void ApiResponse::unsetCode() { m_CodeIsSet = false; } -void ApiResponse::setType(const utility::string_t& value) -{ - m_Type = value; - m_TypeIsSet = true; -} +utility::string_t ApiResponse::getType() const { return m_Type; } -bool ApiResponse::typeIsSet() const -{ - return m_TypeIsSet; +void ApiResponse::setType(const utility::string_t &value) { + m_Type = value; + m_TypeIsSet = true; } -void ApiResponse::unsetType() -{ - m_TypeIsSet = false; -} +bool ApiResponse::typeIsSet() const { return m_TypeIsSet; } -utility::string_t ApiResponse::getMessage() const -{ - return m_Message; -} +void ApiResponse::unsetType() { m_TypeIsSet = false; } -void ApiResponse::setMessage(const utility::string_t& value) -{ - m_Message = value; - m_MessageIsSet = true; -} +utility::string_t ApiResponse::getMessage() const { return m_Message; } -bool ApiResponse::messageIsSet() const -{ - return m_MessageIsSet; +void ApiResponse::setMessage(const utility::string_t &value) { + m_Message = value; + m_MessageIsSet = true; } -void ApiResponse::unsetMessage() -{ - m_MessageIsSet = false; -} +bool ApiResponse::messageIsSet() const { return m_MessageIsSet; } -} -} -} -} +void ApiResponse::unsetMessage() { m_MessageIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h index a65b2e83fc5..389d14c9368 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ - #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,67 +31,66 @@ namespace model { /// <summary> /// Describes the result of uploading an image resource /// </summary> -class ApiResponse - : public ModelBase -{ +class ApiResponse : public ModelBase { public: - ApiResponse(); - virtual ~ApiResponse(); - - ///////////////////////////////////////////// - /// ModelBase overrides + ApiResponse(); + virtual ~ApiResponse(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - ///////////////////////////////////////////// - /// ApiResponse members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - /// <summary> - /// - /// </summary> - int32_t getCode() const; - bool codeIsSet() const; - void unsetCode(); + ///////////////////////////////////////////// + /// ApiResponse members - void setCode(int32_t value); + /// <summary> + /// + /// </summary> + int32_t getCode() const; + bool codeIsSet() const; + void unsetCode(); - /// <summary> - /// - /// </summary> - utility::string_t getType() const; - bool typeIsSet() const; - void unsetType(); + void setCode(int32_t value); - void setType(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getType() const; + bool typeIsSet() const; + void unsetType(); - /// <summary> - /// - /// </summary> - utility::string_t getMessage() const; - bool messageIsSet() const; - void unsetMessage(); + void setType(const utility::string_t &value); - void setMessage(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getMessage() const; + bool messageIsSet() const; + void unsetMessage(); + void setMessage(const utility::string_t &value); protected: - int32_t m_Code; - bool m_CodeIsSet; - utility::string_t m_Type; - bool m_TypeIsSet; - utility::string_t m_Message; - bool m_MessageIsSet; + int32_t m_Code; + bool m_CodeIsSet; + utility::string_t m_Type; + bool m_TypeIsSet; + utility::string_t m_Message; + bool m_MessageIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.cpp b/samples/client/petstore/cpp-restsdk/model/Category.cpp index 68baf3c6bb9..601793f18da 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Category.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "Category.h" namespace org { @@ -18,139 +17,108 @@ namespace openapitools { namespace client { namespace model { -Category::Category() -{ - m_Id = 0L; - m_IdIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_NameIsSet = false; +Category::Category() { + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; } -Category::~Category() -{ -} +Category::~Category() {} -void Category::validate() -{ - // TODO: implement validation +void Category::validate() { + // TODO: implement validation } -web::json::value Category::toJson() const -{ - web::json::value val = web::json::value::object(); +web::json::value Category::toJson() const { + web::json::value val = web::json::value::object(); - if(m_IdIsSet) - { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if(m_NameIsSet) - { - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - } + if (m_IdIsSet) { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if (m_NameIsSet) { + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + } - return val; + return val; } -void Category::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("id"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); - if(!fieldValue.is_null()) - { - setId(ModelBase::int64_tFromJson(fieldValue)); - } +void Category::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("id"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("id")); + if (!fieldValue.is_null()) { + setId(ModelBase::int64_tFromJson(fieldValue)); } - if(val.has_field(utility::conversions::to_string_t("name"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name")); - if(!fieldValue.is_null()) - { - setName(ModelBase::stringFromJson(fieldValue)); - } + } + if (val.has_field(utility::conversions::to_string_t("name"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("name")); + if (!fieldValue.is_null()) { + setName(ModelBase::stringFromJson(fieldValue)); } + } } -void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } - if(m_IdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if(m_NameIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); - } + if (m_IdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if (m_NameIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("name"), m_Name)); + } } -void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(multipart->hasContent(utility::conversions::to_string_t("id"))) - { - setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("name"))) - { - setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); - } -} +void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } -int64_t Category::getId() const -{ - return m_Id; + if (multipart->hasContent(utility::conversions::to_string_t("id"))) { + setId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("id")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("name"))) { + setName(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("name")))); + } } -void Category::setId(int64_t value) -{ - m_Id = value; - m_IdIsSet = true; -} +int64_t Category::getId() const { return m_Id; } -bool Category::idIsSet() const -{ - return m_IdIsSet; +void Category::setId(int64_t value) { + m_Id = value; + m_IdIsSet = true; } -void Category::unsetId() -{ - m_IdIsSet = false; -} +bool Category::idIsSet() const { return m_IdIsSet; } -utility::string_t Category::getName() const -{ - return m_Name; -} +void Category::unsetId() { m_IdIsSet = false; } -void Category::setName(const utility::string_t& value) -{ - m_Name = value; - m_NameIsSet = true; -} +utility::string_t Category::getName() const { return m_Name; } -bool Category::nameIsSet() const -{ - return m_NameIsSet; +void Category::setName(const utility::string_t &value) { + m_Name = value; + m_NameIsSet = true; } -void Category::unsetName() -{ - m_NameIsSet = false; -} +bool Category::nameIsSet() const { return m_NameIsSet; } -} -} -} -} +void Category::unsetName() { m_NameIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Category.h b/samples/client/petstore/cpp-restsdk/model/Category.h index 0f3f9d55a32..23b66f3cf34 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/model/Category.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ - #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,56 +31,55 @@ namespace model { /// <summary> /// A category for a pet /// </summary> -class Category - : public ModelBase -{ +class Category : public ModelBase { public: - Category(); - virtual ~Category(); - - ///////////////////////////////////////////// - /// ModelBase overrides + Category(); + virtual ~Category(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - ///////////////////////////////////////////// - /// Category members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + ///////////////////////////////////////////// + /// Category members - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - utility::string_t getName() const; - bool nameIsSet() const; - void unsetName(); + void setId(int64_t value); - void setName(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); + void setName(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Name; - bool m_NameIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.cpp b/samples/client/petstore/cpp-restsdk/model/Order.cpp index 9e438173135..dde0ecebaa4 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Order.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "Order.h" namespace org { @@ -18,311 +17,240 @@ namespace openapitools { namespace client { namespace model { -Order::Order() -{ - m_Id = 0L; - m_IdIsSet = false; - m_PetId = 0L; - m_PetIdIsSet = false; - m_Quantity = 0; - m_QuantityIsSet = false; - m_ShipDate = utility::datetime(); - m_ShipDateIsSet = false; - m_Status = utility::conversions::to_string_t(""); - m_StatusIsSet = false; - m_Complete = false; - m_CompleteIsSet = false; -} - -Order::~Order() -{ -} - -void Order::validate() -{ - // TODO: implement validation -} - -web::json::value Order::toJson() const -{ - web::json::value val = web::json::value::object(); - - if(m_IdIsSet) - { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); +Order::Order() { + m_Id = 0L; + m_IdIsSet = false; + m_PetId = 0L; + m_PetIdIsSet = false; + m_Quantity = 0; + m_QuantityIsSet = false; + m_ShipDate = utility::datetime(); + m_ShipDateIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; + m_Complete = false; + m_CompleteIsSet = false; +} + +Order::~Order() {} + +void Order::validate() { + // TODO: implement validation +} + +web::json::value Order::toJson() const { + web::json::value val = web::json::value::object(); + + if (m_IdIsSet) { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if (m_PetIdIsSet) { + val[utility::conversions::to_string_t("petId")] = + ModelBase::toJson(m_PetId); + } + if (m_QuantityIsSet) { + val[utility::conversions::to_string_t("quantity")] = + ModelBase::toJson(m_Quantity); + } + if (m_ShipDateIsSet) { + val[utility::conversions::to_string_t("shipDate")] = + ModelBase::toJson(m_ShipDate); + } + if (m_StatusIsSet) { + val[utility::conversions::to_string_t("status")] = + ModelBase::toJson(m_Status); + } + if (m_CompleteIsSet) { + val[utility::conversions::to_string_t("complete")] = + ModelBase::toJson(m_Complete); + } + + return val; +} + +void Order::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("id"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("id")); + if (!fieldValue.is_null()) { + setId(ModelBase::int64_tFromJson(fieldValue)); } - if(m_PetIdIsSet) - { - val[utility::conversions::to_string_t("petId")] = ModelBase::toJson(m_PetId); + } + if (val.has_field(utility::conversions::to_string_t("petId"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("petId")); + if (!fieldValue.is_null()) { + setPetId(ModelBase::int64_tFromJson(fieldValue)); } - if(m_QuantityIsSet) - { - val[utility::conversions::to_string_t("quantity")] = ModelBase::toJson(m_Quantity); + } + if (val.has_field(utility::conversions::to_string_t("quantity"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("quantity")); + if (!fieldValue.is_null()) { + setQuantity(ModelBase::int32_tFromJson(fieldValue)); } - if(m_ShipDateIsSet) - { - val[utility::conversions::to_string_t("shipDate")] = ModelBase::toJson(m_ShipDate); + } + if (val.has_field(utility::conversions::to_string_t("shipDate"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("shipDate")); + if (!fieldValue.is_null()) { + setShipDate(ModelBase::dateFromJson(fieldValue)); } - if(m_StatusIsSet) - { - val[utility::conversions::to_string_t("status")] = ModelBase::toJson(m_Status); + } + if (val.has_field(utility::conversions::to_string_t("status"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("status")); + if (!fieldValue.is_null()) { + setStatus(ModelBase::stringFromJson(fieldValue)); } - if(m_CompleteIsSet) - { - val[utility::conversions::to_string_t("complete")] = ModelBase::toJson(m_Complete); + } + if (val.has_field(utility::conversions::to_string_t("complete"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("complete")); + if (!fieldValue.is_null()) { + setComplete(ModelBase::boolFromJson(fieldValue)); } - - return val; + } +} + +void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + + if (m_IdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if (m_PetIdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("petId"), m_PetId)); + } + if (m_QuantityIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("quantity"), + m_Quantity)); + } + if (m_ShipDateIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("shipDate"), + m_ShipDate)); + } + if (m_StatusIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("status"), m_Status)); + } + if (m_CompleteIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("complete"), + m_Complete)); + } } -void Order::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("id"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); - if(!fieldValue.is_null()) - { - setId(ModelBase::int64_tFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("petId"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("petId")); - if(!fieldValue.is_null()) - { - setPetId(ModelBase::int64_tFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("quantity"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("quantity")); - if(!fieldValue.is_null()) - { - setQuantity(ModelBase::int32_tFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("shipDate"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("shipDate")); - if(!fieldValue.is_null()) - { - setShipDate(ModelBase::dateFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("status"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status")); - if(!fieldValue.is_null()) - { - setStatus(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("complete"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("complete")); - if(!fieldValue.is_null()) - { - setComplete(ModelBase::boolFromJson(fieldValue)); - } - } -} - -void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(m_IdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if(m_PetIdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("petId"), m_PetId)); - } - if(m_QuantityIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("quantity"), m_Quantity)); - } - if(m_ShipDateIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("shipDate"), m_ShipDate)); - } - if(m_StatusIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("status"), m_Status)); - } - if(m_CompleteIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("complete"), m_Complete)); - } -} - -void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(multipart->hasContent(utility::conversions::to_string_t("id"))) - { - setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("petId"))) - { - setPetId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("petId")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("quantity"))) - { - setQuantity(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("quantity")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("shipDate"))) - { - setShipDate(ModelBase::dateFromHttpContent(multipart->getContent(utility::conversions::to_string_t("shipDate")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("status"))) - { - setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("complete"))) - { - setComplete(ModelBase::boolFromHttpContent(multipart->getContent(utility::conversions::to_string_t("complete")))); - } -} +void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } -int64_t Order::getId() const -{ - return m_Id; + if (multipart->hasContent(utility::conversions::to_string_t("id"))) { + setId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("id")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("petId"))) { + setPetId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("petId")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("quantity"))) { + setQuantity(ModelBase::int32_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("quantity")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("shipDate"))) { + setShipDate(ModelBase::dateFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("shipDate")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("status"))) { + setStatus(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("status")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("complete"))) { + setComplete(ModelBase::boolFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("complete")))); + } } -void Order::setId(int64_t value) -{ - m_Id = value; - m_IdIsSet = true; -} +int64_t Order::getId() const { return m_Id; } -bool Order::idIsSet() const -{ - return m_IdIsSet; +void Order::setId(int64_t value) { + m_Id = value; + m_IdIsSet = true; } -void Order::unsetId() -{ - m_IdIsSet = false; -} +bool Order::idIsSet() const { return m_IdIsSet; } -int64_t Order::getPetId() const -{ - return m_PetId; -} +void Order::unsetId() { m_IdIsSet = false; } -void Order::setPetId(int64_t value) -{ - m_PetId = value; - m_PetIdIsSet = true; -} +int64_t Order::getPetId() const { return m_PetId; } -bool Order::petIdIsSet() const -{ - return m_PetIdIsSet; +void Order::setPetId(int64_t value) { + m_PetId = value; + m_PetIdIsSet = true; } -void Order::unsetPetId() -{ - m_PetIdIsSet = false; -} +bool Order::petIdIsSet() const { return m_PetIdIsSet; } -int32_t Order::getQuantity() const -{ - return m_Quantity; -} +void Order::unsetPetId() { m_PetIdIsSet = false; } -void Order::setQuantity(int32_t value) -{ - m_Quantity = value; - m_QuantityIsSet = true; -} +int32_t Order::getQuantity() const { return m_Quantity; } -bool Order::quantityIsSet() const -{ - return m_QuantityIsSet; +void Order::setQuantity(int32_t value) { + m_Quantity = value; + m_QuantityIsSet = true; } -void Order::unsetQuantity() -{ - m_QuantityIsSet = false; -} +bool Order::quantityIsSet() const { return m_QuantityIsSet; } -utility::datetime Order::getShipDate() const -{ - return m_ShipDate; -} +void Order::unsetQuantity() { m_QuantityIsSet = false; } -void Order::setShipDate(const utility::datetime& value) -{ - m_ShipDate = value; - m_ShipDateIsSet = true; -} +utility::datetime Order::getShipDate() const { return m_ShipDate; } -bool Order::shipDateIsSet() const -{ - return m_ShipDateIsSet; +void Order::setShipDate(const utility::datetime &value) { + m_ShipDate = value; + m_ShipDateIsSet = true; } -void Order::unsetShipDate() -{ - m_ShipDateIsSet = false; -} +bool Order::shipDateIsSet() const { return m_ShipDateIsSet; } -utility::string_t Order::getStatus() const -{ - return m_Status; -} +void Order::unsetShipDate() { m_ShipDateIsSet = false; } -void Order::setStatus(const utility::string_t& value) -{ - m_Status = value; - m_StatusIsSet = true; -} +utility::string_t Order::getStatus() const { return m_Status; } -bool Order::statusIsSet() const -{ - return m_StatusIsSet; +void Order::setStatus(const utility::string_t &value) { + m_Status = value; + m_StatusIsSet = true; } -void Order::unsetStatus() -{ - m_StatusIsSet = false; -} +bool Order::statusIsSet() const { return m_StatusIsSet; } -bool Order::isComplete() const -{ - return m_Complete; -} +void Order::unsetStatus() { m_StatusIsSet = false; } -void Order::setComplete(bool value) -{ - m_Complete = value; - m_CompleteIsSet = true; -} +bool Order::isComplete() const { return m_Complete; } -bool Order::completeIsSet() const -{ - return m_CompleteIsSet; +void Order::setComplete(bool value) { + m_Complete = value; + m_CompleteIsSet = true; } -void Order::unsetComplete() -{ - m_CompleteIsSet = false; -} +bool Order::completeIsSet() const { return m_CompleteIsSet; } -} -} -} -} +void Order::unsetComplete() { m_CompleteIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Order.h b/samples/client/petstore/cpp-restsdk/model/Order.h index b7ea4c528c1..55212bdbcf7 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/model/Order.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ - #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,100 +31,99 @@ namespace model { /// <summary> /// An order for a pets from the pet store /// </summary> -class Order - : public ModelBase -{ +class Order : public ModelBase { public: - Order(); - virtual ~Order(); - - ///////////////////////////////////////////// - /// ModelBase overrides + Order(); + virtual ~Order(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - ///////////////////////////////////////////// - /// Order members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + ///////////////////////////////////////////// + /// Order members - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getPetId() const; - bool petIdIsSet() const; - void unsetPetId(); + void setId(int64_t value); - void setPetId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getPetId() const; + bool petIdIsSet() const; + void unsetPetId(); - /// <summary> - /// - /// </summary> - int32_t getQuantity() const; - bool quantityIsSet() const; - void unsetQuantity(); + void setPetId(int64_t value); - void setQuantity(int32_t value); + /// <summary> + /// + /// </summary> + int32_t getQuantity() const; + bool quantityIsSet() const; + void unsetQuantity(); - /// <summary> - /// - /// </summary> - utility::datetime getShipDate() const; - bool shipDateIsSet() const; - void unsetShipDate(); + void setQuantity(int32_t value); - void setShipDate(const utility::datetime& value); + /// <summary> + /// + /// </summary> + utility::datetime getShipDate() const; + bool shipDateIsSet() const; + void unsetShipDate(); - /// <summary> - /// Order Status - /// </summary> - utility::string_t getStatus() const; - bool statusIsSet() const; - void unsetStatus(); + void setShipDate(const utility::datetime &value); - void setStatus(const utility::string_t& value); + /// <summary> + /// Order Status + /// </summary> + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); - /// <summary> - /// - /// </summary> - bool isComplete() const; - bool completeIsSet() const; - void unsetComplete(); + void setStatus(const utility::string_t &value); - void setComplete(bool value); + /// <summary> + /// + /// </summary> + bool isComplete() const; + bool completeIsSet() const; + void unsetComplete(); + void setComplete(bool value); protected: - int64_t m_Id; - bool m_IdIsSet; - int64_t m_PetId; - bool m_PetIdIsSet; - int32_t m_Quantity; - bool m_QuantityIsSet; - utility::datetime m_ShipDate; - bool m_ShipDateIsSet; - utility::string_t m_Status; - bool m_StatusIsSet; - bool m_Complete; - bool m_CompleteIsSet; + int64_t m_Id; + bool m_IdIsSet; + int64_t m_PetId; + bool m_PetIdIsSet; + int32_t m_Quantity; + bool m_QuantityIsSet; + utility::datetime m_ShipDate; + bool m_ShipDateIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; + bool m_Complete; + bool m_CompleteIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/model/Pet.cpp index 8b6e77835f7..65f5eb6874a 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Pet.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "Pet.h" namespace org { @@ -18,337 +17,271 @@ namespace openapitools { namespace client { namespace model { -Pet::Pet() -{ - m_Id = 0L; - m_IdIsSet = false; - m_CategoryIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_TagsIsSet = false; - m_Status = utility::conversions::to_string_t(""); - m_StatusIsSet = false; +Pet::Pet() { + m_Id = 0L; + m_IdIsSet = false; + m_CategoryIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_TagsIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; } -Pet::~Pet() -{ -} +Pet::~Pet() {} -void Pet::validate() -{ - // TODO: implement validation +void Pet::validate() { + // TODO: implement validation } -web::json::value Pet::toJson() const -{ - web::json::value val = web::json::value::object(); - - if(m_IdIsSet) - { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if(m_CategoryIsSet) - { - val[utility::conversions::to_string_t("category")] = ModelBase::toJson(m_Category); - } - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - { - std::vector<web::json::value> jsonArray; - for( auto& item : m_PhotoUrls ) - { - jsonArray.push_back(ModelBase::toJson(item)); - } - val[utility::conversions::to_string_t("photoUrls")] = web::json::value::array(jsonArray); +web::json::value Pet::toJson() const { + web::json::value val = web::json::value::object(); + + if (m_IdIsSet) { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if (m_CategoryIsSet) { + val[utility::conversions::to_string_t("category")] = + ModelBase::toJson(m_Category); + } + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + { + std::vector<web::json::value> jsonArray; + for (auto &item : m_PhotoUrls) { + jsonArray.push_back(ModelBase::toJson(item)); } - { - std::vector<web::json::value> jsonArray; - for( auto& item : m_Tags ) - { - jsonArray.push_back(ModelBase::toJson(item)); - } - if(jsonArray.size() > 0) - { - val[utility::conversions::to_string_t("tags")] = web::json::value::array(jsonArray); - } + val[utility::conversions::to_string_t("photoUrls")] = + web::json::value::array(jsonArray); + } + { + std::vector<web::json::value> jsonArray; + for (auto &item : m_Tags) { + jsonArray.push_back(ModelBase::toJson(item)); } - if(m_StatusIsSet) - { - val[utility::conversions::to_string_t("status")] = ModelBase::toJson(m_Status); + if (jsonArray.size() > 0) { + val[utility::conversions::to_string_t("tags")] = + web::json::value::array(jsonArray); } + } + if (m_StatusIsSet) { + val[utility::conversions::to_string_t("status")] = + ModelBase::toJson(m_Status); + } - return val; + return val; } -void Pet::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("id"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); - if(!fieldValue.is_null()) - { - setId(ModelBase::int64_tFromJson(fieldValue)); - } +void Pet::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("id"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("id")); + if (!fieldValue.is_null()) { + setId(ModelBase::int64_tFromJson(fieldValue)); } - if(val.has_field(utility::conversions::to_string_t("category"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("category")); - if(!fieldValue.is_null()) - { - std::shared_ptr<Category> newItem(new Category()); - newItem->fromJson(fieldValue); - setCategory( newItem ); - } + } + if (val.has_field(utility::conversions::to_string_t("category"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("category")); + if (!fieldValue.is_null()) { + std::shared_ptr<Category> newItem(new Category()); + newItem->fromJson(fieldValue); + setCategory(newItem); } - setName(ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("name")))); - { - m_PhotoUrls.clear(); - std::vector<web::json::value> jsonArray; - for( auto& item : val.at(utility::conversions::to_string_t("photoUrls")).as_array() ) - { - m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); - } + } + setName(ModelBase::stringFromJson( + val.at(utility::conversions::to_string_t("name")))); + { + m_PhotoUrls.clear(); + std::vector<web::json::value> jsonArray; + for (auto &item : + val.at(utility::conversions::to_string_t("photoUrls")).as_array()) { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); } - { - m_Tags.clear(); - std::vector<web::json::value> jsonArray; - if(val.has_field(utility::conversions::to_string_t("tags"))) - { - for( auto& item : val.at(utility::conversions::to_string_t("tags")).as_array() ) - { - if(item.is_null()) - { - m_Tags.push_back( std::shared_ptr<Tag>(nullptr) ); - } - else - { - std::shared_ptr<Tag> newItem(new Tag()); - newItem->fromJson(item); - m_Tags.push_back( newItem ); - } - } + } + { + m_Tags.clear(); + std::vector<web::json::value> jsonArray; + if (val.has_field(utility::conversions::to_string_t("tags"))) { + for (auto &item : + val.at(utility::conversions::to_string_t("tags")).as_array()) { + if (item.is_null()) { + m_Tags.push_back(std::shared_ptr<Tag>(nullptr)); + } else { + std::shared_ptr<Tag> newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back(newItem); } + } } - if(val.has_field(utility::conversions::to_string_t("status"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status")); - if(!fieldValue.is_null()) - { - setStatus(ModelBase::stringFromJson(fieldValue)); - } + } + if (val.has_field(utility::conversions::to_string_t("status"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("status")); + if (!fieldValue.is_null()) { + setStatus(ModelBase::stringFromJson(fieldValue)); } + } } -void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(m_IdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if(m_CategoryIsSet) - { - if (m_Category.get()) - { - m_Category->toMultipart(multipart, utility::conversions::to_string_t("category.")); - } +void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + + if (m_IdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if (m_CategoryIsSet) { + if (m_Category.get()) { + m_Category->toMultipart(multipart, + utility::conversions::to_string_t("category.")); } - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); - { - std::vector<web::json::value> jsonArray; - for( auto& item : m_PhotoUrls ) - { - jsonArray.push_back(ModelBase::toJson(item)); - } - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("photoUrls"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); - } - { - std::vector<web::json::value> jsonArray; - for( auto& item : m_Tags ) - { - jsonArray.push_back(ModelBase::toJson(item)); - } - - if(jsonArray.size() > 0) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("tags"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); - } + } + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("name"), m_Name)); + { + std::vector<web::json::value> jsonArray; + for (auto &item : m_PhotoUrls) { + jsonArray.push_back(ModelBase::toJson(item)); } - if(m_StatusIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("status"), m_Status)); + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("photoUrls"), + web::json::value::array(jsonArray), + utility::conversions::to_string_t("application/json"))); + } + { + std::vector<web::json::value> jsonArray; + for (auto &item : m_Tags) { + jsonArray.push_back(ModelBase::toJson(item)); } -} -void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); + if (jsonArray.size() > 0) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("tags"), + web::json::value::array(jsonArray), + utility::conversions::to_string_t("application/json"))); } + } + if (m_StatusIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("status"), m_Status)); + } +} - if(multipart->hasContent(utility::conversions::to_string_t("id"))) - { - setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("category"))) - { - if(multipart->hasContent(utility::conversions::to_string_t("category"))) - { - std::shared_ptr<Category> newItem(new Category()); - newItem->fromMultiPart(multipart, utility::conversions::to_string_t("category.")); - setCategory( newItem ); - } +void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + + if (multipart->hasContent(utility::conversions::to_string_t("id"))) { + setId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("id")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("category"))) { + if (multipart->hasContent(utility::conversions::to_string_t("category"))) { + std::shared_ptr<Category> newItem(new Category()); + newItem->fromMultiPart(multipart, + utility::conversions::to_string_t("category.")); + setCategory(newItem); } - setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); - { - m_PhotoUrls.clear(); - - web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("photoUrls")))); - for( auto& item : jsonArray.as_array() ) - { - m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); - } + } + setName(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("name")))); + { + m_PhotoUrls.clear(); + + web::json::value jsonArray = web::json::value::parse( + ModelBase::stringFromHttpContent(multipart->getContent( + utility::conversions::to_string_t("photoUrls")))); + for (auto &item : jsonArray.as_array()) { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); } - { - m_Tags.clear(); - if(multipart->hasContent(utility::conversions::to_string_t("tags"))) - { - - web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("tags")))); - for( auto& item : jsonArray.as_array() ) - { - if(item.is_null()) - { - m_Tags.push_back( std::shared_ptr<Tag>(nullptr) ); - } - else - { - std::shared_ptr<Tag> newItem(new Tag()); - newItem->fromJson(item); - m_Tags.push_back( newItem ); - } - } + } + { + m_Tags.clear(); + if (multipart->hasContent(utility::conversions::to_string_t("tags"))) { + + web::json::value jsonArray = web::json::value::parse( + ModelBase::stringFromHttpContent(multipart->getContent( + utility::conversions::to_string_t("tags")))); + for (auto &item : jsonArray.as_array()) { + if (item.is_null()) { + m_Tags.push_back(std::shared_ptr<Tag>(nullptr)); + } else { + std::shared_ptr<Tag> newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back(newItem); } + } } - if(multipart->hasContent(utility::conversions::to_string_t("status"))) - { - setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")))); - } -} - -int64_t Pet::getId() const -{ - return m_Id; + } + if (multipart->hasContent(utility::conversions::to_string_t("status"))) { + setStatus(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("status")))); + } } -void Pet::setId(int64_t value) -{ - m_Id = value; - m_IdIsSet = true; -} +int64_t Pet::getId() const { return m_Id; } -bool Pet::idIsSet() const -{ - return m_IdIsSet; +void Pet::setId(int64_t value) { + m_Id = value; + m_IdIsSet = true; } -void Pet::unsetId() -{ - m_IdIsSet = false; -} +bool Pet::idIsSet() const { return m_IdIsSet; } -std::shared_ptr<Category> Pet::getCategory() const -{ - return m_Category; -} +void Pet::unsetId() { m_IdIsSet = false; } -void Pet::setCategory(const std::shared_ptr<Category>& value) -{ - m_Category = value; - m_CategoryIsSet = true; -} +std::shared_ptr<Category> Pet::getCategory() const { return m_Category; } -bool Pet::categoryIsSet() const -{ - return m_CategoryIsSet; +void Pet::setCategory(const std::shared_ptr<Category> &value) { + m_Category = value; + m_CategoryIsSet = true; } -void Pet::unsetCategory() -{ - m_CategoryIsSet = false; -} +bool Pet::categoryIsSet() const { return m_CategoryIsSet; } -utility::string_t Pet::getName() const -{ - return m_Name; -} +void Pet::unsetCategory() { m_CategoryIsSet = false; } -void Pet::setName(const utility::string_t& value) -{ - m_Name = value; - -} +utility::string_t Pet::getName() const { return m_Name; } -std::vector<utility::string_t>& Pet::getPhotoUrls() -{ - return m_PhotoUrls; -} +void Pet::setName(const utility::string_t &value) { m_Name = value; } -void Pet::setPhotoUrls(const std::vector<utility::string_t>& value) -{ - m_PhotoUrls = value; - -} +std::vector<utility::string_t> &Pet::getPhotoUrls() { return m_PhotoUrls; } -std::vector<std::shared_ptr<Tag>>& Pet::getTags() -{ - return m_Tags; +void Pet::setPhotoUrls(const std::vector<utility::string_t> &value) { + m_PhotoUrls = value; } -void Pet::setTags(const std::vector<std::shared_ptr<Tag>>& value) -{ - m_Tags = value; - m_TagsIsSet = true; -} +std::vector<std::shared_ptr<Tag>> &Pet::getTags() { return m_Tags; } -bool Pet::tagsIsSet() const -{ - return m_TagsIsSet; +void Pet::setTags(const std::vector<std::shared_ptr<Tag>> &value) { + m_Tags = value; + m_TagsIsSet = true; } -void Pet::unsetTags() -{ - m_TagsIsSet = false; -} +bool Pet::tagsIsSet() const { return m_TagsIsSet; } -utility::string_t Pet::getStatus() const -{ - return m_Status; -} +void Pet::unsetTags() { m_TagsIsSet = false; } -void Pet::setStatus(const utility::string_t& value) -{ - m_Status = value; - m_StatusIsSet = true; -} +utility::string_t Pet::getStatus() const { return m_Status; } -bool Pet::statusIsSet() const -{ - return m_StatusIsSet; +void Pet::setStatus(const utility::string_t &value) { + m_Status = value; + m_StatusIsSet = true; } -void Pet::unsetStatus() -{ - m_StatusIsSet = false; -} +bool Pet::statusIsSet() const { return m_StatusIsSet; } -} -} -} -} +void Pet::unsetStatus() { m_StatusIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.h b/samples/client/petstore/cpp-restsdk/model/Pet.h index 55a1b86af41..467756fa4bf 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/model/Pet.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,12 +19,11 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ - #include "../ModelBase.h" +#include "Category.h" #include "Tag.h" #include <cpprest/details/basic_types.h> -#include "Category.h" #include <vector> namespace org { @@ -34,94 +34,93 @@ namespace model { /// <summary> /// A pet for sale in the pet store /// </summary> -class Pet - : public ModelBase -{ +class Pet : public ModelBase { public: - Pet(); - virtual ~Pet(); + Pet(); + virtual ~Pet(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + ///////////////////////////////////////////// + /// Pet members - ///////////////////////////////////////////// - /// Pet members + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + void setId(int64_t value); - void setId(int64_t value); + /// <summary> + /// + /// </summary> + std::shared_ptr<Category> getCategory() const; + bool categoryIsSet() const; + void unsetCategory(); - /// <summary> - /// - /// </summary> - std::shared_ptr<Category> getCategory() const; - bool categoryIsSet() const; - void unsetCategory(); + void setCategory(const std::shared_ptr<Category> &value); - void setCategory(const std::shared_ptr<Category>& value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; - /// <summary> - /// - /// </summary> - utility::string_t getName() const; - - void setName(const utility::string_t& value); + void setName(const utility::string_t &value); - /// <summary> - /// - /// </summary> - std::vector<utility::string_t>& getPhotoUrls(); - - void setPhotoUrls(const std::vector<utility::string_t>& value); + /// <summary> + /// + /// </summary> + std::vector<utility::string_t> &getPhotoUrls(); - /// <summary> - /// - /// </summary> - std::vector<std::shared_ptr<Tag>>& getTags(); - bool tagsIsSet() const; - void unsetTags(); + void setPhotoUrls(const std::vector<utility::string_t> &value); - void setTags(const std::vector<std::shared_ptr<Tag>>& value); + /// <summary> + /// + /// </summary> + std::vector<std::shared_ptr<Tag>> &getTags(); + bool tagsIsSet() const; + void unsetTags(); - /// <summary> - /// pet status in the store - /// </summary> - utility::string_t getStatus() const; - bool statusIsSet() const; - void unsetStatus(); + void setTags(const std::vector<std::shared_ptr<Tag>> &value); - void setStatus(const utility::string_t& value); + /// <summary> + /// pet status in the store + /// </summary> + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); + void setStatus(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - std::shared_ptr<Category> m_Category; - bool m_CategoryIsSet; - utility::string_t m_Name; - std::vector<utility::string_t> m_PhotoUrls; - std::vector<std::shared_ptr<Tag>> m_Tags; - bool m_TagsIsSet; - utility::string_t m_Status; - bool m_StatusIsSet; + int64_t m_Id; + bool m_IdIsSet; + std::shared_ptr<Category> m_Category; + bool m_CategoryIsSet; + utility::string_t m_Name; + std::vector<utility::string_t> m_PhotoUrls; + std::vector<std::shared_ptr<Tag>> m_Tags; + bool m_TagsIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/model/Tag.cpp index d60ec0ecc42..36cc16b9ebb 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Tag.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "Tag.h" namespace org { @@ -18,139 +17,108 @@ namespace openapitools { namespace client { namespace model { -Tag::Tag() -{ - m_Id = 0L; - m_IdIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_NameIsSet = false; +Tag::Tag() { + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; } -Tag::~Tag() -{ -} +Tag::~Tag() {} -void Tag::validate() -{ - // TODO: implement validation +void Tag::validate() { + // TODO: implement validation } -web::json::value Tag::toJson() const -{ - web::json::value val = web::json::value::object(); +web::json::value Tag::toJson() const { + web::json::value val = web::json::value::object(); - if(m_IdIsSet) - { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if(m_NameIsSet) - { - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - } + if (m_IdIsSet) { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if (m_NameIsSet) { + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + } - return val; + return val; } -void Tag::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("id"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); - if(!fieldValue.is_null()) - { - setId(ModelBase::int64_tFromJson(fieldValue)); - } +void Tag::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("id"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("id")); + if (!fieldValue.is_null()) { + setId(ModelBase::int64_tFromJson(fieldValue)); } - if(val.has_field(utility::conversions::to_string_t("name"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name")); - if(!fieldValue.is_null()) - { - setName(ModelBase::stringFromJson(fieldValue)); - } + } + if (val.has_field(utility::conversions::to_string_t("name"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("name")); + if (!fieldValue.is_null()) { + setName(ModelBase::stringFromJson(fieldValue)); } + } } -void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } - if(m_IdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if(m_NameIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); - } + if (m_IdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if (m_NameIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("name"), m_Name)); + } } -void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } - - if(multipart->hasContent(utility::conversions::to_string_t("id"))) - { - setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("name"))) - { - setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); - } -} +void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } -int64_t Tag::getId() const -{ - return m_Id; + if (multipart->hasContent(utility::conversions::to_string_t("id"))) { + setId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("id")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("name"))) { + setName(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("name")))); + } } -void Tag::setId(int64_t value) -{ - m_Id = value; - m_IdIsSet = true; -} +int64_t Tag::getId() const { return m_Id; } -bool Tag::idIsSet() const -{ - return m_IdIsSet; +void Tag::setId(int64_t value) { + m_Id = value; + m_IdIsSet = true; } -void Tag::unsetId() -{ - m_IdIsSet = false; -} +bool Tag::idIsSet() const { return m_IdIsSet; } -utility::string_t Tag::getName() const -{ - return m_Name; -} +void Tag::unsetId() { m_IdIsSet = false; } -void Tag::setName(const utility::string_t& value) -{ - m_Name = value; - m_NameIsSet = true; -} +utility::string_t Tag::getName() const { return m_Name; } -bool Tag::nameIsSet() const -{ - return m_NameIsSet; +void Tag::setName(const utility::string_t &value) { + m_Name = value; + m_NameIsSet = true; } -void Tag::unsetName() -{ - m_NameIsSet = false; -} +bool Tag::nameIsSet() const { return m_NameIsSet; } -} -} -} -} +void Tag::unsetName() { m_NameIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.h b/samples/client/petstore/cpp-restsdk/model/Tag.h index 6ac7947b63c..73c7a50a07d 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/model/Tag.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ - #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,56 +31,55 @@ namespace model { /// <summary> /// A tag for a pet /// </summary> -class Tag - : public ModelBase -{ +class Tag : public ModelBase { public: - Tag(); - virtual ~Tag(); - - ///////////////////////////////////////////// - /// ModelBase overrides + Tag(); + virtual ~Tag(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - ///////////////////////////////////////////// - /// Tag members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + ///////////////////////////////////////////// + /// Tag members - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - utility::string_t getName() const; - bool nameIsSet() const; - void unsetName(); + void setId(int64_t value); - void setName(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); + void setName(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Name; - bool m_NameIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.cpp b/samples/client/petstore/cpp-restsdk/model/User.cpp index ced6a96347d..2c157f872e0 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.cpp +++ b/samples/client/petstore/cpp-restsdk/model/User.cpp @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -9,8 +10,6 @@ * Do not edit the class manually. */ - - #include "User.h" namespace org { @@ -18,397 +17,306 @@ namespace openapitools { namespace client { namespace model { -User::User() -{ - m_Id = 0L; - m_IdIsSet = false; - m_Username = utility::conversions::to_string_t(""); - m_UsernameIsSet = false; - m_FirstName = utility::conversions::to_string_t(""); - m_FirstNameIsSet = false; - m_LastName = utility::conversions::to_string_t(""); - m_LastNameIsSet = false; - m_Email = utility::conversions::to_string_t(""); - m_EmailIsSet = false; - m_Password = utility::conversions::to_string_t(""); - m_PasswordIsSet = false; - m_Phone = utility::conversions::to_string_t(""); - m_PhoneIsSet = false; - m_UserStatus = 0; - m_UserStatusIsSet = false; +User::User() { + m_Id = 0L; + m_IdIsSet = false; + m_Username = utility::conversions::to_string_t(""); + m_UsernameIsSet = false; + m_FirstName = utility::conversions::to_string_t(""); + m_FirstNameIsSet = false; + m_LastName = utility::conversions::to_string_t(""); + m_LastNameIsSet = false; + m_Email = utility::conversions::to_string_t(""); + m_EmailIsSet = false; + m_Password = utility::conversions::to_string_t(""); + m_PasswordIsSet = false; + m_Phone = utility::conversions::to_string_t(""); + m_PhoneIsSet = false; + m_UserStatus = 0; + m_UserStatusIsSet = false; +} + +User::~User() {} + +void User::validate() { + // TODO: implement validation +} + +web::json::value User::toJson() const { + web::json::value val = web::json::value::object(); + + if (m_IdIsSet) { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if (m_UsernameIsSet) { + val[utility::conversions::to_string_t("username")] = + ModelBase::toJson(m_Username); + } + if (m_FirstNameIsSet) { + val[utility::conversions::to_string_t("firstName")] = + ModelBase::toJson(m_FirstName); + } + if (m_LastNameIsSet) { + val[utility::conversions::to_string_t("lastName")] = + ModelBase::toJson(m_LastName); + } + if (m_EmailIsSet) { + val[utility::conversions::to_string_t("email")] = + ModelBase::toJson(m_Email); + } + if (m_PasswordIsSet) { + val[utility::conversions::to_string_t("password")] = + ModelBase::toJson(m_Password); + } + if (m_PhoneIsSet) { + val[utility::conversions::to_string_t("phone")] = + ModelBase::toJson(m_Phone); + } + if (m_UserStatusIsSet) { + val[utility::conversions::to_string_t("userStatus")] = + ModelBase::toJson(m_UserStatus); + } + + return val; +} + +void User::fromJson(const web::json::value &val) { + if (val.has_field(utility::conversions::to_string_t("id"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("id")); + if (!fieldValue.is_null()) { + setId(ModelBase::int64_tFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("username"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("username")); + if (!fieldValue.is_null()) { + setUsername(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("firstName"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("firstName")); + if (!fieldValue.is_null()) { + setFirstName(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("lastName"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("lastName")); + if (!fieldValue.is_null()) { + setLastName(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("email"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("email")); + if (!fieldValue.is_null()) { + setEmail(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("password"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("password")); + if (!fieldValue.is_null()) { + setPassword(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("phone"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("phone")); + if (!fieldValue.is_null()) { + setPhone(ModelBase::stringFromJson(fieldValue)); + } + } + if (val.has_field(utility::conversions::to_string_t("userStatus"))) { + const web::json::value &fieldValue = + val.at(utility::conversions::to_string_t("userStatus")); + if (!fieldValue.is_null()) { + setUserStatus(ModelBase::int32_tFromJson(fieldValue)); + } + } +} + +void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) const { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + + if (m_IdIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if (m_UsernameIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("username"), + m_Username)); + } + if (m_FirstNameIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("firstName"), + m_FirstName)); + } + if (m_LastNameIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("lastName"), + m_LastName)); + } + if (m_EmailIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("email"), m_Email)); + } + if (m_PasswordIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("password"), + m_Password)); + } + if (m_PhoneIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("phone"), m_Phone)); + } + if (m_UserStatusIsSet) { + multipart->add(ModelBase::toHttpContent( + namePrefix + utility::conversions::to_string_t("userStatus"), + m_UserStatus)); + } +} + +void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &prefix) { + utility::string_t namePrefix = prefix; + if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != + utility::conversions::to_string_t(".")) { + namePrefix += utility::conversions::to_string_t("."); + } + + if (multipart->hasContent(utility::conversions::to_string_t("id"))) { + setId(ModelBase::int64_tFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("id")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("username"))) { + setUsername(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("username")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("firstName"))) { + setFirstName(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("firstName")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("lastName"))) { + setLastName(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("lastName")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("email"))) { + setEmail(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("email")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("password"))) { + setPassword(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("password")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("phone"))) { + setPhone(ModelBase::stringFromHttpContent( + multipart->getContent(utility::conversions::to_string_t("phone")))); + } + if (multipart->hasContent(utility::conversions::to_string_t("userStatus"))) { + setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent( + utility::conversions::to_string_t("userStatus")))); + } } -User::~User() -{ -} +int64_t User::getId() const { return m_Id; } -void User::validate() -{ - // TODO: implement validation +void User::setId(int64_t value) { + m_Id = value; + m_IdIsSet = true; } -web::json::value User::toJson() const -{ - web::json::value val = web::json::value::object(); +bool User::idIsSet() const { return m_IdIsSet; } - if(m_IdIsSet) - { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if(m_UsernameIsSet) - { - val[utility::conversions::to_string_t("username")] = ModelBase::toJson(m_Username); - } - if(m_FirstNameIsSet) - { - val[utility::conversions::to_string_t("firstName")] = ModelBase::toJson(m_FirstName); - } - if(m_LastNameIsSet) - { - val[utility::conversions::to_string_t("lastName")] = ModelBase::toJson(m_LastName); - } - if(m_EmailIsSet) - { - val[utility::conversions::to_string_t("email")] = ModelBase::toJson(m_Email); - } - if(m_PasswordIsSet) - { - val[utility::conversions::to_string_t("password")] = ModelBase::toJson(m_Password); - } - if(m_PhoneIsSet) - { - val[utility::conversions::to_string_t("phone")] = ModelBase::toJson(m_Phone); - } - if(m_UserStatusIsSet) - { - val[utility::conversions::to_string_t("userStatus")] = ModelBase::toJson(m_UserStatus); - } +void User::unsetId() { m_IdIsSet = false; } - return val; -} +utility::string_t User::getUsername() const { return m_Username; } -void User::fromJson(const web::json::value& val) -{ - if(val.has_field(utility::conversions::to_string_t("id"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); - if(!fieldValue.is_null()) - { - setId(ModelBase::int64_tFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("username"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("username")); - if(!fieldValue.is_null()) - { - setUsername(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("firstName"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("firstName")); - if(!fieldValue.is_null()) - { - setFirstName(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("lastName"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("lastName")); - if(!fieldValue.is_null()) - { - setLastName(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("email"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("email")); - if(!fieldValue.is_null()) - { - setEmail(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("password"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("password")); - if(!fieldValue.is_null()) - { - setPassword(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("phone"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("phone")); - if(!fieldValue.is_null()) - { - setPhone(ModelBase::stringFromJson(fieldValue)); - } - } - if(val.has_field(utility::conversions::to_string_t("userStatus"))) - { - const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("userStatus")); - if(!fieldValue.is_null()) - { - setUserStatus(ModelBase::int32_tFromJson(fieldValue)); - } - } +void User::setUsername(const utility::string_t &value) { + m_Username = value; + m_UsernameIsSet = true; } -void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +bool User::usernameIsSet() const { return m_UsernameIsSet; } - if(m_IdIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if(m_UsernameIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("username"), m_Username)); - } - if(m_FirstNameIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("firstName"), m_FirstName)); - } - if(m_LastNameIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("lastName"), m_LastName)); - } - if(m_EmailIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("email"), m_Email)); - } - if(m_PasswordIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("password"), m_Password)); - } - if(m_PhoneIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("phone"), m_Phone)); - } - if(m_UserStatusIsSet) - { - multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("userStatus"), m_UserStatus)); - } -} +void User::unsetUsername() { m_UsernameIsSet = false; } -void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) -{ - utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) - { - namePrefix += utility::conversions::to_string_t("."); - } +utility::string_t User::getFirstName() const { return m_FirstName; } - if(multipart->hasContent(utility::conversions::to_string_t("id"))) - { - setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("username"))) - { - setUsername(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("username")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("firstName"))) - { - setFirstName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("firstName")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("lastName"))) - { - setLastName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("lastName")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("email"))) - { - setEmail(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("email")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("password"))) - { - setPassword(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("password")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("phone"))) - { - setPhone(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("phone")))); - } - if(multipart->hasContent(utility::conversions::to_string_t("userStatus"))) - { - setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("userStatus")))); - } +void User::setFirstName(const utility::string_t &value) { + m_FirstName = value; + m_FirstNameIsSet = true; } -int64_t User::getId() const -{ - return m_Id; -} +bool User::firstNameIsSet() const { return m_FirstNameIsSet; } -void User::setId(int64_t value) -{ - m_Id = value; - m_IdIsSet = true; -} +void User::unsetFirstName() { m_FirstNameIsSet = false; } -bool User::idIsSet() const -{ - return m_IdIsSet; -} - -void User::unsetId() -{ - m_IdIsSet = false; -} - -utility::string_t User::getUsername() const -{ - return m_Username; -} - -void User::setUsername(const utility::string_t& value) -{ - m_Username = value; - m_UsernameIsSet = true; -} - -bool User::usernameIsSet() const -{ - return m_UsernameIsSet; -} - -void User::unsetUsername() -{ - m_UsernameIsSet = false; -} - -utility::string_t User::getFirstName() const -{ - return m_FirstName; -} - -void User::setFirstName(const utility::string_t& value) -{ - m_FirstName = value; - m_FirstNameIsSet = true; -} - -bool User::firstNameIsSet() const -{ - return m_FirstNameIsSet; -} - -void User::unsetFirstName() -{ - m_FirstNameIsSet = false; -} - -utility::string_t User::getLastName() const -{ - return m_LastName; -} +utility::string_t User::getLastName() const { return m_LastName; } -void User::setLastName(const utility::string_t& value) -{ - m_LastName = value; - m_LastNameIsSet = true; +void User::setLastName(const utility::string_t &value) { + m_LastName = value; + m_LastNameIsSet = true; } -bool User::lastNameIsSet() const -{ - return m_LastNameIsSet; -} +bool User::lastNameIsSet() const { return m_LastNameIsSet; } -void User::unsetLastName() -{ - m_LastNameIsSet = false; -} - -utility::string_t User::getEmail() const -{ - return m_Email; -} +void User::unsetLastName() { m_LastNameIsSet = false; } -void User::setEmail(const utility::string_t& value) -{ - m_Email = value; - m_EmailIsSet = true; -} +utility::string_t User::getEmail() const { return m_Email; } -bool User::emailIsSet() const -{ - return m_EmailIsSet; +void User::setEmail(const utility::string_t &value) { + m_Email = value; + m_EmailIsSet = true; } -void User::unsetEmail() -{ - m_EmailIsSet = false; -} +bool User::emailIsSet() const { return m_EmailIsSet; } -utility::string_t User::getPassword() const -{ - return m_Password; -} +void User::unsetEmail() { m_EmailIsSet = false; } -void User::setPassword(const utility::string_t& value) -{ - m_Password = value; - m_PasswordIsSet = true; -} +utility::string_t User::getPassword() const { return m_Password; } -bool User::passwordIsSet() const -{ - return m_PasswordIsSet; +void User::setPassword(const utility::string_t &value) { + m_Password = value; + m_PasswordIsSet = true; } -void User::unsetPassword() -{ - m_PasswordIsSet = false; -} +bool User::passwordIsSet() const { return m_PasswordIsSet; } -utility::string_t User::getPhone() const -{ - return m_Phone; -} +void User::unsetPassword() { m_PasswordIsSet = false; } -void User::setPhone(const utility::string_t& value) -{ - m_Phone = value; - m_PhoneIsSet = true; -} +utility::string_t User::getPhone() const { return m_Phone; } -bool User::phoneIsSet() const -{ - return m_PhoneIsSet; +void User::setPhone(const utility::string_t &value) { + m_Phone = value; + m_PhoneIsSet = true; } -void User::unsetPhone() -{ - m_PhoneIsSet = false; -} +bool User::phoneIsSet() const { return m_PhoneIsSet; } -int32_t User::getUserStatus() const -{ - return m_UserStatus; -} +void User::unsetPhone() { m_PhoneIsSet = false; } -void User::setUserStatus(int32_t value) -{ - m_UserStatus = value; - m_UserStatusIsSet = true; -} +int32_t User::getUserStatus() const { return m_UserStatus; } -bool User::userStatusIsSet() const -{ - return m_UserStatusIsSet; +void User::setUserStatus(int32_t value) { + m_UserStatus = value; + m_UserStatusIsSet = true; } -void User::unsetUserStatus() -{ - m_UserStatusIsSet = false; -} +bool User::userStatusIsSet() const { return m_UserStatusIsSet; } -} -} -} -} +void User::unsetUserStatus() { m_UserStatusIsSet = false; } +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/User.h b/samples/client/petstore/cpp-restsdk/model/User.h index 1a177f06832..2c7748e9807 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.h +++ b/samples/client/petstore/cpp-restsdk/model/User.h @@ -1,6 +1,7 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api + * key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -18,7 +19,6 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ - #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,122 +31,121 @@ namespace model { /// <summary> /// A User who is purchasing from the pet store /// </summary> -class User - : public ModelBase -{ +class User : public ModelBase { public: - User(); - virtual ~User(); - - ///////////////////////////////////////////// - /// ModelBase overrides + User(); + virtual ~User(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value& json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value &json) override; - ///////////////////////////////////////////// - /// User members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, + const utility::string_t &namePrefix) override; - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + ///////////////////////////////////////////// + /// User members - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - utility::string_t getUsername() const; - bool usernameIsSet() const; - void unsetUsername(); + void setId(int64_t value); - void setUsername(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getUsername() const; + bool usernameIsSet() const; + void unsetUsername(); - /// <summary> - /// - /// </summary> - utility::string_t getFirstName() const; - bool firstNameIsSet() const; - void unsetFirstName(); + void setUsername(const utility::string_t &value); - void setFirstName(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getFirstName() const; + bool firstNameIsSet() const; + void unsetFirstName(); - /// <summary> - /// - /// </summary> - utility::string_t getLastName() const; - bool lastNameIsSet() const; - void unsetLastName(); + void setFirstName(const utility::string_t &value); - void setLastName(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getLastName() const; + bool lastNameIsSet() const; + void unsetLastName(); - /// <summary> - /// - /// </summary> - utility::string_t getEmail() const; - bool emailIsSet() const; - void unsetEmail(); + void setLastName(const utility::string_t &value); - void setEmail(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getEmail() const; + bool emailIsSet() const; + void unsetEmail(); - /// <summary> - /// - /// </summary> - utility::string_t getPassword() const; - bool passwordIsSet() const; - void unsetPassword(); + void setEmail(const utility::string_t &value); - void setPassword(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getPassword() const; + bool passwordIsSet() const; + void unsetPassword(); - /// <summary> - /// - /// </summary> - utility::string_t getPhone() const; - bool phoneIsSet() const; - void unsetPhone(); + void setPassword(const utility::string_t &value); - void setPhone(const utility::string_t& value); + /// <summary> + /// + /// </summary> + utility::string_t getPhone() const; + bool phoneIsSet() const; + void unsetPhone(); - /// <summary> - /// User Status - /// </summary> - int32_t getUserStatus() const; - bool userStatusIsSet() const; - void unsetUserStatus(); + void setPhone(const utility::string_t &value); - void setUserStatus(int32_t value); + /// <summary> + /// User Status + /// </summary> + int32_t getUserStatus() const; + bool userStatusIsSet() const; + void unsetUserStatus(); + void setUserStatus(int32_t value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Username; - bool m_UsernameIsSet; - utility::string_t m_FirstName; - bool m_FirstNameIsSet; - utility::string_t m_LastName; - bool m_LastNameIsSet; - utility::string_t m_Email; - bool m_EmailIsSet; - utility::string_t m_Password; - bool m_PasswordIsSet; - utility::string_t m_Phone; - bool m_PhoneIsSet; - int32_t m_UserStatus; - bool m_UserStatusIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Username; + bool m_UsernameIsSet; + utility::string_t m_FirstName; + bool m_FirstNameIsSet; + utility::string_t m_LastName; + bool m_LastNameIsSet; + utility::string_t m_Email; + bool m_EmailIsSet; + utility::string_t m_Password; + bool m_PasswordIsSet; + utility::string_t m_Phone; + bool m_PhoneIsSet; + int32_t m_UserStatus; + bool m_UserStatusIsSet; }; -} -} -} -} +} // namespace model +} // namespace client +} // namespace openapitools +} // namespace org #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ */ -- GitLab From e316f638ff12527522bf08129717e3058e13cafe Mon Sep 17 00:00:00 2001 From: William Cheng <wing328hk@gmail.com> Date: Wed, 14 Nov 2018 15:45:57 +0800 Subject: [PATCH 3/3] restore cpp-restsdk samples without clang format --- .../client/petstore/cpp-restsdk/ApiClient.cpp | 269 +-- .../client/petstore/cpp-restsdk/ApiClient.h | 88 +- .../petstore/cpp-restsdk/ApiConfiguration.cpp | 77 +- .../petstore/cpp-restsdk/ApiConfiguration.h | 49 +- .../petstore/cpp-restsdk/ApiException.cpp | 50 +- .../petstore/cpp-restsdk/ApiException.h | 44 +- .../petstore/cpp-restsdk/HttpContent.cpp | 76 +- .../client/petstore/cpp-restsdk/HttpContent.h | 55 +- .../client/petstore/cpp-restsdk/IHttpBody.h | 19 +- .../client/petstore/cpp-restsdk/JsonBody.cpp | 25 +- .../client/petstore/cpp-restsdk/JsonBody.h | 24 +- .../client/petstore/cpp-restsdk/ModelBase.cpp | 617 +++--- .../client/petstore/cpp-restsdk/ModelBase.h | 186 +- .../cpp-restsdk/MultipartFormData.cpp | 142 +- .../petstore/cpp-restsdk/MultipartFormData.h | 47 +- .../client/petstore/cpp-restsdk/Object.cpp | 86 +- samples/client/petstore/cpp-restsdk/Object.h | 45 +- .../petstore/cpp-restsdk/api/PetApi.cpp | 1869 ++++++++--------- .../client/petstore/cpp-restsdk/api/PetApi.h | 207 +- .../petstore/cpp-restsdk/api/StoreApi.cpp | 908 ++++---- .../petstore/cpp-restsdk/api/StoreApi.h | 105 +- .../petstore/cpp-restsdk/api/UserApi.cpp | 1771 +++++++--------- .../client/petstore/cpp-restsdk/api/UserApi.h | 186 +- .../cpp-restsdk/model/ApiResponse.cpp | 251 ++- .../petstore/cpp-restsdk/model/ApiResponse.h | 95 +- .../petstore/cpp-restsdk/model/Category.cpp | 188 +- .../petstore/cpp-restsdk/model/Category.h | 77 +- .../petstore/cpp-restsdk/model/Order.cpp | 468 +++-- .../client/petstore/cpp-restsdk/model/Order.h | 149 +- .../client/petstore/cpp-restsdk/model/Pet.cpp | 495 +++-- .../client/petstore/cpp-restsdk/model/Pet.h | 141 +- .../client/petstore/cpp-restsdk/model/Tag.cpp | 188 +- .../client/petstore/cpp-restsdk/model/Tag.h | 77 +- .../petstore/cpp-restsdk/model/User.cpp | 618 +++--- .../client/petstore/cpp-restsdk/model/User.h | 185 +- 35 files changed, 4923 insertions(+), 4954 deletions(-) diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/ApiClient.cpp index 1ce911edc27..5df6b675e36 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiClient.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -11,17 +10,18 @@ */ #include "ApiClient.h" -#include "ModelBase.h" #include "MultipartFormData.h" +#include "ModelBase.h" -#include <iomanip> -#include <limits> #include <sstream> +#include <limits> +#include <iomanip> -template <typename T> utility::string_t toString(const T value) { +template <typename T> +utility::string_t toString(const T value) +{ std::ostringstream out; - out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed - << value; + out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed << value; return out.str(); } @@ -32,143 +32,162 @@ namespace api { using namespace org::openapitools::client::model; -ApiClient::ApiClient(std::shared_ptr<ApiConfiguration> configuration) - : m_Configuration(configuration) {} -ApiClient::~ApiClient() {} +ApiClient::ApiClient(std::shared_ptr<ApiConfiguration> configuration ) + : m_Configuration(configuration) +{ +} +ApiClient::~ApiClient() +{ +} -std::shared_ptr<ApiConfiguration> ApiClient::getConfiguration() const { - return m_Configuration; +std::shared_ptr<ApiConfiguration> ApiClient::getConfiguration() const +{ + return m_Configuration; } -void ApiClient::setConfiguration( - std::shared_ptr<ApiConfiguration> configuration) { - m_Configuration = configuration; +void ApiClient::setConfiguration(std::shared_ptr<ApiConfiguration> configuration) +{ + m_Configuration = configuration; } -utility::string_t ApiClient::parameterToString(utility::string_t value) { - return value; + +utility::string_t ApiClient::parameterToString(utility::string_t value) +{ + return value; } -utility::string_t ApiClient::parameterToString(int64_t value) { - std::stringstream valueAsStringStream; - valueAsStringStream << value; - return utility::conversions::to_string_t(valueAsStringStream.str()); +utility::string_t ApiClient::parameterToString(int64_t value) +{ + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); } -utility::string_t ApiClient::parameterToString(int32_t value) { - std::stringstream valueAsStringStream; - valueAsStringStream << value; - return utility::conversions::to_string_t(valueAsStringStream.str()); +utility::string_t ApiClient::parameterToString(int32_t value) +{ + std::stringstream valueAsStringStream; + valueAsStringStream << value; + return utility::conversions::to_string_t(valueAsStringStream.str()); } -utility::string_t ApiClient::parameterToString(float value) { - return utility::conversions::to_string_t(toString(value)); +utility::string_t ApiClient::parameterToString(float value) +{ + return utility::conversions::to_string_t(toString(value)); } -utility::string_t ApiClient::parameterToString(double value) { - return utility::conversions::to_string_t(toString(value)); +utility::string_t ApiClient::parameterToString(double value) +{ + return utility::conversions::to_string_t(toString(value)); } -utility::string_t ApiClient::parameterToString(const utility::datetime &value) { - return utility::conversions::to_string_t( - value.to_string(utility::datetime::ISO_8601)); +utility::string_t ApiClient::parameterToString(const utility::datetime &value) +{ + return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601)); } pplx::task<web::http::http_response> ApiClient::callApi( - const utility::string_t &path, const utility::string_t &method, - const std::map<utility::string_t, utility::string_t> &queryParams, + const utility::string_t& path, + const utility::string_t& method, + const std::map<utility::string_t, utility::string_t>& queryParams, const std::shared_ptr<IHttpBody> postBody, - const std::map<utility::string_t, utility::string_t> &headerParams, - const std::map<utility::string_t, utility::string_t> &formParams, - const std::map<utility::string_t, std::shared_ptr<HttpContent>> &fileParams, - const utility::string_t &contentType) const { - if (postBody != nullptr && formParams.size() != 0) { - throw ApiException(400, utility::conversions::to_string_t( - "Cannot have body and form params")); - } - - if (postBody != nullptr && fileParams.size() != 0) { - throw ApiException(400, utility::conversions::to_string_t( - "Cannot have body and file params")); - } - - if (fileParams.size() > 0 && - contentType != utility::conversions::to_string_t("multipart/form-data")) { - throw ApiException(400, utility::conversions::to_string_t( - "Operations with file parameters must be " - "called with multipart/form-data")); - } - - web::http::client::http_client client(m_Configuration->getBaseUrl(), - m_Configuration->getHttpConfig()); - - web::http::http_request request; - for (auto &kvp : headerParams) { - request.headers().add(kvp.first, kvp.second); - } - - if (fileParams.size() > 0) { - MultipartFormData uploadData; - for (auto &kvp : formParams) { - uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + const std::map<utility::string_t, utility::string_t>& headerParams, + const std::map<utility::string_t, utility::string_t>& formParams, + const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams, + const utility::string_t& contentType +) const +{ + if (postBody != nullptr && formParams.size() != 0) + { + throw ApiException(400, utility::conversions::to_string_t("Cannot have body and form params")); } - for (auto &kvp : fileParams) { - uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); + + if (postBody != nullptr && fileParams.size() != 0) + { + throw ApiException(400, utility::conversions::to_string_t("Cannot have body and file params")); } - std::stringstream data; - uploadData.writeTo(data); - auto bodyString = data.str(); - auto length = bodyString.size(); - request.set_body( - concurrency::streams::bytestream::open_istream(std::move(bodyString)), - length, - utility::conversions::to_string_t("multipart/form-data; boundary=") + - uploadData.getBoundary()); - } else { - if (postBody != nullptr) { - std::stringstream data; - postBody->writeTo(data); - auto bodyString = data.str(); - auto length = bodyString.size(); - request.set_body( - concurrency::streams::bytestream::open_istream(std::move(bodyString)), - length, contentType); - } else { - if (contentType == - utility::conversions::to_string_t("application/json")) { - web::json::value body_data = web::json::value::object(); - for (auto &kvp : formParams) { - body_data[kvp.first] = ModelBase::toJson(kvp.second); + + if (fileParams.size() > 0 && contentType != utility::conversions::to_string_t("multipart/form-data")) + { + throw ApiException(400, utility::conversions::to_string_t("Operations with file parameters must be called with multipart/form-data")); + } + + web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig()); + + web::http::http_request request; + for ( auto& kvp : headerParams ) + { + request.headers().add(kvp.first, kvp.second); + } + + if (fileParams.size() > 0) + { + MultipartFormData uploadData; + for (auto& kvp : formParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } - if (!formParams.empty()) { - request.set_body(body_data); + for (auto& kvp : fileParams) + { + uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } - } else { - web::http::uri_builder formData; - for (auto &kvp : formParams) { - formData.append_query(kvp.first, kvp.second); + std::stringstream data; + uploadData.writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary()); + } + else + { + if (postBody != nullptr) + { + std::stringstream data; + postBody->writeTo(data); + auto bodyString = data.str(); + auto length = bodyString.size(); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); } - if (!formParams.empty()) { - request.set_body(formData.query(), - utility::conversions::to_string_t( - "application/x-www-form-urlencoded")); + else + { + if (contentType == utility::conversions::to_string_t("application/json")) + { + web::json::value body_data = web::json::value::object(); + for (auto& kvp : formParams) + { + body_data[kvp.first] = ModelBase::toJson(kvp.second); + } + if (!formParams.empty()) + { + request.set_body(body_data); + } + } + else + { + web::http::uri_builder formData; + for (auto& kvp : formParams) + { + formData.append_query(kvp.first, kvp.second); + } + if (!formParams.empty()) + { + request.set_body(formData.query(), utility::conversions::to_string_t("application/x-www-form-urlencoded")); + } + } } - } } - } - - web::http::uri_builder builder(path); - for (auto &kvp : queryParams) { - builder.append_query(kvp.first, kvp.second); - } - request.set_request_uri(builder.to_uri()); - request.set_method(method); - if (!request.headers().has(web::http::header_names::user_agent)) { - request.headers().add(web::http::header_names::user_agent, - m_Configuration->getUserAgent()); - } - - return client.request(request); -} - -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org + + web::http::uri_builder builder(path); + for (auto& kvp : queryParams) + { + builder.append_query(kvp.first, kvp.second); + } + request.set_request_uri(builder.to_uri()); + request.set_method(method); + if ( !request.headers().has( web::http::header_names::user_agent ) ) + { + request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() ); + } + + return client.request(request); +} + +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.h b/samples/client/petstore/cpp-restsdk/ApiClient.h index 9f686c09b6f..8aea53688c5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.h +++ b/samples/client/petstore/cpp-restsdk/ApiClient.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,10 +18,11 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ + #include "ApiConfiguration.h" #include "ApiException.h" -#include "HttpContent.h" #include "IHttpBody.h" +#include "HttpContent.h" #include <memory> #include <vector> @@ -37,53 +37,57 @@ namespace api { using namespace org::openapitools::client::model; -class ApiClient { +class ApiClient +{ public: - ApiClient(std::shared_ptr<ApiConfiguration> configuration = nullptr); - virtual ~ApiClient(); - - std::shared_ptr<ApiConfiguration> getConfiguration() const; - void setConfiguration(std::shared_ptr<ApiConfiguration> configuration); - - static utility::string_t parameterToString(utility::string_t value); - static utility::string_t parameterToString(int32_t value); - static utility::string_t parameterToString(int64_t value); - static utility::string_t parameterToString(float value); - static utility::string_t parameterToString(double value); - static utility::string_t parameterToString(const utility::datetime &value); - template <class T> - static utility::string_t parameterToString(const std::vector<T> &value); - - pplx::task<web::http::http_response> - callApi(const utility::string_t &path, const utility::string_t &method, - const std::map<utility::string_t, utility::string_t> &queryParams, - const std::shared_ptr<IHttpBody> postBody, - const std::map<utility::string_t, utility::string_t> &headerParams, - const std::map<utility::string_t, utility::string_t> &formParams, - const std::map<utility::string_t, std::shared_ptr<HttpContent>> - &fileParams, - const utility::string_t &contentType) const; + ApiClient( std::shared_ptr<ApiConfiguration> configuration = nullptr ); + virtual ~ApiClient(); + + std::shared_ptr<ApiConfiguration> getConfiguration() const; + void setConfiguration(std::shared_ptr<ApiConfiguration> configuration); + + static utility::string_t parameterToString(utility::string_t value); + static utility::string_t parameterToString(int32_t value); + static utility::string_t parameterToString(int64_t value); + static utility::string_t parameterToString(float value); + static utility::string_t parameterToString(double value); + static utility::string_t parameterToString(const utility::datetime &value); + template<class T> + static utility::string_t parameterToString(const std::vector<T>& value); + + pplx::task<web::http::http_response> callApi( + const utility::string_t& path, + const utility::string_t& method, + const std::map<utility::string_t, utility::string_t>& queryParams, + const std::shared_ptr<IHttpBody> postBody, + const std::map<utility::string_t, utility::string_t>& headerParams, + const std::map<utility::string_t, utility::string_t>& formParams, + const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams, + const utility::string_t& contentType + ) const; protected: - std::shared_ptr<ApiConfiguration> m_Configuration; + + std::shared_ptr<ApiConfiguration> m_Configuration; }; -template <class T> -utility::string_t ApiClient::parameterToString(const std::vector<T> &value) { - utility::stringstream_t ss; +template<class T> +utility::string_t ApiClient::parameterToString(const std::vector<T>& value) +{ + utility::stringstream_t ss; - for (size_t i = 0; i < value.size(); i++) { - if (i > 0) - ss << utility::conversions::to_string_t(", "); - ss << ApiClient::parameterToString(value[i]); - } + for( size_t i = 0; i < value.size(); i++) + { + if( i > 0) ss << utility::conversions::to_string_t(", "); + ss << ApiClient::parameterToString(value[i]); + } - return ss.str(); + return ss.str(); } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp index fff446fa43d..abc0510b192 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,51 +16,65 @@ namespace openapitools { namespace client { namespace api { -ApiConfiguration::ApiConfiguration() {} +ApiConfiguration::ApiConfiguration() +{ +} -ApiConfiguration::~ApiConfiguration() {} +ApiConfiguration::~ApiConfiguration() +{ +} -web::http::client::http_client_config &ApiConfiguration::getHttpConfig() { - return m_HttpConfig; +web::http::client::http_client_config& ApiConfiguration::getHttpConfig() +{ + return m_HttpConfig; } -void ApiConfiguration::setHttpConfig( - web::http::client::http_client_config &value) { - m_HttpConfig = value; +void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value ) +{ + m_HttpConfig = value; } -utility::string_t ApiConfiguration::getBaseUrl() const { return m_BaseUrl; } +utility::string_t ApiConfiguration::getBaseUrl() const +{ + return m_BaseUrl; +} -void ApiConfiguration::setBaseUrl(const utility::string_t value) { - m_BaseUrl = value; +void ApiConfiguration::setBaseUrl( const utility::string_t value ) +{ + m_BaseUrl = value; } -utility::string_t ApiConfiguration::getUserAgent() const { return m_UserAgent; } +utility::string_t ApiConfiguration::getUserAgent() const +{ + return m_UserAgent; +} -void ApiConfiguration::setUserAgent(const utility::string_t value) { - m_UserAgent = value; +void ApiConfiguration::setUserAgent( const utility::string_t value ) +{ + m_UserAgent = value; } -std::map<utility::string_t, utility::string_t> & -ApiConfiguration::getDefaultHeaders() { - return m_DefaultHeaders; +std::map<utility::string_t, utility::string_t>& ApiConfiguration::getDefaultHeaders() +{ + return m_DefaultHeaders; } -utility::string_t -ApiConfiguration::getApiKey(const utility::string_t &prefix) const { - auto result = m_ApiKeys.find(prefix); - if (result != m_ApiKeys.end()) { - return result->second; - } - return utility::conversions::to_string_t(""); +utility::string_t ApiConfiguration::getApiKey( const utility::string_t& prefix) const +{ + auto result = m_ApiKeys.find(prefix); + if( result != m_ApiKeys.end() ) + { + return result->second; + } + return utility::conversions::to_string_t(""); } -void ApiConfiguration::setApiKey(const utility::string_t &prefix, - const utility::string_t &apiKey) { - m_ApiKeys[prefix] = apiKey; +void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ) +{ + m_ApiKeys[prefix] = apiKey; } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h index 1788a356517..35b7892cbf5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,8 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ + + #include <map> #include <cpprest/details/basic_types.h> @@ -28,36 +29,36 @@ namespace openapitools { namespace client { namespace api { -class ApiConfiguration { +class ApiConfiguration +{ public: - ApiConfiguration(); - virtual ~ApiConfiguration(); + ApiConfiguration(); + virtual ~ApiConfiguration(); - web::http::client::http_client_config &getHttpConfig(); - void setHttpConfig(web::http::client::http_client_config &value); + web::http::client::http_client_config& getHttpConfig(); + void setHttpConfig( web::http::client::http_client_config& value ); - utility::string_t getBaseUrl() const; - void setBaseUrl(const utility::string_t value); + utility::string_t getBaseUrl() const; + void setBaseUrl( const utility::string_t value ); - utility::string_t getUserAgent() const; - void setUserAgent(const utility::string_t value); + utility::string_t getUserAgent() const; + void setUserAgent( const utility::string_t value ); - std::map<utility::string_t, utility::string_t> &getDefaultHeaders(); + std::map<utility::string_t, utility::string_t>& getDefaultHeaders(); - utility::string_t getApiKey(const utility::string_t &prefix) const; - void setApiKey(const utility::string_t &prefix, - const utility::string_t &apiKey); + utility::string_t getApiKey( const utility::string_t& prefix) const; + void setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey ); protected: - utility::string_t m_BaseUrl; - std::map<utility::string_t, utility::string_t> m_DefaultHeaders; - std::map<utility::string_t, utility::string_t> m_ApiKeys; - web::http::client::http_client_config m_HttpConfig; - utility::string_t m_UserAgent; + utility::string_t m_BaseUrl; + std::map<utility::string_t, utility::string_t> m_DefaultHeaders; + std::map<utility::string_t, utility::string_t> m_ApiKeys; + web::http::client::http_client_config m_HttpConfig; + utility::string_t m_UserAgent; }; -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.cpp b/samples/client/petstore/cpp-restsdk/ApiException.cpp index 7b278fe0c0c..f8206bc56c9 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiException.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,27 +16,38 @@ namespace openapitools { namespace client { namespace api { -ApiException::ApiException(int errorCode, const utility::string_t &message, - std::shared_ptr<std::istream> content /*= nullptr*/) - : web::http::http_exception(errorCode, message), m_Content(content) {} -ApiException::ApiException( - int errorCode, const utility::string_t &message, - std::map<utility::string_t, utility::string_t> &headers, - std::shared_ptr<std::istream> content /*= nullptr*/) - : web::http::http_exception(errorCode, message), m_Content(content), - m_Headers(headers) {} +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr<std::istream> content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) +{ +} +ApiException::ApiException( int errorCode + , const utility::string_t& message + , std::map<utility::string_t, utility::string_t>& headers + , std::shared_ptr<std::istream> content /*= nullptr*/ ) + : web::http::http_exception( errorCode, message ) + , m_Content(content) + , m_Headers(headers) +{ +} -ApiException::~ApiException() {} +ApiException::~ApiException() +{ +} -std::shared_ptr<std::istream> ApiException::getContent() const { - return m_Content; +std::shared_ptr<std::istream> ApiException::getContent() const +{ + return m_Content; } -std::map<utility::string_t, utility::string_t> &ApiException::getHeaders() { - return m_Headers; +std::map<utility::string_t, utility::string_t>& ApiException::getHeaders() +{ + return m_Headers; } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/ApiException.h b/samples/client/petstore/cpp-restsdk/ApiException.h index e9d44907853..7de8a64e96d 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.h +++ b/samples/client/petstore/cpp-restsdk/ApiException.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,37 +18,44 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ #define ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_ -#include <map> + + #include <memory> +#include <map> #include <cpprest/details/basic_types.h> #include <cpprest/http_msg.h> + namespace org { namespace openapitools { namespace client { namespace api { -class ApiException : public web::http::http_exception { +class ApiException + : public web::http::http_exception +{ public: - ApiException(int errorCode, const utility::string_t &message, - std::shared_ptr<std::istream> content = nullptr); - ApiException(int errorCode, const utility::string_t &message, - std::map<utility::string_t, utility::string_t> &headers, - std::shared_ptr<std::istream> content = nullptr); - virtual ~ApiException(); - - std::map<utility::string_t, utility::string_t> &getHeaders(); - std::shared_ptr<std::istream> getContent() const; + ApiException( int errorCode + , const utility::string_t& message + , std::shared_ptr<std::istream> content = nullptr ); + ApiException( int errorCode + , const utility::string_t& message + , std::map<utility::string_t, utility::string_t>& headers + , std::shared_ptr<std::istream> content = nullptr ); + virtual ~ApiException(); + + std::map<utility::string_t, utility::string_t>& getHeaders(); + std::shared_ptr<std::istream> getContent() const; protected: - std::shared_ptr<std::istream> m_Content; - std::map<utility::string_t, utility::string_t> m_Headers; + std::shared_ptr<std::istream> m_Content; + std::map<utility::string_t, utility::string_t> m_Headers; }; -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/HttpContent.cpp index 83a810104b1..c64fc2e26ee 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.cpp +++ b/samples/client/petstore/cpp-restsdk/HttpContent.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,46 +16,71 @@ namespace openapitools { namespace client { namespace model { -HttpContent::HttpContent() {} +HttpContent::HttpContent() +{ +} -HttpContent::~HttpContent() {} +HttpContent::~HttpContent() +{ +} -utility::string_t HttpContent::getContentDisposition() { - return m_ContentDisposition; +utility::string_t HttpContent::getContentDisposition() +{ + return m_ContentDisposition; } -void HttpContent::setContentDisposition(const utility::string_t &value) { - m_ContentDisposition = value; +void HttpContent::setContentDisposition( const utility::string_t & value ) +{ + m_ContentDisposition = value; } -utility::string_t HttpContent::getName() { return m_Name; } +utility::string_t HttpContent::getName() +{ + return m_Name; +} -void HttpContent::setName(const utility::string_t &value) { m_Name = value; } +void HttpContent::setName( const utility::string_t & value ) +{ + m_Name = value; +} -utility::string_t HttpContent::getFileName() { return m_FileName; } +utility::string_t HttpContent::getFileName() +{ + return m_FileName; +} -void HttpContent::setFileName(const utility::string_t &value) { - m_FileName = value; +void HttpContent::setFileName( const utility::string_t & value ) +{ + m_FileName = value; } -utility::string_t HttpContent::getContentType() { return m_ContentType; } +utility::string_t HttpContent::getContentType() +{ + return m_ContentType; +} -void HttpContent::setContentType(const utility::string_t &value) { - m_ContentType = value; +void HttpContent::setContentType( const utility::string_t & value ) +{ + m_ContentType = value; } -std::shared_ptr<std::istream> HttpContent::getData() { return m_Data; } +std::shared_ptr<std::istream> HttpContent::getData() +{ + return m_Data; +} -void HttpContent::setData(std::shared_ptr<std::istream> value) { - m_Data = value; +void HttpContent::setData( std::shared_ptr<std::istream> value ) +{ + m_Data = value; } -void HttpContent::writeTo(std::ostream &stream) { - m_Data->seekg(0, m_Data->beg); - stream << m_Data->rdbuf(); +void HttpContent::writeTo( std::ostream& stream ) +{ + m_Data->seekg( 0, m_Data->beg ); + stream << m_Data->rdbuf(); } -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.h b/samples/client/petstore/cpp-restsdk/HttpContent.h index c28300c7099..a5edc34dd2a 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.h +++ b/samples/client/petstore/cpp-restsdk/HttpContent.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,8 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ + + #include <memory> #include <cpprest/details/basic_types.h> @@ -28,41 +29,41 @@ namespace openapitools { namespace client { namespace model { -class HttpContent { +class HttpContent +{ public: - HttpContent(); - virtual ~HttpContent(); + HttpContent(); + virtual ~HttpContent(); - virtual utility::string_t getContentDisposition(); - virtual void setContentDisposition(const utility::string_t &value); + virtual utility::string_t getContentDisposition(); + virtual void setContentDisposition( const utility::string_t& value ); - virtual utility::string_t getName(); - virtual void setName(const utility::string_t &value); + virtual utility::string_t getName(); + virtual void setName( const utility::string_t& value ); - virtual utility::string_t getFileName(); - virtual void setFileName(const utility::string_t &value); + virtual utility::string_t getFileName(); + virtual void setFileName( const utility::string_t& value ); - virtual utility::string_t getContentType(); - virtual void setContentType(const utility::string_t &value); + virtual utility::string_t getContentType(); + virtual void setContentType( const utility::string_t& value ); - virtual std::shared_ptr<std::istream> getData(); - virtual void setData(std::shared_ptr<std::istream> value); + virtual std::shared_ptr<std::istream> getData(); + virtual void setData( std::shared_ptr<std::istream> value ); - virtual void writeTo(std::ostream &stream); + virtual void writeTo( std::ostream& stream ); protected: - // NOTE: no utility::string_t here because those strings can only contain - // ascii - utility::string_t m_ContentDisposition; - utility::string_t m_Name; - utility::string_t m_FileName; - utility::string_t m_ContentType; - std::shared_ptr<std::istream> m_Data; + // NOTE: no utility::string_t here because those strings can only contain ascii + utility::string_t m_ContentDisposition; + utility::string_t m_Name; + utility::string_t m_FileName; + utility::string_t m_ContentType; + std::shared_ptr<std::istream> m_Data; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/IHttpBody.h b/samples/client/petstore/cpp-restsdk/IHttpBody.h index 1e8c061ac25..592a3e3bcf7 100644 --- a/samples/client/petstore/cpp-restsdk/IHttpBody.h +++ b/samples/client/petstore/cpp-restsdk/IHttpBody.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ + #include <iostream> namespace org { @@ -26,16 +26,17 @@ namespace openapitools { namespace client { namespace model { -class IHttpBody { +class IHttpBody +{ public: - virtual ~IHttpBody() {} + virtual ~IHttpBody() { } - virtual void writeTo(std::ostream &stream) = 0; + virtual void writeTo( std::ostream& stream ) = 0; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/JsonBody.cpp index 8ee4289ba5a..f058afe6e08 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.cpp +++ b/samples/client/petstore/cpp-restsdk/JsonBody.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,13 +16,21 @@ namespace openapitools { namespace client { namespace model { -JsonBody::JsonBody(const web::json::value &json) : m_Json(json) {} +JsonBody::JsonBody( const web::json::value& json) + : m_Json(json) +{ +} -JsonBody::~JsonBody() {} +JsonBody::~JsonBody() +{ +} -void JsonBody::writeTo(std::ostream &target) { m_Json.serialize(target); } +void JsonBody::writeTo( std::ostream& target ) +{ + m_Json.serialize(target); +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.h b/samples/client/petstore/cpp-restsdk/JsonBody.h index 20bb691bedd..028dd07bfcc 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.h +++ b/samples/client/petstore/cpp-restsdk/JsonBody.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ + #include "IHttpBody.h" #include <cpprest/json.h> @@ -28,20 +28,22 @@ namespace openapitools { namespace client { namespace model { -class JsonBody : public IHttpBody { +class JsonBody + : public IHttpBody +{ public: - JsonBody(const web::json::value &value); - virtual ~JsonBody(); + JsonBody( const web::json::value& value ); + virtual ~JsonBody(); - void writeTo(std::ostream &target) override; + void writeTo( std::ostream& target ) override; protected: - web::json::value m_Json; + web::json::value m_Json; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/ModelBase.cpp index 21c0d80187c..4abda808cb0 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.cpp +++ b/samples/client/petstore/cpp-restsdk/ModelBase.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,353 +16,363 @@ namespace openapitools { namespace client { namespace model { -ModelBase::ModelBase() {} -ModelBase::~ModelBase() {} - -web::json::value ModelBase::toJson(const utility::string_t &value) { - return web::json::value::string(value); -} -web::json::value ModelBase::toJson(const utility::datetime &value) { - return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); -} -web::json::value ModelBase::toJson(int32_t value) { - return web::json::value::number(value); +ModelBase::ModelBase() +{ } -web::json::value ModelBase::toJson(int64_t value) { - return web::json::value::number(value); -} -web::json::value ModelBase::toJson(double value) { - return web::json::value::number(value); +ModelBase::~ModelBase() +{ } + +web::json::value ModelBase::toJson( const utility::string_t& value ) +{ + return web::json::value::string(value); +} +web::json::value ModelBase::toJson( const utility::datetime& value ) +{ + return web::json::value::string(value.to_string(utility::datetime::ISO_8601)); +} +web::json::value ModelBase::toJson( int32_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( int64_t value ) +{ + return web::json::value::number(value); +} +web::json::value ModelBase::toJson( double value ) +{ + return web::json::value::number(value); +} web::json::value ModelBase::toJson(bool value) { - return web::json::value::boolean(value); + return web::json::value::boolean(value); } -web::json::value ModelBase::toJson(std::shared_ptr<HttpContent> content) { - web::json::value value; - value[utility::conversions::to_string_t("ContentDisposition")] = - ModelBase::toJson(content->getContentDisposition()); - value[utility::conversions::to_string_t("ContentType")] = - ModelBase::toJson(content->getContentType()); - value[utility::conversions::to_string_t("FileName")] = - ModelBase::toJson(content->getFileName()); - value[utility::conversions::to_string_t("InputStream")] = - web::json::value::string(ModelBase::toBase64(content->getData())); - return value; +web::json::value ModelBase::toJson( std::shared_ptr<HttpContent> content ) +{ + web::json::value value; + value[utility::conversions::to_string_t("ContentDisposition")] = ModelBase::toJson(content->getContentDisposition()); + value[utility::conversions::to_string_t("ContentType")] = ModelBase::toJson(content->getContentType()); + value[utility::conversions::to_string_t("FileName")] = ModelBase::toJson(content->getFileName()); + value[utility::conversions::to_string_t("InputStream")] = web::json::value::string( ModelBase::toBase64(content->getData()) ); + return value; } -std::shared_ptr<HttpContent> -ModelBase::fileFromJson(const web::json::value &val) { - std::shared_ptr<HttpContent> content(new HttpContent); +std::shared_ptr<HttpContent> ModelBase::fileFromJson(const web::json::value& val) +{ + std::shared_ptr<HttpContent> content(new HttpContent); - if (val.has_field(utility::conversions::to_string_t("ContentDisposition"))) { - content->setContentDisposition(ModelBase::stringFromJson( - val.at(utility::conversions::to_string_t("ContentDisposition")))); - } - if (val.has_field(utility::conversions::to_string_t("ContentType"))) { - content->setContentType(ModelBase::stringFromJson( - val.at(utility::conversions::to_string_t("ContentType")))); - } - if (val.has_field(utility::conversions::to_string_t("FileName"))) { - content->setFileName(ModelBase::stringFromJson( - val.at(utility::conversions::to_string_t("FileName")))); - } - if (val.has_field(utility::conversions::to_string_t("InputStream"))) { - content->setData(ModelBase::fromBase64(ModelBase::stringFromJson( - val.at(utility::conversions::to_string_t("InputStream"))))); - } + if(val.has_field(utility::conversions::to_string_t("ContentDisposition"))) + { + content->setContentDisposition( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentDisposition"))) ); + } + if(val.has_field(utility::conversions::to_string_t("ContentType"))) + { + content->setContentType( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("ContentType"))) ); + } + if(val.has_field(utility::conversions::to_string_t("FileName"))) + { + content->setFileName( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("FileName"))) ); + } + if(val.has_field(utility::conversions::to_string_t("InputStream"))) + { + content->setData( ModelBase::fromBase64( ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("InputStream")))) ); + } - return content; + return content; } -web::json::value ModelBase::toJson(std::shared_ptr<ModelBase> content) { - return content.get() ? content->toJson() : web::json::value::null(); +web::json::value ModelBase::toJson( std::shared_ptr<ModelBase> content ) +{ + return content.get() ? content->toJson() : web::json::value::null(); } -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, - const utility::string_t &value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - content->setData(std::shared_ptr<std::istream>( - new std::stringstream(utility::conversions::to_utf8string(value)))); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, - const utility::datetime &value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - content->setData(std::shared_ptr<std::istream>( - new std::stringstream(utility::conversions::to_utf8string( - value.to_string(utility::datetime::ISO_8601))))); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, - std::shared_ptr<HttpContent> value) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition(value->getContentDisposition()); - content->setContentType(value->getContentType()); - content->setData(value->getData()); - content->setFileName(value->getFileName()); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, - const web::json::value &value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - content->setData(std::shared_ptr<std::istream>(new std::stringstream( - utility::conversions::to_utf8string(value.serialize())))); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, int32_t value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - std::stringstream *valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, int64_t value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - std::stringstream *valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); - return content; -} -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, double value, - const utility::string_t &contentType) { - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - std::stringstream *valueAsStringStream = new std::stringstream(); - (*valueAsStringStream) << value; - content->setData(std::shared_ptr<std::istream>(valueAsStringStream)); - return content; +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType) +{ + std::shared_ptr<HttpContent> content(new HttpContent); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value) ) ) ); + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.to_string(utility::datetime::ISO_8601) ) ) ) ); + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( value->getContentDisposition() ); + content->setContentType( value->getContentType() ); + content->setData( value->getData() ); + content->setFileName( value->getFileName() ); + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(value.serialize()) ) ) ); + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) ); + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr<std::istream>( valueAsStringStream) ) ; + return content; +} +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType ) +{ + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + std::stringstream* valueAsStringStream = new std::stringstream(); + (*valueAsStringStream) << value; + content->setData( std::shared_ptr<std::istream>( valueAsStringStream ) ); + return content; } -// base64 encoding/decoding based on : -// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B -const static char Base64Chars[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +// base64 encoding/decoding based on : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B +const static char Base64Chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const static char Base64PadChar = '='; -utility::string_t ModelBase::toBase64(utility::string_t value) { - std::shared_ptr<std::istream> source( - new std::stringstream(utility::conversions::to_utf8string(value))); - return ModelBase::toBase64(source); -} -utility::string_t ModelBase::toBase64(std::shared_ptr<std::istream> value) { - value->seekg(0, value->end); - size_t length = value->tellg(); - value->seekg(0, value->beg); - utility::string_t base64; - base64.reserve(((length / 3) + (length % 3 > 0)) * 4); - char read[3] = {0}; - uint32_t temp; - for (size_t idx = 0; idx < length / 3; idx++) { - value->read(read, 3); - temp = (read[0]) << 16; - temp += (read[1]) << 8; - temp += (read[2]); - base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); - base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); - base64.append(1, Base64Chars[(temp & 0x00000FC0) >> 6]); - base64.append(1, Base64Chars[(temp & 0x0000003F)]); - } - switch (length % 3) { - case 1: - value->read(read, 1); - temp = read[0] << 16; - base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); - base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); - base64.append(2, Base64PadChar); - break; - case 2: - value->read(read, 2); - temp = read[0] << 16; - temp += read[1] << 8; - base64.append(1, Base64Chars[(temp & 0x00FC0000) >> 18]); - base64.append(1, Base64Chars[(temp & 0x0003F000) >> 12]); - base64.append(1, Base64Chars[(temp & 0x00000FC0) >> 6]); - base64.append(1, Base64PadChar); - break; - } - return base64; +utility::string_t ModelBase::toBase64( utility::string_t value ) +{ + std::shared_ptr<std::istream> source( new std::stringstream( utility::conversions::to_utf8string(value) ) ); + return ModelBase::toBase64(source); +} +utility::string_t ModelBase::toBase64( std::shared_ptr<std::istream> value ) +{ + value->seekg( 0, value->end ); + size_t length = value->tellg(); + value->seekg( 0, value->beg ); + utility::string_t base64; + base64.reserve( ((length / 3) + (length % 3 > 0)) * 4 ); + char read[3] = { 0 }; + uint32_t temp; + for ( size_t idx = 0; idx < length / 3; idx++ ) + { + value->read( read, 3 ); + temp = (read[0]) << 16; + temp += (read[1]) << 8; + temp += (read[2]); + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64Chars[(temp & 0x0000003F)] ); + } + switch ( length % 3 ) + { + case 1: + value->read( read, 1 ); + temp = read[0] << 16; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 2, Base64PadChar ); + break; + case 2: + value->read( read, 2 ); + temp = read[0] << 16; + temp += read[1] << 8; + base64.append( 1, Base64Chars[(temp & 0x00FC0000) >> 18] ); + base64.append( 1, Base64Chars[(temp & 0x0003F000) >> 12] ); + base64.append( 1, Base64Chars[(temp & 0x00000FC0) >> 6] ); + base64.append( 1, Base64PadChar ); + break; + } + return base64; } -std::shared_ptr<std::istream> -ModelBase::fromBase64(const utility::string_t &encoded) { - std::shared_ptr<std::stringstream> result(new std::stringstream); - char outBuf[3] = {0}; - uint32_t temp = 0; +std::shared_ptr<std::istream> ModelBase::fromBase64( const utility::string_t& encoded ) +{ + std::shared_ptr<std::stringstream> result(new std::stringstream); - utility::string_t::const_iterator cursor = encoded.begin(); - while (cursor < encoded.end()) { - for (size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++) { - temp <<= 6; - if (*cursor >= 0x41 && *cursor <= 0x5A) { - temp |= *cursor - 0x41; - } else if (*cursor >= 0x61 && *cursor <= 0x7A) { - temp |= *cursor - 0x47; - } else if (*cursor >= 0x30 && *cursor <= 0x39) { - temp |= *cursor + 0x04; - } else if (*cursor == 0x2B) { - temp |= 0x3E; // change to 0x2D for URL alphabet - } else if (*cursor == 0x2F) { - temp |= 0x3F; // change to 0x5F for URL alphabet - } else if (*cursor == Base64PadChar) // pad - { - switch (encoded.end() - cursor) { - case 1: // One pad character - outBuf[0] = (temp >> 16) & 0x000000FF; - outBuf[1] = (temp >> 8) & 0x000000FF; - result->write(outBuf, 2); - return result; - case 2: // Two pad characters - outBuf[0] = (temp >> 10) & 0x000000FF; - result->write(outBuf, 1); - return result; - default: - throw web::json::json_exception( - utility::conversions::to_string_t("Invalid Padding in Base 64!") - .c_str()); + char outBuf[3] = { 0 }; + uint32_t temp = 0; + + utility::string_t::const_iterator cursor = encoded.begin(); + while ( cursor < encoded.end() ) + { + for ( size_t quantumPosition = 0; quantumPosition < 4; quantumPosition++ ) + { + temp <<= 6; + if ( *cursor >= 0x41 && *cursor <= 0x5A ) + { + temp |= *cursor - 0x41; + } + else if ( *cursor >= 0x61 && *cursor <= 0x7A ) + { + temp |= *cursor - 0x47; + } + else if ( *cursor >= 0x30 && *cursor <= 0x39 ) + { + temp |= *cursor + 0x04; + } + else if ( *cursor == 0x2B ) + { + temp |= 0x3E; //change to 0x2D for URL alphabet + } + else if ( *cursor == 0x2F ) + { + temp |= 0x3F; //change to 0x5F for URL alphabet + } + else if ( *cursor == Base64PadChar ) //pad + { + switch ( encoded.end() - cursor ) + { + case 1: //One pad character + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + result->write( outBuf, 2 ); + return result; + case 2: //Two pad characters + outBuf[0] = (temp >> 10) & 0x000000FF; + result->write( outBuf, 1 ); + return result; + default: + throw web::json::json_exception( utility::conversions::to_string_t( "Invalid Padding in Base 64!" ).c_str() ); + } + } + else + { + throw web::json::json_exception( utility::conversions::to_string_t( "Non-Valid Character in Base 64!" ).c_str() ); + } + ++cursor; } - } else { - throw web::json::json_exception( - utility::conversions::to_string_t("Non-Valid Character in Base 64!") - .c_str()); - } - ++cursor; - } - outBuf[0] = (temp >> 16) & 0x000000FF; - outBuf[1] = (temp >> 8) & 0x000000FF; - outBuf[2] = (temp)&0x000000FF; - result->write(outBuf, 3); - } + outBuf[0] = (temp >> 16) & 0x000000FF; + outBuf[1] = (temp >> 8) & 0x000000FF; + outBuf[2] = (temp) & 0x000000FF; + result->write( outBuf, 3 ); + } - return result; + return result; } -int64_t ModelBase::int64_tFromJson(const web::json::value &val) { - return val.as_number().to_int64(); +int64_t ModelBase::int64_tFromJson(const web::json::value& val) +{ + return val.as_number().to_int64(); } -int32_t ModelBase::int32_tFromJson(const web::json::value &val) { - return val.as_integer(); +int32_t ModelBase::int32_tFromJson(const web::json::value& val) +{ + return val.as_integer(); } -float ModelBase::floatFromJson(const web::json::value &val) { - return static_cast<float>(val.as_double()); +float ModelBase::floatFromJson(const web::json::value& val) +{ + return static_cast<float>(val.as_double()); } -utility::string_t ModelBase::stringFromJson(const web::json::value &val) { - return val.is_string() ? val.as_string() - : utility::conversions::to_string_t(""); +utility::string_t ModelBase::stringFromJson(const web::json::value& val) +{ + return val.is_string() ? val.as_string() : utility::conversions::to_string_t(""); } -utility::datetime ModelBase::dateFromJson(const web::json::value &val) { - return utility::datetime::from_string(val.as_string(), - utility::datetime::ISO_8601); +utility::datetime ModelBase::dateFromJson(const web::json::value& val) +{ + return utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601); } -bool ModelBase::boolFromJson(const web::json::value &val) { - return val.as_bool(); +bool ModelBase::boolFromJson(const web::json::value& val) +{ + return val.as_bool(); } -double ModelBase::doubleFromJson(const web::json::value &val) { - return val.as_double(); +double ModelBase::doubleFromJson(const web::json::value& val) +{ + return val.as_double(); } -int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); +int64_t ModelBase::int64_tFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - int64_t result = 0; - ss >> result; - return result; -} -int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); + utility::stringstream_t ss(str); + int64_t result = 0; + ss >> result; + return result; +} +int32_t ModelBase::int32_tFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - int32_t result = 0; - ss >> result; - return result; -} -float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); + utility::stringstream_t ss(str); + int32_t result = 0; + ss >> result; + return result; +} +float ModelBase::floatFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - float result = 0; - ss >> result; - return result; -} -utility::string_t -ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val) { - std::shared_ptr<std::istream> data = val->getData(); - data->seekg(0, data->beg); + utility::stringstream_t ss(str); + float result = 0; + ss >> result; + return result; +} +utility::string_t ModelBase::stringFromHttpContent(std::shared_ptr<HttpContent> val) +{ + std::shared_ptr<std::istream> data = val->getData(); + data->seekg( 0, data->beg ); - std::string str((std::istreambuf_iterator<char>(*data.get())), - std::istreambuf_iterator<char>()); + std::string str((std::istreambuf_iterator<char>(*data.get())), + std::istreambuf_iterator<char>()); - return utility::conversions::to_string_t(str); + return utility::conversions::to_string_t(str); } -utility::datetime -ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); - return utility::datetime::from_string(str, utility::datetime::ISO_8601); +utility::datetime ModelBase::dateFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + return utility::datetime::from_string(str, utility::datetime::ISO_8601); } -bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); +bool ModelBase::boolFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - bool result = false; - ss >> result; - return result; -} -double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); + utility::stringstream_t ss(str); + bool result = false; + ss >> result; + return result; +} +double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); - utility::stringstream_t ss(str); - double result = 0.0; - ss >> result; - return result; + utility::stringstream_t ss(str); + double result = 0.0; + ss >> result; + return result; } -web::json::value -ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val) { - utility::string_t str = ModelBase::stringFromHttpContent(val); - return web::json::value::parse(str); +web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val) +{ + utility::string_t str = ModelBase::stringFromHttpContent(val); + return web::json::value::parse(str); } -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.h b/samples/client/petstore/cpp-restsdk/ModelBase.h index b37d7963f9d..e35de11673e 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/ModelBase.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ + #include "HttpContent.h" #include "MultipartFormData.h" @@ -32,121 +32,89 @@ namespace openapitools { namespace client { namespace model { -class ModelBase { +class ModelBase +{ public: - ModelBase(); - virtual ~ModelBase(); - - virtual void validate() = 0; - - virtual web::json::value toJson() const = 0; - virtual void fromJson(const web::json::value &json) = 0; - - virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const = 0; - virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) = 0; - - static web::json::value toJson(const utility::string_t &value); - static web::json::value toJson(const utility::datetime &value); - static web::json::value toJson(std::shared_ptr<HttpContent> value); - static web::json::value toJson(std::shared_ptr<ModelBase> value); - static web::json::value toJson(int32_t value); - static web::json::value toJson(int64_t value); - static web::json::value toJson(double value); - static web::json::value toJson(bool value); - template <class T> - static web::json::value toJson(const std::vector<T> &value); - - static int64_t int64_tFromJson(const web::json::value &val); - static int32_t int32_tFromJson(const web::json::value &val); - static float floatFromJson(const web::json::value &val); - static utility::string_t stringFromJson(const web::json::value &val); - static utility::datetime dateFromJson(const web::json::value &val); - static double doubleFromJson(const web::json::value &val); - static bool boolFromJson(const web::json::value &val); - static std::shared_ptr<HttpContent> fileFromJson(const web::json::value &val); - - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, const utility::string_t &value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, const utility::datetime &value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, - std::shared_ptr<HttpContent> value); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, const web::json::value &value, - const utility::string_t &contentType = - utility::conversions::to_string_t("application/json")); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, int32_t value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, int64_t value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, double value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - template <class T> - static std::shared_ptr<HttpContent> - toHttpContent(const utility::string_t &name, const std::vector<T> &value, - const utility::string_t &contentType = - utility::conversions::to_string_t("")); - - static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val); - static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val); - static float floatFromHttpContent(std::shared_ptr<HttpContent> val); - static utility::string_t - stringFromHttpContent(std::shared_ptr<HttpContent> val); - static utility::datetime - dateFromHttpContent(std::shared_ptr<HttpContent> val); - static bool boolFromHttpContent(std::shared_ptr<HttpContent> val); - static double doubleFromHttpContent(std::shared_ptr<HttpContent> val); - static web::json::value - valueFromHttpContent(std::shared_ptr<HttpContent> val); - - static utility::string_t toBase64(utility::string_t value); - static utility::string_t toBase64(std::shared_ptr<std::istream> value); - static std::shared_ptr<std::istream> - fromBase64(const utility::string_t &encoded); + ModelBase(); + virtual ~ModelBase(); + + virtual void validate() = 0; + + virtual web::json::value toJson() const = 0; + virtual void fromJson(const web::json::value& json) = 0; + + virtual void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const = 0; + virtual void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) = 0; + + static web::json::value toJson( const utility::string_t& value ); + static web::json::value toJson( const utility::datetime& value ); + static web::json::value toJson( std::shared_ptr<HttpContent> value ); + static web::json::value toJson( std::shared_ptr<ModelBase> value ); + static web::json::value toJson( int32_t value ); + static web::json::value toJson( int64_t value ); + static web::json::value toJson( double value ); + static web::json::value toJson( bool value ); + template<class T> + static web::json::value toJson(const std::vector<T>& value); + + static int64_t int64_tFromJson(const web::json::value& val); + static int32_t int32_tFromJson(const web::json::value& val); + static float floatFromJson(const web::json::value& val); + static utility::string_t stringFromJson(const web::json::value& val); + static utility::datetime dateFromJson(const web::json::value& val); + static double doubleFromJson(const web::json::value& val); + static bool boolFromJson(const web::json::value& val); + static std::shared_ptr<HttpContent> fileFromJson(const web::json::value& val); + + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = utility::conversions::to_string_t("")); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, std::shared_ptr<HttpContent> value ); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const web::json::value& value, const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + template <class T> + static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); + + static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val); + static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val); + static float floatFromHttpContent(std::shared_ptr<HttpContent> val); + static utility::string_t stringFromHttpContent(std::shared_ptr<HttpContent> val); + static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val); + static bool boolFromHttpContent(std::shared_ptr<HttpContent> val); + static double doubleFromHttpContent(std::shared_ptr<HttpContent> val); + static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val); + + + static utility::string_t toBase64( utility::string_t value ); + static utility::string_t toBase64( std::shared_ptr<std::istream> value ); + static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded ); }; -template <class T> -web::json::value ModelBase::toJson(const std::vector<T> &value) { - std::vector<web::json::value> ret; - for (auto &x : value) { - ret.push_back(toJson(x)); - } +template<class T> +web::json::value ModelBase::toJson(const std::vector<T>& value) { + std::vector<web::json::value> ret; + for (auto& x : value) { + ret.push_back(toJson(x)); + } - return web::json::value::array(ret); + return web::json::value::array(ret); } template <class T> -std::shared_ptr<HttpContent> -ModelBase::toHttpContent(const utility::string_t &name, - const std::vector<T> &value, - const utility::string_t &contentType) { - web::json::value json_array = ModelBase::toJson(value); - std::shared_ptr<HttpContent> content(new HttpContent); - content->setName(name); - content->setContentDisposition( - utility::conversions::to_string_t("form-data")); - content->setContentType(contentType); - content->setData(std::shared_ptr<std::istream>(new std::stringstream( - utility::conversions::to_utf8string(json_array.serialize())))); - return content; +std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType ) { + web::json::value json_array = ModelBase::toJson(value); + std::shared_ptr<HttpContent> content( new HttpContent ); + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); + return content; } -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp index 2475bc915d3..009c333ff06 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -21,86 +20,93 @@ namespace openapitools { namespace client { namespace model { -MultipartFormData::MultipartFormData() { - utility::stringstream_t uuidString; - uuidString << boost::uuids::random_generator()(); - m_Boundary = uuidString.str(); +MultipartFormData::MultipartFormData() +{ + utility::stringstream_t uuidString; + uuidString << boost::uuids::random_generator()(); + m_Boundary = uuidString.str(); } -MultipartFormData::MultipartFormData(const utility::string_t &boundary) - : m_Boundary(boundary) {} +MultipartFormData::MultipartFormData(const utility::string_t& boundary) + : m_Boundary(boundary) +{ -MultipartFormData::~MultipartFormData() {} +} -utility::string_t MultipartFormData::getBoundary() { return m_Boundary; } +MultipartFormData::~MultipartFormData() +{ +} -void MultipartFormData::add(std::shared_ptr<HttpContent> content) { - m_Contents.push_back(content); - m_ContentLookup[content->getName()] = content; +utility::string_t MultipartFormData::getBoundary() +{ + return m_Boundary; } -bool MultipartFormData::hasContent(const utility::string_t &name) const { - return m_ContentLookup.find(name) != m_ContentLookup.end(); +void MultipartFormData::add( std::shared_ptr<HttpContent> content ) +{ + m_Contents.push_back( content ); + m_ContentLookup[content->getName()] = content; } -std::shared_ptr<HttpContent> -MultipartFormData::getContent(const utility::string_t &name) const { - auto result = m_ContentLookup.find(name); - if (result == m_ContentLookup.end()) { - return std::shared_ptr<HttpContent>(nullptr); - } - return result->second; +bool MultipartFormData::hasContent(const utility::string_t& name) const +{ + return m_ContentLookup.find(name) != m_ContentLookup.end(); } -void MultipartFormData::writeTo(std::ostream &target) { - for (size_t i = 0; i < m_Contents.size(); i++) { - std::shared_ptr<HttpContent> content = m_Contents[i]; - - // boundary - target << "\r\n" - << "--" << utility::conversions::to_utf8string(m_Boundary) << "\r\n"; - - // headers - target << "Content-Disposition: " - << utility::conversions::to_utf8string( - content->getContentDisposition()); - if (content->getName().size() > 0) { - target << "; name=\"" - << utility::conversions::to_utf8string(content->getName()) << "\""; +std::shared_ptr<HttpContent> MultipartFormData::getContent(const utility::string_t& name) const +{ + auto result = m_ContentLookup.find(name); + if(result == m_ContentLookup.end()) + { + return std::shared_ptr<HttpContent>(nullptr); } - if (content->getFileName().size() > 0) { - target << "; filename=\"" - << utility::conversions::to_utf8string(content->getFileName()) - << "\""; - } - target << "\r\n"; + return result->second; +} - if (content->getContentType().size() > 0) { - target << "Content-Type: " - << utility::conversions::to_utf8string(content->getContentType()) - << "\r\n"; +void MultipartFormData::writeTo( std::ostream& target ) +{ + for ( size_t i = 0; i < m_Contents.size(); i++ ) + { + std::shared_ptr<HttpContent> content = m_Contents[i]; + + // boundary + target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n"; + + // headers + target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() ); + if ( content->getName().size() > 0 ) + { + target << "; name=\"" << utility::conversions::to_utf8string( content->getName() ) << "\""; + } + if ( content->getFileName().size() > 0 ) + { + target << "; filename=\"" << utility::conversions::to_utf8string( content->getFileName() ) << "\""; + } + target << "\r\n"; + + if ( content->getContentType().size() > 0 ) + { + target << "Content-Type: " << utility::conversions::to_utf8string( content->getContentType() ) << "\r\n"; + } + + target << "\r\n"; + + // body + std::shared_ptr<std::istream> data = content->getData(); + + data->seekg( 0, data->end ); + std::vector<char> dataBytes( data->tellg() ); + + data->seekg( 0, data->beg ); + data->read( &dataBytes[0], dataBytes.size() ); + + std::copy( dataBytes.begin(), dataBytes.end(), std::ostreambuf_iterator<char>( target ) ); } - target << "\r\n"; - - // body - std::shared_ptr<std::istream> data = content->getData(); - - data->seekg(0, data->end); - std::vector<char> dataBytes(data->tellg()); - - data->seekg(0, data->beg); - data->read(&dataBytes[0], dataBytes.size()); - - std::copy(dataBytes.begin(), dataBytes.end(), - std::ostreambuf_iterator<char>(target)); - } - - target << "\r\n--" << utility::conversions::to_utf8string(m_Boundary) - << "--\r\n"; + target << "\r\n--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n"; } -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/MultipartFormData.h index 2794b30a84d..50e8216f67a 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.h +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -13,49 +12,51 @@ /* * MultipartFormData.h * - * This class represents a container for building - * application/x-multipart-formdata requests. + * This class represents a container for building application/x-multipart-formdata requests. */ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ -#include "HttpContent.h" + #include "IHttpBody.h" +#include "HttpContent.h" +#include <vector> #include <map> #include <memory> -#include <vector> #include <cpprest/details/basic_types.h> + namespace org { namespace openapitools { namespace client { namespace model { -class MultipartFormData : public IHttpBody { +class MultipartFormData + : public IHttpBody +{ public: - MultipartFormData(); - MultipartFormData(const utility::string_t &boundary); - virtual ~MultipartFormData(); + MultipartFormData(); + MultipartFormData(const utility::string_t& boundary); + virtual ~MultipartFormData(); - virtual void add(std::shared_ptr<HttpContent> content); - virtual utility::string_t getBoundary(); - virtual std::shared_ptr<HttpContent> - getContent(const utility::string_t &name) const; - virtual bool hasContent(const utility::string_t &name) const; - virtual void writeTo(std::ostream &target); + virtual void add( std::shared_ptr<HttpContent> content ); + virtual utility::string_t getBoundary(); + virtual std::shared_ptr<HttpContent> getContent(const utility::string_t& name) const; + virtual bool hasContent(const utility::string_t& name) const; + virtual void writeTo( std::ostream& target ); protected: - std::vector<std::shared_ptr<HttpContent>> m_Contents; - utility::string_t m_Boundary; - std::map<utility::string_t, std::shared_ptr<HttpContent>> m_ContentLookup; + std::vector<std::shared_ptr<HttpContent>> m_Contents; + utility::string_t m_Boundary; + std::map<utility::string_t, std::shared_ptr<HttpContent>> m_ContentLookup; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/Object.cpp b/samples/client/petstore/cpp-restsdk/Object.cpp index 7b510f78274..4edce53d791 100644 --- a/samples/client/petstore/cpp-restsdk/Object.cpp +++ b/samples/client/petstore/cpp-restsdk/Object.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -17,55 +16,66 @@ namespace openapitools { namespace client { namespace model { -Object::Object() { m_object = web::json::value::object(); } +Object::Object() +{ + m_object = web::json::value::object(); +} -Object::~Object() {} +Object::~Object() +{ +} -void Object::validate() { - // TODO: implement validation +void Object::validate() +{ + // TODO: implement validation } -web::json::value Object::toJson() const { return m_object; } +web::json::value Object::toJson() const +{ + return m_object; +} -void Object::fromJson(const web::json::value &val) { - if (val.is_object()) { - m_object = val; - } +void Object::fromJson(const web::json::value& val) +{ + if (val.is_object()) + { + m_object = val; + } } -void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("object"), m_object)); +void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object)); } -void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } - m_object = ModelBase::valueFromHttpContent(multipart->getContent( - namePrefix + utility::conversions::to_string_t("object"))); + m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object"))); } -web::json::value Object::getValue(const utility::string_t &key) const { - return m_object.at(key); +web::json::value Object::getValue(const utility::string_t& key) const +{ + return m_object.at(key); } -void Object::setValue(const utility::string_t &key, - const web::json::value &value) { - m_object[key] = value; + +void Object::setValue(const utility::string_t& key, const web::json::value& value) +{ + m_object[key] = value; } -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} diff --git a/samples/client/petstore/cpp-restsdk/Object.h b/samples/client/petstore/cpp-restsdk/Object.h index b2c848a955a..1944f397bda 100644 --- a/samples/client/petstore/cpp-restsdk/Object.h +++ b/samples/client/petstore/cpp-restsdk/Object.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ + #include "ModelBase.h" #include <cpprest/details/basic_types.h> @@ -29,35 +29,34 @@ namespace openapitools { namespace client { namespace model { -class Object : public ModelBase { +class Object : public ModelBase +{ public: - Object(); - virtual ~Object(); + Object(); + virtual ~Object(); - ///////////////////////////////////////////// - /// ModelBase overrides - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides + void validate() override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - ///////////////////////////////////////////// - /// Object manipulation - web::json::value getValue(const utility::string_t &key) const; - void setValue(const utility::string_t &key, const web::json::value &value); + ///////////////////////////////////////////// + /// Object manipulation + web::json::value getValue(const utility::string_t& key) const; + void setValue(const utility::string_t& key, const web::json::value& value); private: - web::json::value m_object; + web::json::value m_object; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index e1520d312ae..63c11ca9b44 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,7 @@ * Do not edit the class manually. */ + #include "PetApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,1178 +26,963 @@ namespace api { using namespace org::openapitools::client::model; -PetApi::PetApi(std::shared_ptr<ApiClient> apiClient) : m_ApiClient(apiClient) {} - -PetApi::~PetApi() {} - -pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> pet) { - - // verify the required parameter 'pet' is set - if (pet == nullptr) { - throw ApiException( - 400, - utility::conversions::to_string_t( - "Missing required parameter 'pet' when calling PetApi->addPet")); - } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, utility::conversions::to_string_t( - "PetApi->addPet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(pet); - - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if (pet.get()) { - pet->toMultipart(localVarMultipart, - utility::conversions::to_string_t("pet")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException( - 415, utility::conversions::to_string_t( - "PetApi->addPet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +PetApi::PetApi( std::shared_ptr<ApiClient> apiClient ) + : m_ApiClient(apiClient) +{ +} + +PetApi::~PetApi() +{ +} + +pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> pet) +{ + + // verify the required parameter 'pet' is set + if (pet == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->addPet")); + } + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->addPet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if(pet.get()) + { + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->addPet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling addPet: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling addPet: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling addPet: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling addPet: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> PetApi::deletePet(int64_t petId, - boost::optional<utility::string_t> apiKey) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("petId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "PetApi->deletePet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - if (apiKey) { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = - ApiClient::parameterToString(*apiKey); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "PetApi->deletePet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<void> PetApi::deletePet(int64_t petId, boost::optional<utility::string_t> apiKey) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->deletePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + if (apiKey) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = ApiClient::parameterToString(*apiKey); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->deletePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling deletePet: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deletePet: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling deletePet: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deletePet: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<std::vector<std::shared_ptr<Pet>>> -PetApi::findPetsByStatus(std::vector<utility::string_t> status) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/findByStatus"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "PetApi->findPetsByStatus does not produce any " - "supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("status")] = - ApiClient::parameterToString(status); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "PetApi->findPetsByStatus does not consume any " - "supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vector<utility::string_t> status) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByStatus"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByStatus does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("status")] = ApiClient::parameterToString(status); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByStatus does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling findPetsByStatus: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByStatus: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling findPetsByStatus: unexpected response " - "type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByStatus: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::vector<std::shared_ptr<Pet>> localVarResult; - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); - - for (auto &localVarItem : localVarJson.as_array()) { - std::shared_ptr<Pet> localVarItemObj(new Pet()); - localVarItemObj->fromJson(localVarItem); - localVarResult.push_back(localVarItemObj); - } - + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + for( auto& localVarItem : localVarJson.as_array() ) + { + std::shared_ptr<Pet> localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); + + } + } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling findPetsByStatus: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByStatus: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::vector<std::shared_ptr<Pet>>> -PetApi::findPetsByTags(std::vector<utility::string_t> tags) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/findByTags"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "PetApi->findPetsByTags does not produce any " - "supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("tags")] = - ApiClient::parameterToString(tags); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "PetApi->findPetsByTags does not consume any " - "supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector<utility::string_t> tags) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByTags"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByTags does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("tags")] = ApiClient::parameterToString(tags); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByTags does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling findPetsByTags: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByTags: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling findPetsByTags: unexpected response " - "type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByTags: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::vector<std::shared_ptr<Pet>> localVarResult; - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); - - for (auto &localVarItem : localVarJson.as_array()) { - std::shared_ptr<Pet> localVarItemObj(new Pet()); - localVarItemObj->fromJson(localVarItem); - localVarResult.push_back(localVarItemObj); - } - + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + + for( auto& localVarItem : localVarJson.as_array() ) + { + std::shared_ptr<Pet> localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); + + } + } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling findPetsByTags: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling findPetsByTags: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("petId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "PetApi->getPetById does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "PetApi->getPetById does not consume any supported media type")); - } - - // authentication (api_key) required - { - utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey( - utility::conversions::to_string_t("api_key")); - if (localVarApiKey.size() > 0) { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = - localVarApiKey; - } - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->getPetById does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->getPetById does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling getPetById: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getPetById: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getPetById: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getPetById: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::shared_ptr<Pet> localVarResult(new Pet()); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, utility::conversions::to_string_t( - "error calling getPetById: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getPetById: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> pet) { - - // verify the required parameter 'pet' is set - if (pet == nullptr) { - throw ApiException( - 400, - utility::conversions::to_string_t( - "Missing required parameter 'pet' when calling PetApi->updatePet")); - } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "PetApi->updatePet does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(pet); - - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if (pet.get()) { - pet->toMultipart(localVarMultipart, - utility::conversions::to_string_t("pet")); - } - - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "PetApi->updatePet does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("PUT"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> pet) +{ + + // verify the required parameter 'pet' is set + if (pet == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'pet' when calling PetApi->updatePet")); + } + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePet does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(pet); + + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if(pet.get()) + { + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePet does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling updatePet: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePet: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling updatePet: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updatePet: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> -PetApi::updatePetWithForm(int64_t petId, - boost::optional<utility::string_t> name, - boost::optional<utility::string_t> status) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("petId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "PetApi->updatePetWithForm does not produce " - "any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("application/x-www-form-urlencoded")); - - if (name) { - localVarFormParams[utility::conversions::to_string_t("name")] = - ApiClient::parameterToString(*name); - } - if (status) { - localVarFormParams[utility::conversions::to_string_t("status")] = - ApiClient::parameterToString(*status); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "PetApi->updatePetWithForm does not consume " - "any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<void> PetApi::updatePetWithForm(int64_t petId, boost::optional<utility::string_t> name, boost::optional<utility::string_t> status) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePetWithForm does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/x-www-form-urlencoded") ); + + if (name) + { + localVarFormParams[ utility::conversions::to_string_t("name") ] = ApiClient::parameterToString(*name); + } + if (status) + { + localVarFormParams[ utility::conversions::to_string_t("status") ] = ApiClient::parameterToString(*status); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePetWithForm does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling updatePetWithForm: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePetWithForm: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling updatePetWithForm: unexpected response " - "type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updatePetWithForm: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<std::shared_ptr<ApiResponse>> -PetApi::uploadFile(int64_t petId, - boost::optional<utility::string_t> additionalMetadata, - boost::optional<std::shared_ptr<HttpContent>> file) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/pet/{petId}/uploadImage"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("petId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(petId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "PetApi->uploadFile does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - localVarConsumeHttpContentTypes.insert( - utility::conversions::to_string_t("multipart/form-data")); - - if (additionalMetadata) { - localVarFormParams[utility::conversions::to_string_t( - "additionalMetadata")] = - ApiClient::parameterToString(*additionalMetadata); - } - if (file && *file != nullptr) { - localVarFileParams[utility::conversions::to_string_t("file")] = *file; - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "PetApi->uploadFile does not consume any supported media type")); - } - - // authentication (petstore_auth) required - // oauth2 authentication is added automatically as part of the - // http_client_config - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, boost::optional<utility::string_t> additionalMetadata, boost::optional<std::shared_ptr<HttpContent>> file) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}/uploadImage"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("PetApi->uploadFile does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") ); + + if (additionalMetadata) + { + localVarFormParams[ utility::conversions::to_string_t("additionalMetadata") ] = ApiClient::parameterToString(*additionalMetadata); + } + if (file && *file != nullptr) + { + localVarFileParams[ utility::conversions::to_string_t("file") ] = *file; + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("PetApi->uploadFile does not consume any supported media type")); + } + + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling uploadFile: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling uploadFile: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling uploadFile: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling uploadFile: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::shared_ptr<ApiResponse> localVarResult(new ApiResponse()); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, utility::conversions::to_string_t( - "error calling uploadFile: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling uploadFile: unsupported response type")); } return localVarResult; - }); + }); +} + +} +} +} } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h index 0e275040639..81662ef543a 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.h +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -13,12 +12,13 @@ /* * PetApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ + #include "../ApiClient.h" #include "ApiResponse.h" @@ -26,6 +26,7 @@ #include "Pet.h" #include <cpprest/details/basic_types.h> + #include <boost/optional.hpp> namespace org { @@ -35,105 +36,115 @@ namespace api { using namespace org::openapitools::client::model; -class PetApi { + + +class PetApi +{ public: - explicit PetApi(std::shared_ptr<ApiClient> apiClient); - - virtual ~PetApi(); - - /// <summary> - /// Add a new pet to the store - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="pet">Pet object that needs to be added to the store</param> - pplx::task<void> addPet(std::shared_ptr<Pet> pet); - /// <summary> - /// Deletes a pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">Pet id to delete</param> - /// <param name="apiKey"> (optional, default to - /// utility::conversions::to_string_t(""))</param> - pplx::task<void> deletePet(int64_t petId, - boost::optional<utility::string_t> apiKey); - /// <summary> - /// Finds Pets by status - /// </summary> - /// <remarks> - /// Multiple status values can be provided with comma separated strings - /// </remarks> - /// <param name="status">Status values that need to be considered for - /// filter</param> - pplx::task<std::vector<std::shared_ptr<Pet>>> - findPetsByStatus(std::vector<utility::string_t> status); - /// <summary> - /// Finds Pets by tags - /// </summary> - /// <remarks> - /// Multiple tags can be provided with comma separated strings. Use tag1, - /// tag2, tag3 for testing. - /// </remarks> - /// <param name="tags">Tags to filter by</param> - pplx::task<std::vector<std::shared_ptr<Pet>>> - findPetsByTags(std::vector<utility::string_t> tags); - /// <summary> - /// Find pet by ID - /// </summary> - /// <remarks> - /// Returns a single pet - /// </remarks> - /// <param name="petId">ID of pet to return</param> - pplx::task<std::shared_ptr<Pet>> getPetById(int64_t petId); - /// <summary> - /// Update an existing pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="pet">Pet object that needs to be added to the store</param> - pplx::task<void> updatePet(std::shared_ptr<Pet> pet); - /// <summary> - /// Updates a pet in the store with form data - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">ID of pet that needs to be updated</param> - /// <param name="name">Updated name of the pet (optional, default to - /// utility::conversions::to_string_t(""))</param> <param - /// name="status">Updated status of the pet (optional, default to - /// utility::conversions::to_string_t(""))</param> - pplx::task<void> updatePetWithForm(int64_t petId, - boost::optional<utility::string_t> name, - boost::optional<utility::string_t> status); - /// <summary> - /// uploads an image - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="petId">ID of pet to update</param> - /// <param name="additionalMetadata">Additional data to pass to server - /// (optional, default to - /// utility::conversions::to_string_t(""))</param> <param - /// name="file">file to upload (optional, default to - /// utility::conversions::to_string_t(""))</param> - pplx::task<std::shared_ptr<ApiResponse>> - uploadFile(int64_t petId, - boost::optional<utility::string_t> additionalMetadata, - boost::optional<std::shared_ptr<HttpContent>> file); + + explicit PetApi( std::shared_ptr<ApiClient> apiClient ); + + virtual ~PetApi(); + + /// <summary> + /// Add a new pet to the store + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="pet">Pet object that needs to be added to the store</param> + pplx::task<void> addPet( + std::shared_ptr<Pet> pet + ); + /// <summary> + /// Deletes a pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">Pet id to delete</param> + /// <param name="apiKey"> (optional, default to utility::conversions::to_string_t(""))</param> + pplx::task<void> deletePet( + int64_t petId, + boost::optional<utility::string_t> apiKey + ); + /// <summary> + /// Finds Pets by status + /// </summary> + /// <remarks> + /// Multiple status values can be provided with comma separated strings + /// </remarks> + /// <param name="status">Status values that need to be considered for filter</param> + pplx::task<std::vector<std::shared_ptr<Pet>>> findPetsByStatus( + std::vector<utility::string_t> status + ); + /// <summary> + /// Finds Pets by tags + /// </summary> + /// <remarks> + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + /// </remarks> + /// <param name="tags">Tags to filter by</param> + pplx::task<std::vector<std::shared_ptr<Pet>>> findPetsByTags( + std::vector<utility::string_t> tags + ); + /// <summary> + /// Find pet by ID + /// </summary> + /// <remarks> + /// Returns a single pet + /// </remarks> + /// <param name="petId">ID of pet to return</param> + pplx::task<std::shared_ptr<Pet>> getPetById( + int64_t petId + ); + /// <summary> + /// Update an existing pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="pet">Pet object that needs to be added to the store</param> + pplx::task<void> updatePet( + std::shared_ptr<Pet> pet + ); + /// <summary> + /// Updates a pet in the store with form data + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">ID of pet that needs to be updated</param> + /// <param name="name">Updated name of the pet (optional, default to utility::conversions::to_string_t(""))</param> + /// <param name="status">Updated status of the pet (optional, default to utility::conversions::to_string_t(""))</param> + pplx::task<void> updatePetWithForm( + int64_t petId, + boost::optional<utility::string_t> name, + boost::optional<utility::string_t> status + ); + /// <summary> + /// uploads an image + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="petId">ID of pet to update</param> + /// <param name="additionalMetadata">Additional data to pass to server (optional, default to utility::conversions::to_string_t(""))</param> + /// <param name="file">file to upload (optional, default to utility::conversions::to_string_t(""))</param> + pplx::task<std::shared_ptr<ApiResponse>> uploadFile( + int64_t petId, + boost::optional<utility::string_t> additionalMetadata, + boost::optional<std::shared_ptr<HttpContent>> file + ); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index 0687e1ac70c..36f501f54b6 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,7 @@ * Do not edit the class manually. */ + #include "StoreApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,585 +26,489 @@ namespace api { using namespace org::openapitools::client::model; -StoreApi::StoreApi(std::shared_ptr<ApiClient> apiClient) - : m_ApiClient(apiClient) {} - -StoreApi::~StoreApi() {} - -pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("orderId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(orderId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "StoreApi->deleteOrder does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "StoreApi->deleteOrder does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +StoreApi::StoreApi( std::shared_ptr<ApiClient> apiClient ) + : m_ApiClient(apiClient) +{ +} + +StoreApi::~StoreApi() +{ +} + +pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->deleteOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->deleteOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling deleteOrder: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteOrder: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling deleteOrder: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deleteOrder: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/store/inventory"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "StoreApi->getInventory does not produce any " - "supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "StoreApi->getInventory does not consume any " - "supported media type")); - } - - // authentication (api_key) required - { - utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey( - utility::conversions::to_string_t("api_key")); - if (localVarApiKey.size() > 0) { - localVarHeaderParams[utility::conversions::to_string_t("api_key")] = - localVarApiKey; +pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/inventory"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->getInventory does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->getInventory does not consume any supported media type")); + } + + // authentication (api_key) required + { + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) + { + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; + } + } + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling getInventory: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getInventory: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getInventory: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getInventory: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::map<utility::string_t, int32_t> localVarResult; - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); - - for (auto &localVarItem : localVarJson.as_object()) { - localVarResult[localVarItem.first] = - ModelBase::int32_tFromJson(localVarItem.second); - } + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); + for( auto& localVarItem : localVarJson.as_object() ) + { + localVarResult[localVarItem.first] = ModelBase::int32_tFromJson(localVarItem.second); + + } + } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getInventory: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getInventory: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("orderId") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(orderId)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "StoreApi->getOrderById does not produce any " - "supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "StoreApi->getOrderById does not consume any " - "supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->getOrderById does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->getOrderById does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling getOrderById: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getOrderById: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getOrderById: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getOrderById: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::shared_ptr<Order> localVarResult(new Order()); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getOrderById: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getOrderById: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<std::shared_ptr<Order>> -StoreApi::placeOrder(std::shared_ptr<Order> order) { - - // verify the required parameter 'order' is set - if (order == nullptr) { - throw ApiException(400, utility::conversions::to_string_t( - "Missing required parameter 'order' when " - "calling StoreApi->placeOrder")); - } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/store/order"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "StoreApi->placeOrder does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(order); - - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if (order.get()) { - order->toMultipart(localVarMultipart, - utility::conversions::to_string_t("order")); +pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> order) +{ + + // verify the required parameter 'order' is set + if (order == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'order' when calling StoreApi->placeOrder")); } - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "StoreApi->placeOrder does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("StoreApi->placeOrder does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(order); + + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if(order.get()) + { + order->toMultipart(localVarMultipart, utility::conversions::to_string_t("order")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("StoreApi->placeOrder does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling placeOrder: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling placeOrder: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling placeOrder: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling placeOrder: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::shared_ptr<Order> localVarResult(new Order()); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, utility::conversions::to_string_t( - "error calling placeOrder: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling placeOrder: unsupported response type")); } return localVarResult; - }); + }); +} + +} +} +} } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h index c51d2eb13ec..1c609872c38 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -13,17 +12,19 @@ /* * StoreApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ + #include "../ApiClient.h" #include "Order.h" -#include <cpprest/details/basic_types.h> #include <map> +#include <cpprest/details/basic_types.h> + #include <boost/optional.hpp> @@ -34,53 +35,63 @@ namespace api { using namespace org::openapitools::client::model; -class StoreApi { + + +class StoreApi +{ public: - explicit StoreApi(std::shared_ptr<ApiClient> apiClient); - - virtual ~StoreApi(); - - /// <summary> - /// Delete purchase order by ID - /// </summary> - /// <remarks> - /// For valid response try integer IDs with value < 1000. Anything above - /// 1000 or nonintegers will generate API errors - /// </remarks> - /// <param name="orderId">ID of the order that needs to be deleted</param> - pplx::task<void> deleteOrder(utility::string_t orderId); - /// <summary> - /// Returns pet inventories by status - /// </summary> - /// <remarks> - /// Returns a map of status codes to quantities - /// </remarks> - pplx::task<std::map<utility::string_t, int32_t>> getInventory(); - /// <summary> - /// Find purchase order by ID - /// </summary> - /// <remarks> - /// For valid response try integer IDs with value <= 5 or > 10. - /// Other values will generated exceptions - /// </remarks> - /// <param name="orderId">ID of pet that needs to be fetched</param> - pplx::task<std::shared_ptr<Order>> getOrderById(int64_t orderId); - /// <summary> - /// Place an order for a pet - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="order">order placed for purchasing the pet</param> - pplx::task<std::shared_ptr<Order>> placeOrder(std::shared_ptr<Order> order); + + explicit StoreApi( std::shared_ptr<ApiClient> apiClient ); + + virtual ~StoreApi(); + + /// <summary> + /// Delete purchase order by ID + /// </summary> + /// <remarks> + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// </remarks> + /// <param name="orderId">ID of the order that needs to be deleted</param> + pplx::task<void> deleteOrder( + utility::string_t orderId + ); + /// <summary> + /// Returns pet inventories by status + /// </summary> + /// <remarks> + /// Returns a map of status codes to quantities + /// </remarks> + pplx::task<std::map<utility::string_t, int32_t>> getInventory( + ); + /// <summary> + /// Find purchase order by ID + /// </summary> + /// <remarks> + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// </remarks> + /// <param name="orderId">ID of pet that needs to be fetched</param> + pplx::task<std::shared_ptr<Order>> getOrderById( + int64_t orderId + ); + /// <summary> + /// Place an order for a pet + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="order">order placed for purchasing the pet</param> + pplx::task<std::shared_ptr<Order>> placeOrder( + std::shared_ptr<Order> order + ); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index fa70d0247e3..d62ba153544 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,7 @@ * Do not edit the class manually. */ + #include "UserApi.h" #include "IHttpBody.h" #include "JsonBody.h" @@ -26,1108 +26,923 @@ namespace api { using namespace org::openapitools::client::model; -UserApi::UserApi(std::shared_ptr<ApiClient> apiClient) - : m_ApiClient(apiClient) {} - -UserApi::~UserApi() {} - -pplx::task<void> UserApi::createUser(std::shared_ptr<User> user) { - - // verify the required parameter 'user' is set - if (user == nullptr) { - throw ApiException(400, utility::conversions::to_string_t( - "Missing required parameter 'user' when " - "calling UserApi->createUser")); - } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = utility::conversions::to_string_t("/user"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "UserApi->createUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(user); - - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if (user.get()) { - user->toMultipart(localVarMultipart, - utility::conversions::to_string_t("user")); +UserApi::UserApi( std::shared_ptr<ApiClient> apiClient ) + : m_ApiClient(apiClient) +{ +} + +UserApi::~UserApi() +{ +} + +pplx::task<void> UserApi::createUser(std::shared_ptr<User> user) +{ + + // verify the required parameter 'user' is set + if (user == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->createUser")); + } + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if(user.get()) + { + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type")); } - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "UserApi->createUser does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling createUser: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUser: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling createUser: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> -UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/createWithArray"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "UserApi->createUsersWithArrayInput does not " - "produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - { - std::vector<web::json::value> localVarJsonArray; - for (auto &localVarItem : user) { - localVarJsonArray.push_back(localVarItem.get() - ? localVarItem->toJson() - : web::json::value::null()); - } - localVarJson = web::json::value::array(localVarJsonArray); +pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type")); } - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - { - std::vector<web::json::value> localVarJsonArray; - for (auto &localVarItem : user) { - localVarJsonArray.push_back(localVarItem.get() - ? localVarItem->toJson() - : web::json::value::null()); - } - localVarMultipart->add(ModelBase::toHttpContent( - utility::conversions::to_string_t("user"), - web::json::value::array(localVarJsonArray), - utility::conversions::to_string_t("application/json"))); + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector<web::json::value> localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarJson = web::json::value::array(localVarJsonArray); + } + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + { + std::vector<web::json::value> localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type")); } - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "UserApi->createUsersWithArrayInput does not " - "consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling createUsersWithArrayInput: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling createUsersWithArrayInput: unexpected " - "response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> -UserApi::createUsersWithListInput(std::vector<std::shared_ptr<User>> user) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/createWithList"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "UserApi->createUsersWithListInput does not " - "produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - { - std::vector<web::json::value> localVarJsonArray; - for (auto &localVarItem : user) { - localVarJsonArray.push_back(localVarItem.get() - ? localVarItem->toJson() - : web::json::value::null()); - } - localVarJson = web::json::value::array(localVarJsonArray); +pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<User>> user) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type")); } - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - { - std::vector<web::json::value> localVarJsonArray; - for (auto &localVarItem : user) { - localVarJsonArray.push_back(localVarItem.get() - ? localVarItem->toJson() - : web::json::value::null()); - } - localVarMultipart->add(ModelBase::toHttpContent( - utility::conversions::to_string_t("user"), - web::json::value::array(localVarJsonArray), - utility::conversions::to_string_t("application/json"))); + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + { + std::vector<web::json::value> localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarJson = web::json::value::array(localVarJsonArray); + } + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + { + std::vector<web::json::value> localVarJsonArray; + for( auto& localVarItem : user ) + { + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); + + } + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type")); } - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "UserApi->createUsersWithListInput does not " - "consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("POST"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling createUsersWithListInput: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithListInput: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling createUsersWithListInput: unexpected " - "response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> UserApi::deleteUser(utility::string_t username) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("username") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "UserApi->deleteUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "UserApi->deleteUser does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<void> UserApi::deleteUser(utility::string_t username) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling deleteUser: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteUser: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling deleteUser: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<std::shared_ptr<User>> -UserApi::getUserByName(utility::string_t username) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("username") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(400, utility::conversions::to_string_t( - "UserApi->getUserByName does not produce any " - "supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException(415, utility::conversions::to_string_t( - "UserApi->getUserByName does not consume any " - "supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t username) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t( - "error calling getUserByName: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getUserByName: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getUserByName: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { std::shared_ptr<User> localVarResult(new User()); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult->fromJson(localVarJson); + localVarResult->fromJson(localVarJson); } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling getUserByName: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling getUserByName: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, - utility::string_t password) { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/login"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/xml")); - localVarResponseHttpContentTypes.insert( - utility::conversions::to_string_t("application/json")); - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("text/plain"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } - // plain text - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("text/plain")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("text/plain"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "UserApi->loginUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - { - localVarQueryParams[utility::conversions::to_string_t("username")] = - ApiClient::parameterToString(username); - } - { - localVarQueryParams[utility::conversions::to_string_t("password")] = - ApiClient::parameterToString(password); - } - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "UserApi->loginUser does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, utility::string_t password) +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/login"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + // plain text + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + { + localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); + } + { + localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); + } + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling loginUser: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling loginUser: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling loginUser: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { + }) + .then([=](utility::string_t localVarResponse) + { utility::string_t localVarResult(utility::conversions::to_string_t("")); - if (localVarResponseHttpContentType == - utility::conversions::to_string_t("application/json")) { - web::json::value localVarJson = - web::json::value::parse(localVarResponse); + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) + { + web::json::value localVarJson = web::json::value::parse(localVarResponse); - localVarResult = ModelBase::stringFromJson(localVarJson); - - } else if (localVarResponseHttpContentType == - utility::conversions::to_string_t("text/plain")) { - localVarResult = localVarResponse; + localVarResult = ModelBase::stringFromJson(localVarJson); + + } + else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain")) + { + localVarResult = localVarResponse; } - // else if(localVarResponseHttpContentType == - // utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } - else { - throw ApiException( - 500, utility::conversions::to_string_t( - "error calling loginUser: unsupported response type")); + else + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling loginUser: unsupported response type")); } return localVarResult; - }); + }); } -pplx::task<void> UserApi::logoutUser() { - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/logout"); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "UserApi->logoutUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "UserApi->logoutUser does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("GET"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { +pplx::task<void> UserApi::logoutUser() +{ + + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout"); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling logoutUser: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling logoutUser: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling logoutUser: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); } -pplx::task<void> UserApi::updateUser(utility::string_t username, - std::shared_ptr<User> user) { - - // verify the required parameter 'user' is set - if (user == nullptr) { - throw ApiException(400, utility::conversions::to_string_t( - "Missing required parameter 'user' when " - "calling UserApi->updateUser")); - } - - std::shared_ptr<ApiConfiguration> localVarApiConfiguration( - m_ApiClient->getConfiguration()); - utility::string_t localVarPath = - utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(localVarPath, - utility::conversions::to_string_t("{") + - utility::conversions::to_string_t("username") + - utility::conversions::to_string_t("}"), - ApiClient::parameterToString(username)); - - std::map<utility::string_t, utility::string_t> localVarQueryParams; - std::map<utility::string_t, utility::string_t> localVarHeaderParams( - localVarApiConfiguration->getDefaultHeaders()); - std::map<utility::string_t, utility::string_t> localVarFormParams; - std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; - - std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; - - utility::string_t localVarResponseHttpContentType; - - // use JSON if possible - if (localVarResponseHttpContentTypes.size() == 0) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // JSON - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("application/json")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("application/json"); - } - // multipart formdata - else if (localVarResponseHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarResponseHttpContentTypes.end()) { - localVarResponseHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - } else { - throw ApiException( - 400, - utility::conversions::to_string_t( - "UserApi->updateUser does not produce any supported media type")); - } - - localVarHeaderParams[utility::conversions::to_string_t("Accept")] = - localVarResponseHttpContentType; - - std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; - - std::shared_ptr<IHttpBody> localVarHttpBody; - utility::string_t localVarRequestHttpContentType; - - // use JSON if possible - if (localVarConsumeHttpContentTypes.size() == 0 || - localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t( - "application/json")) != localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("application/json"); - web::json::value localVarJson; - - localVarJson = ModelBase::toJson(user); - - localVarHttpBody = std::shared_ptr<IHttpBody>(new JsonBody(localVarJson)); - } - // multipart formdata - else if (localVarConsumeHttpContentTypes.find( - utility::conversions::to_string_t("multipart/form-data")) != - localVarConsumeHttpContentTypes.end()) { - localVarRequestHttpContentType = - utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); - - if (user.get()) { - user->toMultipart(localVarMultipart, - utility::conversions::to_string_t("user")); +pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr<User> user) +{ + + // verify the required parameter 'user' is set + if (user == nullptr) + { + throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->updateUser")); } - localVarHttpBody = localVarMultipart; - localVarRequestHttpContentType += - utility::conversions::to_string_t("; boundary=") + - localVarMultipart->getBoundary(); - } else { - throw ApiException( - 415, - utility::conversions::to_string_t( - "UserApi->updateUser does not consume any supported media type")); - } - - return m_ApiClient - ->callApi(localVarPath, utility::conversions::to_string_t("PUT"), - localVarQueryParams, localVarHttpBody, localVarHeaderParams, - localVarFormParams, localVarFileParams, - localVarRequestHttpContentType) - .then([=](web::http::http_response localVarResponse) { + + std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + + std::map<utility::string_t, utility::string_t> localVarQueryParams; + std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map<utility::string_t, utility::string_t> localVarFormParams; + std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams; + + std::unordered_set<utility::string_t> localVarResponseHttpContentTypes; + + utility::string_t localVarResponseHttpContentType; + + // use JSON if possible + if ( localVarResponseHttpContentTypes.size() == 0 ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // JSON + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); + } + // multipart formdata + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) + { + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + } + else + { + throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type")); + } + + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; + + std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes; + + + std::shared_ptr<IHttpBody> localVarHttpBody; + utility::string_t localVarRequestHttpContentType; + + // use JSON if possible + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; + + localVarJson = ModelBase::toJson(user); + + + localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) ); + } + // multipart formdata + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) + { + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData); + + if(user.get()) + { + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); + } + + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); + } + else + { + throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type")); + } + + + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) + { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (localVarResponse.status_code() >= 400) { - throw ApiException( - localVarResponse.status_code(), - utility::conversions::to_string_t("error calling updateUser: ") + - localVarResponse.reason_phrase(), - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); + if (localVarResponse.status_code() >= 400) + { + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updateUser: ") + localVarResponse.reason_phrase() + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); } // check response content type - if (localVarResponse.headers().has( - utility::conversions::to_string_t("Content-Type"))) { - utility::string_t localVarContentType = - localVarResponse - .headers()[utility::conversions::to_string_t("Content-Type")]; - if (localVarContentType.find(localVarResponseHttpContentType) == - std::string::npos) { - throw ApiException( - 500, - utility::conversions::to_string_t( - "error calling updateUser: unexpected response type: ") + - localVarContentType, - std::make_shared<std::stringstream>( - localVarResponse.extract_utf8string(true).get())); - } + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) + { + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) + { + throw ApiException(500 + , utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + localVarContentType + , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get())); + } } return localVarResponse.extract_string(); - }) - .then([=](utility::string_t localVarResponse) { return void(); }); + }) + .then([=](utility::string_t localVarResponse) + { + return void(); + }); +} + +} +} +} } -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.h b/samples/client/petstore/cpp-restsdk/api/UserApi.h index 19e763b31ca..3f5ef26bd18 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.h +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -13,17 +12,19 @@ /* * UserApi.h * - * + * */ #ifndef ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ #define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ + #include "../ApiClient.h" #include "User.h" -#include <cpprest/details/basic_types.h> #include <vector> +#include <cpprest/details/basic_types.h> + #include <boost/optional.hpp> @@ -34,90 +35,107 @@ namespace api { using namespace org::openapitools::client::model; -class UserApi { + + +class UserApi +{ public: - explicit UserApi(std::shared_ptr<ApiClient> apiClient); - - virtual ~UserApi(); - - /// <summary> - /// Create user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="user">Created user object</param> - pplx::task<void> createUser(std::shared_ptr<User> user); - /// <summary> - /// Creates list of users with given input array - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="user">List of user object</param> - pplx::task<void> - createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user); - /// <summary> - /// Creates list of users with given input array - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="user">List of user object</param> - pplx::task<void> - createUsersWithListInput(std::vector<std::shared_ptr<User>> user); - /// <summary> - /// Delete user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="username">The name that needs to be deleted</param> - pplx::task<void> deleteUser(utility::string_t username); - /// <summary> - /// Get user by user name - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="username">The name that needs to be fetched. Use user1 for - /// testing.</param> - pplx::task<std::shared_ptr<User>> getUserByName(utility::string_t username); - /// <summary> - /// Logs user into the system - /// </summary> - /// <remarks> - /// - /// </remarks> - /// <param name="username">The user name for login</param> - /// <param name="password">The password for login in clear text</param> - pplx::task<utility::string_t> loginUser(utility::string_t username, - utility::string_t password); - /// <summary> - /// Logs out current logged in user session - /// </summary> - /// <remarks> - /// - /// </remarks> - pplx::task<void> logoutUser(); - /// <summary> - /// Updated user - /// </summary> - /// <remarks> - /// This can only be done by the logged in user. - /// </remarks> - /// <param name="username">name that need to be deleted</param> - /// <param name="user">Updated user object</param> - pplx::task<void> updateUser(utility::string_t username, - std::shared_ptr<User> user); + + explicit UserApi( std::shared_ptr<ApiClient> apiClient ); + + virtual ~UserApi(); + + /// <summary> + /// Create user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="user">Created user object</param> + pplx::task<void> createUser( + std::shared_ptr<User> user + ); + /// <summary> + /// Creates list of users with given input array + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="user">List of user object</param> + pplx::task<void> createUsersWithArrayInput( + std::vector<std::shared_ptr<User>> user + ); + /// <summary> + /// Creates list of users with given input array + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="user">List of user object</param> + pplx::task<void> createUsersWithListInput( + std::vector<std::shared_ptr<User>> user + ); + /// <summary> + /// Delete user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="username">The name that needs to be deleted</param> + pplx::task<void> deleteUser( + utility::string_t username + ); + /// <summary> + /// Get user by user name + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="username">The name that needs to be fetched. Use user1 for testing.</param> + pplx::task<std::shared_ptr<User>> getUserByName( + utility::string_t username + ); + /// <summary> + /// Logs user into the system + /// </summary> + /// <remarks> + /// + /// </remarks> + /// <param name="username">The user name for login</param> + /// <param name="password">The password for login in clear text</param> + pplx::task<utility::string_t> loginUser( + utility::string_t username, + utility::string_t password + ); + /// <summary> + /// Logs out current logged in user session + /// </summary> + /// <remarks> + /// + /// </remarks> + pplx::task<void> logoutUser( + ); + /// <summary> + /// Updated user + /// </summary> + /// <remarks> + /// This can only be done by the logged in user. + /// </remarks> + /// <param name="username">name that need to be deleted</param> + /// <param name="user">Updated user object</param> + pplx::task<void> updateUser( + utility::string_t username, + std::shared_ptr<User> user + ); protected: - std::shared_ptr<ApiClient> m_ApiClient; + std::shared_ptr<ApiClient> m_ApiClient; }; -} // namespace api -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ */ + diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp index 5a3c672cb9e..2ed8acfaced 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "ApiResponse.h" namespace org { @@ -17,140 +18,182 @@ namespace openapitools { namespace client { namespace model { -ApiResponse::ApiResponse() { - m_Code = 0; - m_CodeIsSet = false; - m_Type = utility::conversions::to_string_t(""); - m_TypeIsSet = false; - m_Message = utility::conversions::to_string_t(""); - m_MessageIsSet = false; +ApiResponse::ApiResponse() +{ + m_Code = 0; + m_CodeIsSet = false; + m_Type = utility::conversions::to_string_t(""); + m_TypeIsSet = false; + m_Message = utility::conversions::to_string_t(""); + m_MessageIsSet = false; } -ApiResponse::~ApiResponse() {} +ApiResponse::~ApiResponse() +{ +} -void ApiResponse::validate() { - // TODO: implement validation +void ApiResponse::validate() +{ + // TODO: implement validation } -web::json::value ApiResponse::toJson() const { - web::json::value val = web::json::value::object(); +web::json::value ApiResponse::toJson() const +{ + web::json::value val = web::json::value::object(); - if (m_CodeIsSet) { - val[utility::conversions::to_string_t("code")] = ModelBase::toJson(m_Code); - } - if (m_TypeIsSet) { - val[utility::conversions::to_string_t("type")] = ModelBase::toJson(m_Type); - } - if (m_MessageIsSet) { - val[utility::conversions::to_string_t("message")] = - ModelBase::toJson(m_Message); - } + if(m_CodeIsSet) + { + val[utility::conversions::to_string_t("code")] = ModelBase::toJson(m_Code); + } + if(m_TypeIsSet) + { + val[utility::conversions::to_string_t("type")] = ModelBase::toJson(m_Type); + } + if(m_MessageIsSet) + { + val[utility::conversions::to_string_t("message")] = ModelBase::toJson(m_Message); + } - return val; + return val; } -void ApiResponse::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("code"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("code")); - if (!fieldValue.is_null()) { - setCode(ModelBase::int32_tFromJson(fieldValue)); +void ApiResponse::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("code"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("code")); + if(!fieldValue.is_null()) + { + setCode(ModelBase::int32_tFromJson(fieldValue)); + } } - } - if (val.has_field(utility::conversions::to_string_t("type"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("type")); - if (!fieldValue.is_null()) { - setType(ModelBase::stringFromJson(fieldValue)); + if(val.has_field(utility::conversions::to_string_t("type"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("type")); + if(!fieldValue.is_null()) + { + setType(ModelBase::stringFromJson(fieldValue)); + } } - } - if (val.has_field(utility::conversions::to_string_t("message"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("message")); - if (!fieldValue.is_null()) { - setMessage(ModelBase::stringFromJson(fieldValue)); + if(val.has_field(utility::conversions::to_string_t("message"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("message")); + if(!fieldValue.is_null()) + { + setMessage(ModelBase::stringFromJson(fieldValue)); + } } - } } -void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void ApiResponse::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } - if (m_CodeIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("code"), m_Code)); - } - if (m_TypeIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("type"), m_Type)); - } - if (m_MessageIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("message"), m_Message)); - } + if(m_CodeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("code"), m_Code)); + } + if(m_TypeIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("type"), m_Type)); + } + if(m_MessageIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("message"), m_Message)); + } } -void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(multipart->hasContent(utility::conversions::to_string_t("code"))) + { + setCode(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("code")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("type"))) + { + setType(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("type")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("message"))) + { + setMessage(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("message")))); + } +} - if (multipart->hasContent(utility::conversions::to_string_t("code"))) { - setCode(ModelBase::int32_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("code")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("type"))) { - setType(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("type")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("message"))) { - setMessage(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("message")))); - } +int32_t ApiResponse::getCode() const +{ + return m_Code; } -int32_t ApiResponse::getCode() const { return m_Code; } +void ApiResponse::setCode(int32_t value) +{ + m_Code = value; + m_CodeIsSet = true; +} -void ApiResponse::setCode(int32_t value) { - m_Code = value; - m_CodeIsSet = true; +bool ApiResponse::codeIsSet() const +{ + return m_CodeIsSet; } -bool ApiResponse::codeIsSet() const { return m_CodeIsSet; } +void ApiResponse::unsetCode() +{ + m_CodeIsSet = false; +} -void ApiResponse::unsetCode() { m_CodeIsSet = false; } +utility::string_t ApiResponse::getType() const +{ + return m_Type; +} -utility::string_t ApiResponse::getType() const { return m_Type; } +void ApiResponse::setType(const utility::string_t& value) +{ + m_Type = value; + m_TypeIsSet = true; +} -void ApiResponse::setType(const utility::string_t &value) { - m_Type = value; - m_TypeIsSet = true; +bool ApiResponse::typeIsSet() const +{ + return m_TypeIsSet; } -bool ApiResponse::typeIsSet() const { return m_TypeIsSet; } +void ApiResponse::unsetType() +{ + m_TypeIsSet = false; +} -void ApiResponse::unsetType() { m_TypeIsSet = false; } +utility::string_t ApiResponse::getMessage() const +{ + return m_Message; +} -utility::string_t ApiResponse::getMessage() const { return m_Message; } +void ApiResponse::setMessage(const utility::string_t& value) +{ + m_Message = value; + m_MessageIsSet = true; +} -void ApiResponse::setMessage(const utility::string_t &value) { - m_Message = value; - m_MessageIsSet = true; +bool ApiResponse::messageIsSet() const +{ + return m_MessageIsSet; } -bool ApiResponse::messageIsSet() const { return m_MessageIsSet; } +void ApiResponse::unsetMessage() +{ + m_MessageIsSet = false; +} -void ApiResponse::unsetMessage() { m_MessageIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h index 389d14c9368..a65b2e83fc5 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ + #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,66 +31,67 @@ namespace model { /// <summary> /// Describes the result of uploading an image resource /// </summary> -class ApiResponse : public ModelBase { +class ApiResponse + : public ModelBase +{ public: - ApiResponse(); - virtual ~ApiResponse(); + ApiResponse(); + virtual ~ApiResponse(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + ///////////////////////////////////////////// + /// ApiResponse members - ///////////////////////////////////////////// - /// ApiResponse members + /// <summary> + /// + /// </summary> + int32_t getCode() const; + bool codeIsSet() const; + void unsetCode(); - /// <summary> - /// - /// </summary> - int32_t getCode() const; - bool codeIsSet() const; - void unsetCode(); + void setCode(int32_t value); - void setCode(int32_t value); + /// <summary> + /// + /// </summary> + utility::string_t getType() const; + bool typeIsSet() const; + void unsetType(); - /// <summary> - /// - /// </summary> - utility::string_t getType() const; - bool typeIsSet() const; - void unsetType(); + void setType(const utility::string_t& value); - void setType(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getMessage() const; + bool messageIsSet() const; + void unsetMessage(); - /// <summary> - /// - /// </summary> - utility::string_t getMessage() const; - bool messageIsSet() const; - void unsetMessage(); + void setMessage(const utility::string_t& value); - void setMessage(const utility::string_t &value); protected: - int32_t m_Code; - bool m_CodeIsSet; - utility::string_t m_Type; - bool m_TypeIsSet; - utility::string_t m_Message; - bool m_MessageIsSet; + int32_t m_Code; + bool m_CodeIsSet; + utility::string_t m_Type; + bool m_TypeIsSet; + utility::string_t m_Message; + bool m_MessageIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.cpp b/samples/client/petstore/cpp-restsdk/model/Category.cpp index 601793f18da..68baf3c6bb9 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Category.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "Category.h" namespace org { @@ -17,108 +18,139 @@ namespace openapitools { namespace client { namespace model { -Category::Category() { - m_Id = 0L; - m_IdIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_NameIsSet = false; +Category::Category() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; } -Category::~Category() {} +Category::~Category() +{ +} -void Category::validate() { - // TODO: implement validation +void Category::validate() +{ + // TODO: implement validation } -web::json::value Category::toJson() const { - web::json::value val = web::json::value::object(); +web::json::value Category::toJson() const +{ + web::json::value val = web::json::value::object(); - if (m_IdIsSet) { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if (m_NameIsSet) { - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - } + if(m_IdIsSet) + { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + } - return val; + return val; } -void Category::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("id"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("id")); - if (!fieldValue.is_null()) { - setId(ModelBase::int64_tFromJson(fieldValue)); +void Category::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("id"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); + if(!fieldValue.is_null()) + { + setId(ModelBase::int64_tFromJson(fieldValue)); + } } - } - if (val.has_field(utility::conversions::to_string_t("name"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("name")); - if (!fieldValue.is_null()) { - setName(ModelBase::stringFromJson(fieldValue)); + if(val.has_field(utility::conversions::to_string_t("name"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name")); + if(!fieldValue.is_null()) + { + setName(ModelBase::stringFromJson(fieldValue)); + } } - } } -void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Category::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } - if (m_IdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if (m_NameIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("name"), m_Name)); - } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); + } } -void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(multipart->hasContent(utility::conversions::to_string_t("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("name"))) + { + setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); + } +} - if (multipart->hasContent(utility::conversions::to_string_t("id"))) { - setId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("id")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("name"))) { - setName(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("name")))); - } +int64_t Category::getId() const +{ + return m_Id; } -int64_t Category::getId() const { return m_Id; } +void Category::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} -void Category::setId(int64_t value) { - m_Id = value; - m_IdIsSet = true; +bool Category::idIsSet() const +{ + return m_IdIsSet; } -bool Category::idIsSet() const { return m_IdIsSet; } +void Category::unsetId() +{ + m_IdIsSet = false; +} -void Category::unsetId() { m_IdIsSet = false; } +utility::string_t Category::getName() const +{ + return m_Name; +} -utility::string_t Category::getName() const { return m_Name; } +void Category::setName(const utility::string_t& value) +{ + m_Name = value; + m_NameIsSet = true; +} -void Category::setName(const utility::string_t &value) { - m_Name = value; - m_NameIsSet = true; +bool Category::nameIsSet() const +{ + return m_NameIsSet; } -bool Category::nameIsSet() const { return m_NameIsSet; } +void Category::unsetName() +{ + m_NameIsSet = false; +} -void Category::unsetName() { m_NameIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Category.h b/samples/client/petstore/cpp-restsdk/model/Category.h index 23b66f3cf34..0f3f9d55a32 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/model/Category.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ + #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,55 +31,56 @@ namespace model { /// <summary> /// A category for a pet /// </summary> -class Category : public ModelBase { +class Category + : public ModelBase +{ public: - Category(); - virtual ~Category(); + Category(); + virtual ~Category(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + ///////////////////////////////////////////// + /// Category members - ///////////////////////////////////////////// - /// Category members + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + void setId(int64_t value); - void setId(int64_t value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); - /// <summary> - /// - /// </summary> - utility::string_t getName() const; - bool nameIsSet() const; - void unsetName(); + void setName(const utility::string_t& value); - void setName(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Name; - bool m_NameIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.cpp b/samples/client/petstore/cpp-restsdk/model/Order.cpp index dde0ecebaa4..9e438173135 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Order.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "Order.h" namespace org { @@ -17,240 +18,311 @@ namespace openapitools { namespace client { namespace model { -Order::Order() { - m_Id = 0L; - m_IdIsSet = false; - m_PetId = 0L; - m_PetIdIsSet = false; - m_Quantity = 0; - m_QuantityIsSet = false; - m_ShipDate = utility::datetime(); - m_ShipDateIsSet = false; - m_Status = utility::conversions::to_string_t(""); - m_StatusIsSet = false; - m_Complete = false; - m_CompleteIsSet = false; -} - -Order::~Order() {} - -void Order::validate() { - // TODO: implement validation -} - -web::json::value Order::toJson() const { - web::json::value val = web::json::value::object(); - - if (m_IdIsSet) { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if (m_PetIdIsSet) { - val[utility::conversions::to_string_t("petId")] = - ModelBase::toJson(m_PetId); - } - if (m_QuantityIsSet) { - val[utility::conversions::to_string_t("quantity")] = - ModelBase::toJson(m_Quantity); - } - if (m_ShipDateIsSet) { - val[utility::conversions::to_string_t("shipDate")] = - ModelBase::toJson(m_ShipDate); - } - if (m_StatusIsSet) { - val[utility::conversions::to_string_t("status")] = - ModelBase::toJson(m_Status); - } - if (m_CompleteIsSet) { - val[utility::conversions::to_string_t("complete")] = - ModelBase::toJson(m_Complete); - } - - return val; -} - -void Order::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("id"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("id")); - if (!fieldValue.is_null()) { - setId(ModelBase::int64_tFromJson(fieldValue)); +Order::Order() +{ + m_Id = 0L; + m_IdIsSet = false; + m_PetId = 0L; + m_PetIdIsSet = false; + m_Quantity = 0; + m_QuantityIsSet = false; + m_ShipDate = utility::datetime(); + m_ShipDateIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; + m_Complete = false; + m_CompleteIsSet = false; +} + +Order::~Order() +{ +} + +void Order::validate() +{ + // TODO: implement validation +} + +web::json::value Order::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); } - } - if (val.has_field(utility::conversions::to_string_t("petId"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("petId")); - if (!fieldValue.is_null()) { - setPetId(ModelBase::int64_tFromJson(fieldValue)); + if(m_PetIdIsSet) + { + val[utility::conversions::to_string_t("petId")] = ModelBase::toJson(m_PetId); } - } - if (val.has_field(utility::conversions::to_string_t("quantity"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("quantity")); - if (!fieldValue.is_null()) { - setQuantity(ModelBase::int32_tFromJson(fieldValue)); + if(m_QuantityIsSet) + { + val[utility::conversions::to_string_t("quantity")] = ModelBase::toJson(m_Quantity); } - } - if (val.has_field(utility::conversions::to_string_t("shipDate"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("shipDate")); - if (!fieldValue.is_null()) { - setShipDate(ModelBase::dateFromJson(fieldValue)); + if(m_ShipDateIsSet) + { + val[utility::conversions::to_string_t("shipDate")] = ModelBase::toJson(m_ShipDate); } - } - if (val.has_field(utility::conversions::to_string_t("status"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("status")); - if (!fieldValue.is_null()) { - setStatus(ModelBase::stringFromJson(fieldValue)); + if(m_StatusIsSet) + { + val[utility::conversions::to_string_t("status")] = ModelBase::toJson(m_Status); } - } - if (val.has_field(utility::conversions::to_string_t("complete"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("complete")); - if (!fieldValue.is_null()) { - setComplete(ModelBase::boolFromJson(fieldValue)); + if(m_CompleteIsSet) + { + val[utility::conversions::to_string_t("complete")] = ModelBase::toJson(m_Complete); } - } -} - -void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - - if (m_IdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if (m_PetIdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("petId"), m_PetId)); - } - if (m_QuantityIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("quantity"), - m_Quantity)); - } - if (m_ShipDateIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("shipDate"), - m_ShipDate)); - } - if (m_StatusIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("status"), m_Status)); - } - if (m_CompleteIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("complete"), - m_Complete)); - } + + return val; } -void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Order::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("id"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); + if(!fieldValue.is_null()) + { + setId(ModelBase::int64_tFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("petId"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("petId")); + if(!fieldValue.is_null()) + { + setPetId(ModelBase::int64_tFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("quantity"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("quantity")); + if(!fieldValue.is_null()) + { + setQuantity(ModelBase::int32_tFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("shipDate"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("shipDate")); + if(!fieldValue.is_null()) + { + setShipDate(ModelBase::dateFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("status"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status")); + if(!fieldValue.is_null()) + { + setStatus(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("complete"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("complete")); + if(!fieldValue.is_null()) + { + setComplete(ModelBase::boolFromJson(fieldValue)); + } + } +} + +void Order::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if(m_PetIdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("petId"), m_PetId)); + } + if(m_QuantityIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("quantity"), m_Quantity)); + } + if(m_ShipDateIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("shipDate"), m_ShipDate)); + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("status"), m_Status)); + } + if(m_CompleteIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("complete"), m_Complete)); + } +} + +void Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(multipart->hasContent(utility::conversions::to_string_t("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("petId"))) + { + setPetId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("petId")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("quantity"))) + { + setQuantity(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("quantity")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("shipDate"))) + { + setShipDate(ModelBase::dateFromHttpContent(multipart->getContent(utility::conversions::to_string_t("shipDate")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("status"))) + { + setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("complete"))) + { + setComplete(ModelBase::boolFromHttpContent(multipart->getContent(utility::conversions::to_string_t("complete")))); + } +} - if (multipart->hasContent(utility::conversions::to_string_t("id"))) { - setId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("id")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("petId"))) { - setPetId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("petId")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("quantity"))) { - setQuantity(ModelBase::int32_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("quantity")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("shipDate"))) { - setShipDate(ModelBase::dateFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("shipDate")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("status"))) { - setStatus(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("status")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("complete"))) { - setComplete(ModelBase::boolFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("complete")))); - } +int64_t Order::getId() const +{ + return m_Id; } -int64_t Order::getId() const { return m_Id; } +void Order::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} -void Order::setId(int64_t value) { - m_Id = value; - m_IdIsSet = true; +bool Order::idIsSet() const +{ + return m_IdIsSet; } -bool Order::idIsSet() const { return m_IdIsSet; } +void Order::unsetId() +{ + m_IdIsSet = false; +} -void Order::unsetId() { m_IdIsSet = false; } +int64_t Order::getPetId() const +{ + return m_PetId; +} -int64_t Order::getPetId() const { return m_PetId; } +void Order::setPetId(int64_t value) +{ + m_PetId = value; + m_PetIdIsSet = true; +} -void Order::setPetId(int64_t value) { - m_PetId = value; - m_PetIdIsSet = true; +bool Order::petIdIsSet() const +{ + return m_PetIdIsSet; } -bool Order::petIdIsSet() const { return m_PetIdIsSet; } +void Order::unsetPetId() +{ + m_PetIdIsSet = false; +} -void Order::unsetPetId() { m_PetIdIsSet = false; } +int32_t Order::getQuantity() const +{ + return m_Quantity; +} -int32_t Order::getQuantity() const { return m_Quantity; } +void Order::setQuantity(int32_t value) +{ + m_Quantity = value; + m_QuantityIsSet = true; +} -void Order::setQuantity(int32_t value) { - m_Quantity = value; - m_QuantityIsSet = true; +bool Order::quantityIsSet() const +{ + return m_QuantityIsSet; } -bool Order::quantityIsSet() const { return m_QuantityIsSet; } +void Order::unsetQuantity() +{ + m_QuantityIsSet = false; +} -void Order::unsetQuantity() { m_QuantityIsSet = false; } +utility::datetime Order::getShipDate() const +{ + return m_ShipDate; +} -utility::datetime Order::getShipDate() const { return m_ShipDate; } +void Order::setShipDate(const utility::datetime& value) +{ + m_ShipDate = value; + m_ShipDateIsSet = true; +} -void Order::setShipDate(const utility::datetime &value) { - m_ShipDate = value; - m_ShipDateIsSet = true; +bool Order::shipDateIsSet() const +{ + return m_ShipDateIsSet; } -bool Order::shipDateIsSet() const { return m_ShipDateIsSet; } +void Order::unsetShipDate() +{ + m_ShipDateIsSet = false; +} -void Order::unsetShipDate() { m_ShipDateIsSet = false; } +utility::string_t Order::getStatus() const +{ + return m_Status; +} -utility::string_t Order::getStatus() const { return m_Status; } +void Order::setStatus(const utility::string_t& value) +{ + m_Status = value; + m_StatusIsSet = true; +} -void Order::setStatus(const utility::string_t &value) { - m_Status = value; - m_StatusIsSet = true; +bool Order::statusIsSet() const +{ + return m_StatusIsSet; } -bool Order::statusIsSet() const { return m_StatusIsSet; } +void Order::unsetStatus() +{ + m_StatusIsSet = false; +} -void Order::unsetStatus() { m_StatusIsSet = false; } +bool Order::isComplete() const +{ + return m_Complete; +} -bool Order::isComplete() const { return m_Complete; } +void Order::setComplete(bool value) +{ + m_Complete = value; + m_CompleteIsSet = true; +} -void Order::setComplete(bool value) { - m_Complete = value; - m_CompleteIsSet = true; +bool Order::completeIsSet() const +{ + return m_CompleteIsSet; } -bool Order::completeIsSet() const { return m_CompleteIsSet; } +void Order::unsetComplete() +{ + m_CompleteIsSet = false; +} -void Order::unsetComplete() { m_CompleteIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Order.h b/samples/client/petstore/cpp-restsdk/model/Order.h index 55212bdbcf7..b7ea4c528c1 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/model/Order.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ + #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,99 +31,100 @@ namespace model { /// <summary> /// An order for a pets from the pet store /// </summary> -class Order : public ModelBase { +class Order + : public ModelBase +{ public: - Order(); - virtual ~Order(); + Order(); + virtual ~Order(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + ///////////////////////////////////////////// + /// Order members - ///////////////////////////////////////////// - /// Order members + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + void setId(int64_t value); - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getPetId() const; + bool petIdIsSet() const; + void unsetPetId(); - /// <summary> - /// - /// </summary> - int64_t getPetId() const; - bool petIdIsSet() const; - void unsetPetId(); + void setPetId(int64_t value); - void setPetId(int64_t value); + /// <summary> + /// + /// </summary> + int32_t getQuantity() const; + bool quantityIsSet() const; + void unsetQuantity(); - /// <summary> - /// - /// </summary> - int32_t getQuantity() const; - bool quantityIsSet() const; - void unsetQuantity(); + void setQuantity(int32_t value); - void setQuantity(int32_t value); + /// <summary> + /// + /// </summary> + utility::datetime getShipDate() const; + bool shipDateIsSet() const; + void unsetShipDate(); - /// <summary> - /// - /// </summary> - utility::datetime getShipDate() const; - bool shipDateIsSet() const; - void unsetShipDate(); + void setShipDate(const utility::datetime& value); - void setShipDate(const utility::datetime &value); + /// <summary> + /// Order Status + /// </summary> + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); - /// <summary> - /// Order Status - /// </summary> - utility::string_t getStatus() const; - bool statusIsSet() const; - void unsetStatus(); + void setStatus(const utility::string_t& value); - void setStatus(const utility::string_t &value); + /// <summary> + /// + /// </summary> + bool isComplete() const; + bool completeIsSet() const; + void unsetComplete(); - /// <summary> - /// - /// </summary> - bool isComplete() const; - bool completeIsSet() const; - void unsetComplete(); + void setComplete(bool value); - void setComplete(bool value); protected: - int64_t m_Id; - bool m_IdIsSet; - int64_t m_PetId; - bool m_PetIdIsSet; - int32_t m_Quantity; - bool m_QuantityIsSet; - utility::datetime m_ShipDate; - bool m_ShipDateIsSet; - utility::string_t m_Status; - bool m_StatusIsSet; - bool m_Complete; - bool m_CompleteIsSet; + int64_t m_Id; + bool m_IdIsSet; + int64_t m_PetId; + bool m_PetIdIsSet; + int32_t m_Quantity; + bool m_QuantityIsSet; + utility::datetime m_ShipDate; + bool m_ShipDateIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; + bool m_Complete; + bool m_CompleteIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/model/Pet.cpp index 65f5eb6874a..8b6e77835f7 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Pet.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "Pet.h" namespace org { @@ -17,271 +18,337 @@ namespace openapitools { namespace client { namespace model { -Pet::Pet() { - m_Id = 0L; - m_IdIsSet = false; - m_CategoryIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_TagsIsSet = false; - m_Status = utility::conversions::to_string_t(""); - m_StatusIsSet = false; +Pet::Pet() +{ + m_Id = 0L; + m_IdIsSet = false; + m_CategoryIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_TagsIsSet = false; + m_Status = utility::conversions::to_string_t(""); + m_StatusIsSet = false; } -Pet::~Pet() {} +Pet::~Pet() +{ +} -void Pet::validate() { - // TODO: implement validation +void Pet::validate() +{ + // TODO: implement validation } -web::json::value Pet::toJson() const { - web::json::value val = web::json::value::object(); - - if (m_IdIsSet) { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if (m_CategoryIsSet) { - val[utility::conversions::to_string_t("category")] = - ModelBase::toJson(m_Category); - } - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - { - std::vector<web::json::value> jsonArray; - for (auto &item : m_PhotoUrls) { - jsonArray.push_back(ModelBase::toJson(item)); +web::json::value Pet::toJson() const +{ + web::json::value val = web::json::value::object(); + + if(m_IdIsSet) + { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if(m_CategoryIsSet) + { + val[utility::conversions::to_string_t("category")] = ModelBase::toJson(m_Category); + } + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + { + std::vector<web::json::value> jsonArray; + for( auto& item : m_PhotoUrls ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + val[utility::conversions::to_string_t("photoUrls")] = web::json::value::array(jsonArray); } - val[utility::conversions::to_string_t("photoUrls")] = - web::json::value::array(jsonArray); - } - { - std::vector<web::json::value> jsonArray; - for (auto &item : m_Tags) { - jsonArray.push_back(ModelBase::toJson(item)); + { + std::vector<web::json::value> jsonArray; + for( auto& item : m_Tags ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + if(jsonArray.size() > 0) + { + val[utility::conversions::to_string_t("tags")] = web::json::value::array(jsonArray); + } } - if (jsonArray.size() > 0) { - val[utility::conversions::to_string_t("tags")] = - web::json::value::array(jsonArray); + if(m_StatusIsSet) + { + val[utility::conversions::to_string_t("status")] = ModelBase::toJson(m_Status); } - } - if (m_StatusIsSet) { - val[utility::conversions::to_string_t("status")] = - ModelBase::toJson(m_Status); - } - return val; + return val; } -void Pet::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("id"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("id")); - if (!fieldValue.is_null()) { - setId(ModelBase::int64_tFromJson(fieldValue)); +void Pet::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("id"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); + if(!fieldValue.is_null()) + { + setId(ModelBase::int64_tFromJson(fieldValue)); + } } - } - if (val.has_field(utility::conversions::to_string_t("category"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("category")); - if (!fieldValue.is_null()) { - std::shared_ptr<Category> newItem(new Category()); - newItem->fromJson(fieldValue); - setCategory(newItem); + if(val.has_field(utility::conversions::to_string_t("category"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("category")); + if(!fieldValue.is_null()) + { + std::shared_ptr<Category> newItem(new Category()); + newItem->fromJson(fieldValue); + setCategory( newItem ); + } } - } - setName(ModelBase::stringFromJson( - val.at(utility::conversions::to_string_t("name")))); - { - m_PhotoUrls.clear(); - std::vector<web::json::value> jsonArray; - for (auto &item : - val.at(utility::conversions::to_string_t("photoUrls")).as_array()) { - m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + setName(ModelBase::stringFromJson(val.at(utility::conversions::to_string_t("name")))); + { + m_PhotoUrls.clear(); + std::vector<web::json::value> jsonArray; + for( auto& item : val.at(utility::conversions::to_string_t("photoUrls")).as_array() ) + { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + } } - } - { - m_Tags.clear(); - std::vector<web::json::value> jsonArray; - if (val.has_field(utility::conversions::to_string_t("tags"))) { - for (auto &item : - val.at(utility::conversions::to_string_t("tags")).as_array()) { - if (item.is_null()) { - m_Tags.push_back(std::shared_ptr<Tag>(nullptr)); - } else { - std::shared_ptr<Tag> newItem(new Tag()); - newItem->fromJson(item); - m_Tags.push_back(newItem); + { + m_Tags.clear(); + std::vector<web::json::value> jsonArray; + if(val.has_field(utility::conversions::to_string_t("tags"))) + { + for( auto& item : val.at(utility::conversions::to_string_t("tags")).as_array() ) + { + if(item.is_null()) + { + m_Tags.push_back( std::shared_ptr<Tag>(nullptr) ); + } + else + { + std::shared_ptr<Tag> newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back( newItem ); + } + } } - } } - } - if (val.has_field(utility::conversions::to_string_t("status"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("status")); - if (!fieldValue.is_null()) { - setStatus(ModelBase::stringFromJson(fieldValue)); + if(val.has_field(utility::conversions::to_string_t("status"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status")); + if(!fieldValue.is_null()) + { + setStatus(ModelBase::stringFromJson(fieldValue)); + } } - } } -void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - - if (m_IdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if (m_CategoryIsSet) { - if (m_Category.get()) { - m_Category->toMultipart(multipart, - utility::conversions::to_string_t("category.")); +void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); } - } - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("name"), m_Name)); - { - std::vector<web::json::value> jsonArray; - for (auto &item : m_PhotoUrls) { - jsonArray.push_back(ModelBase::toJson(item)); + + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); } - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("photoUrls"), - web::json::value::array(jsonArray), - utility::conversions::to_string_t("application/json"))); - } - { - std::vector<web::json::value> jsonArray; - for (auto &item : m_Tags) { - jsonArray.push_back(ModelBase::toJson(item)); + if(m_CategoryIsSet) + { + if (m_Category.get()) + { + m_Category->toMultipart(multipart, utility::conversions::to_string_t("category.")); + } } - - if (jsonArray.size() > 0) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("tags"), - web::json::value::array(jsonArray), - utility::conversions::to_string_t("application/json"))); + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); + { + std::vector<web::json::value> jsonArray; + for( auto& item : m_PhotoUrls ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("photoUrls"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); + } + { + std::vector<web::json::value> jsonArray; + for( auto& item : m_Tags ) + { + jsonArray.push_back(ModelBase::toJson(item)); + } + + if(jsonArray.size() > 0) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("tags"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); + } + } + if(m_StatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("status"), m_Status)); } - } - if (m_StatusIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("status"), m_Status)); - } } -void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - - if (multipart->hasContent(utility::conversions::to_string_t("id"))) { - setId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("id")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("category"))) { - if (multipart->hasContent(utility::conversions::to_string_t("category"))) { - std::shared_ptr<Category> newItem(new Category()); - newItem->fromMultiPart(multipart, - utility::conversions::to_string_t("category.")); - setCategory(newItem); +void Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(multipart->hasContent(utility::conversions::to_string_t("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("category"))) + { + if(multipart->hasContent(utility::conversions::to_string_t("category"))) + { + std::shared_ptr<Category> newItem(new Category()); + newItem->fromMultiPart(multipart, utility::conversions::to_string_t("category.")); + setCategory( newItem ); + } } - } - setName(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("name")))); - { - m_PhotoUrls.clear(); - - web::json::value jsonArray = web::json::value::parse( - ModelBase::stringFromHttpContent(multipart->getContent( - utility::conversions::to_string_t("photoUrls")))); - for (auto &item : jsonArray.as_array()) { - m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); + { + m_PhotoUrls.clear(); + + web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("photoUrls")))); + for( auto& item : jsonArray.as_array() ) + { + m_PhotoUrls.push_back(ModelBase::stringFromJson(item)); + } } - } - { - m_Tags.clear(); - if (multipart->hasContent(utility::conversions::to_string_t("tags"))) { - - web::json::value jsonArray = web::json::value::parse( - ModelBase::stringFromHttpContent(multipart->getContent( - utility::conversions::to_string_t("tags")))); - for (auto &item : jsonArray.as_array()) { - if (item.is_null()) { - m_Tags.push_back(std::shared_ptr<Tag>(nullptr)); - } else { - std::shared_ptr<Tag> newItem(new Tag()); - newItem->fromJson(item); - m_Tags.push_back(newItem); + { + m_Tags.clear(); + if(multipart->hasContent(utility::conversions::to_string_t("tags"))) + { + + web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("tags")))); + for( auto& item : jsonArray.as_array() ) + { + if(item.is_null()) + { + m_Tags.push_back( std::shared_ptr<Tag>(nullptr) ); + } + else + { + std::shared_ptr<Tag> newItem(new Tag()); + newItem->fromJson(item); + m_Tags.push_back( newItem ); + } + } } - } } - } - if (multipart->hasContent(utility::conversions::to_string_t("status"))) { - setStatus(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("status")))); - } + if(multipart->hasContent(utility::conversions::to_string_t("status"))) + { + setStatus(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("status")))); + } +} + +int64_t Pet::getId() const +{ + return m_Id; } -int64_t Pet::getId() const { return m_Id; } +void Pet::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} -void Pet::setId(int64_t value) { - m_Id = value; - m_IdIsSet = true; +bool Pet::idIsSet() const +{ + return m_IdIsSet; } -bool Pet::idIsSet() const { return m_IdIsSet; } +void Pet::unsetId() +{ + m_IdIsSet = false; +} -void Pet::unsetId() { m_IdIsSet = false; } +std::shared_ptr<Category> Pet::getCategory() const +{ + return m_Category; +} -std::shared_ptr<Category> Pet::getCategory() const { return m_Category; } +void Pet::setCategory(const std::shared_ptr<Category>& value) +{ + m_Category = value; + m_CategoryIsSet = true; +} -void Pet::setCategory(const std::shared_ptr<Category> &value) { - m_Category = value; - m_CategoryIsSet = true; +bool Pet::categoryIsSet() const +{ + return m_CategoryIsSet; } -bool Pet::categoryIsSet() const { return m_CategoryIsSet; } +void Pet::unsetCategory() +{ + m_CategoryIsSet = false; +} -void Pet::unsetCategory() { m_CategoryIsSet = false; } +utility::string_t Pet::getName() const +{ + return m_Name; +} -utility::string_t Pet::getName() const { return m_Name; } +void Pet::setName(const utility::string_t& value) +{ + m_Name = value; + +} -void Pet::setName(const utility::string_t &value) { m_Name = value; } +std::vector<utility::string_t>& Pet::getPhotoUrls() +{ + return m_PhotoUrls; +} -std::vector<utility::string_t> &Pet::getPhotoUrls() { return m_PhotoUrls; } +void Pet::setPhotoUrls(const std::vector<utility::string_t>& value) +{ + m_PhotoUrls = value; + +} -void Pet::setPhotoUrls(const std::vector<utility::string_t> &value) { - m_PhotoUrls = value; +std::vector<std::shared_ptr<Tag>>& Pet::getTags() +{ + return m_Tags; } -std::vector<std::shared_ptr<Tag>> &Pet::getTags() { return m_Tags; } +void Pet::setTags(const std::vector<std::shared_ptr<Tag>>& value) +{ + m_Tags = value; + m_TagsIsSet = true; +} -void Pet::setTags(const std::vector<std::shared_ptr<Tag>> &value) { - m_Tags = value; - m_TagsIsSet = true; +bool Pet::tagsIsSet() const +{ + return m_TagsIsSet; } -bool Pet::tagsIsSet() const { return m_TagsIsSet; } +void Pet::unsetTags() +{ + m_TagsIsSet = false; +} -void Pet::unsetTags() { m_TagsIsSet = false; } +utility::string_t Pet::getStatus() const +{ + return m_Status; +} -utility::string_t Pet::getStatus() const { return m_Status; } +void Pet::setStatus(const utility::string_t& value) +{ + m_Status = value; + m_StatusIsSet = true; +} -void Pet::setStatus(const utility::string_t &value) { - m_Status = value; - m_StatusIsSet = true; +bool Pet::statusIsSet() const +{ + return m_StatusIsSet; } -bool Pet::statusIsSet() const { return m_StatusIsSet; } +void Pet::unsetStatus() +{ + m_StatusIsSet = false; +} -void Pet::unsetStatus() { m_StatusIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.h b/samples/client/petstore/cpp-restsdk/model/Pet.h index 467756fa4bf..55a1b86af41 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/model/Pet.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,11 +18,12 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ + #include "../ModelBase.h" -#include "Category.h" #include "Tag.h" #include <cpprest/details/basic_types.h> +#include "Category.h" #include <vector> namespace org { @@ -34,93 +34,94 @@ namespace model { /// <summary> /// A pet for sale in the pet store /// </summary> -class Pet : public ModelBase { +class Pet + : public ModelBase +{ public: - Pet(); - virtual ~Pet(); - - ///////////////////////////////////////////// - /// ModelBase overrides + Pet(); + virtual ~Pet(); - void validate() override; + ///////////////////////////////////////////// + /// ModelBase overrides - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void validate() override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - ///////////////////////////////////////////// - /// Pet members + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + ///////////////////////////////////////////// + /// Pet members - void setId(int64_t value); + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - std::shared_ptr<Category> getCategory() const; - bool categoryIsSet() const; - void unsetCategory(); + void setId(int64_t value); - void setCategory(const std::shared_ptr<Category> &value); + /// <summary> + /// + /// </summary> + std::shared_ptr<Category> getCategory() const; + bool categoryIsSet() const; + void unsetCategory(); - /// <summary> - /// - /// </summary> - utility::string_t getName() const; + void setCategory(const std::shared_ptr<Category>& value); - void setName(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; + + void setName(const utility::string_t& value); - /// <summary> - /// - /// </summary> - std::vector<utility::string_t> &getPhotoUrls(); + /// <summary> + /// + /// </summary> + std::vector<utility::string_t>& getPhotoUrls(); + + void setPhotoUrls(const std::vector<utility::string_t>& value); - void setPhotoUrls(const std::vector<utility::string_t> &value); + /// <summary> + /// + /// </summary> + std::vector<std::shared_ptr<Tag>>& getTags(); + bool tagsIsSet() const; + void unsetTags(); - /// <summary> - /// - /// </summary> - std::vector<std::shared_ptr<Tag>> &getTags(); - bool tagsIsSet() const; - void unsetTags(); + void setTags(const std::vector<std::shared_ptr<Tag>>& value); - void setTags(const std::vector<std::shared_ptr<Tag>> &value); + /// <summary> + /// pet status in the store + /// </summary> + utility::string_t getStatus() const; + bool statusIsSet() const; + void unsetStatus(); - /// <summary> - /// pet status in the store - /// </summary> - utility::string_t getStatus() const; - bool statusIsSet() const; - void unsetStatus(); + void setStatus(const utility::string_t& value); - void setStatus(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - std::shared_ptr<Category> m_Category; - bool m_CategoryIsSet; - utility::string_t m_Name; - std::vector<utility::string_t> m_PhotoUrls; - std::vector<std::shared_ptr<Tag>> m_Tags; - bool m_TagsIsSet; - utility::string_t m_Status; - bool m_StatusIsSet; + int64_t m_Id; + bool m_IdIsSet; + std::shared_ptr<Category> m_Category; + bool m_CategoryIsSet; + utility::string_t m_Name; + std::vector<utility::string_t> m_PhotoUrls; + std::vector<std::shared_ptr<Tag>> m_Tags; + bool m_TagsIsSet; + utility::string_t m_Status; + bool m_StatusIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/model/Tag.cpp index 36cc16b9ebb..d60ec0ecc42 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Tag.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "Tag.h" namespace org { @@ -17,108 +18,139 @@ namespace openapitools { namespace client { namespace model { -Tag::Tag() { - m_Id = 0L; - m_IdIsSet = false; - m_Name = utility::conversions::to_string_t(""); - m_NameIsSet = false; +Tag::Tag() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = utility::conversions::to_string_t(""); + m_NameIsSet = false; } -Tag::~Tag() {} +Tag::~Tag() +{ +} -void Tag::validate() { - // TODO: implement validation +void Tag::validate() +{ + // TODO: implement validation } -web::json::value Tag::toJson() const { - web::json::value val = web::json::value::object(); +web::json::value Tag::toJson() const +{ + web::json::value val = web::json::value::object(); - if (m_IdIsSet) { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if (m_NameIsSet) { - val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); - } + if(m_IdIsSet) + { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if(m_NameIsSet) + { + val[utility::conversions::to_string_t("name")] = ModelBase::toJson(m_Name); + } - return val; + return val; } -void Tag::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("id"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("id")); - if (!fieldValue.is_null()) { - setId(ModelBase::int64_tFromJson(fieldValue)); +void Tag::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("id"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); + if(!fieldValue.is_null()) + { + setId(ModelBase::int64_tFromJson(fieldValue)); + } } - } - if (val.has_field(utility::conversions::to_string_t("name"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("name")); - if (!fieldValue.is_null()) { - setName(ModelBase::stringFromJson(fieldValue)); + if(val.has_field(utility::conversions::to_string_t("name"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name")); + if(!fieldValue.is_null()) + { + setName(ModelBase::stringFromJson(fieldValue)); + } } - } } -void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Tag::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } - if (m_IdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if (m_NameIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("name"), m_Name)); - } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if(m_NameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("name"), m_Name)); + } } -void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } +void Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } + + if(multipart->hasContent(utility::conversions::to_string_t("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("name"))) + { + setName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("name")))); + } +} - if (multipart->hasContent(utility::conversions::to_string_t("id"))) { - setId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("id")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("name"))) { - setName(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("name")))); - } +int64_t Tag::getId() const +{ + return m_Id; } -int64_t Tag::getId() const { return m_Id; } +void Tag::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} -void Tag::setId(int64_t value) { - m_Id = value; - m_IdIsSet = true; +bool Tag::idIsSet() const +{ + return m_IdIsSet; } -bool Tag::idIsSet() const { return m_IdIsSet; } +void Tag::unsetId() +{ + m_IdIsSet = false; +} -void Tag::unsetId() { m_IdIsSet = false; } +utility::string_t Tag::getName() const +{ + return m_Name; +} -utility::string_t Tag::getName() const { return m_Name; } +void Tag::setName(const utility::string_t& value) +{ + m_Name = value; + m_NameIsSet = true; +} -void Tag::setName(const utility::string_t &value) { - m_Name = value; - m_NameIsSet = true; +bool Tag::nameIsSet() const +{ + return m_NameIsSet; } -bool Tag::nameIsSet() const { return m_NameIsSet; } +void Tag::unsetName() +{ + m_NameIsSet = false; +} -void Tag::unsetName() { m_NameIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.h b/samples/client/petstore/cpp-restsdk/model/Tag.h index 73c7a50a07d..6ac7947b63c 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/model/Tag.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ + #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,55 +31,56 @@ namespace model { /// <summary> /// A tag for a pet /// </summary> -class Tag : public ModelBase { +class Tag + : public ModelBase +{ public: - Tag(); - virtual ~Tag(); + Tag(); + virtual ~Tag(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + ///////////////////////////////////////////// + /// Tag members - ///////////////////////////////////////////// - /// Tag members + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + void setId(int64_t value); - void setId(int64_t value); + /// <summary> + /// + /// </summary> + utility::string_t getName() const; + bool nameIsSet() const; + void unsetName(); - /// <summary> - /// - /// </summary> - utility::string_t getName() const; - bool nameIsSet() const; - void unsetName(); + void setName(const utility::string_t& value); - void setName(const utility::string_t &value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Name; - bool m_NameIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Name; + bool m_NameIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.cpp b/samples/client/petstore/cpp-restsdk/model/User.cpp index 2c157f872e0..ced6a96347d 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.cpp +++ b/samples/client/petstore/cpp-restsdk/model/User.cpp @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -10,6 +9,8 @@ * Do not edit the class manually. */ + + #include "User.h" namespace org { @@ -17,306 +18,397 @@ namespace openapitools { namespace client { namespace model { -User::User() { - m_Id = 0L; - m_IdIsSet = false; - m_Username = utility::conversions::to_string_t(""); - m_UsernameIsSet = false; - m_FirstName = utility::conversions::to_string_t(""); - m_FirstNameIsSet = false; - m_LastName = utility::conversions::to_string_t(""); - m_LastNameIsSet = false; - m_Email = utility::conversions::to_string_t(""); - m_EmailIsSet = false; - m_Password = utility::conversions::to_string_t(""); - m_PasswordIsSet = false; - m_Phone = utility::conversions::to_string_t(""); - m_PhoneIsSet = false; - m_UserStatus = 0; - m_UserStatusIsSet = false; -} - -User::~User() {} - -void User::validate() { - // TODO: implement validation -} - -web::json::value User::toJson() const { - web::json::value val = web::json::value::object(); - - if (m_IdIsSet) { - val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); - } - if (m_UsernameIsSet) { - val[utility::conversions::to_string_t("username")] = - ModelBase::toJson(m_Username); - } - if (m_FirstNameIsSet) { - val[utility::conversions::to_string_t("firstName")] = - ModelBase::toJson(m_FirstName); - } - if (m_LastNameIsSet) { - val[utility::conversions::to_string_t("lastName")] = - ModelBase::toJson(m_LastName); - } - if (m_EmailIsSet) { - val[utility::conversions::to_string_t("email")] = - ModelBase::toJson(m_Email); - } - if (m_PasswordIsSet) { - val[utility::conversions::to_string_t("password")] = - ModelBase::toJson(m_Password); - } - if (m_PhoneIsSet) { - val[utility::conversions::to_string_t("phone")] = - ModelBase::toJson(m_Phone); - } - if (m_UserStatusIsSet) { - val[utility::conversions::to_string_t("userStatus")] = - ModelBase::toJson(m_UserStatus); - } - - return val; -} - -void User::fromJson(const web::json::value &val) { - if (val.has_field(utility::conversions::to_string_t("id"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("id")); - if (!fieldValue.is_null()) { - setId(ModelBase::int64_tFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("username"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("username")); - if (!fieldValue.is_null()) { - setUsername(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("firstName"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("firstName")); - if (!fieldValue.is_null()) { - setFirstName(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("lastName"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("lastName")); - if (!fieldValue.is_null()) { - setLastName(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("email"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("email")); - if (!fieldValue.is_null()) { - setEmail(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("password"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("password")); - if (!fieldValue.is_null()) { - setPassword(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("phone"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("phone")); - if (!fieldValue.is_null()) { - setPhone(ModelBase::stringFromJson(fieldValue)); - } - } - if (val.has_field(utility::conversions::to_string_t("userStatus"))) { - const web::json::value &fieldValue = - val.at(utility::conversions::to_string_t("userStatus")); - if (!fieldValue.is_null()) { - setUserStatus(ModelBase::int32_tFromJson(fieldValue)); - } - } -} - -void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) const { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - - if (m_IdIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("id"), m_Id)); - } - if (m_UsernameIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("username"), - m_Username)); - } - if (m_FirstNameIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("firstName"), - m_FirstName)); - } - if (m_LastNameIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("lastName"), - m_LastName)); - } - if (m_EmailIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("email"), m_Email)); - } - if (m_PasswordIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("password"), - m_Password)); - } - if (m_PhoneIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("phone"), m_Phone)); - } - if (m_UserStatusIsSet) { - multipart->add(ModelBase::toHttpContent( - namePrefix + utility::conversions::to_string_t("userStatus"), - m_UserStatus)); - } -} - -void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &prefix) { - utility::string_t namePrefix = prefix; - if (namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != - utility::conversions::to_string_t(".")) { - namePrefix += utility::conversions::to_string_t("."); - } - - if (multipart->hasContent(utility::conversions::to_string_t("id"))) { - setId(ModelBase::int64_tFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("id")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("username"))) { - setUsername(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("username")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("firstName"))) { - setFirstName(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("firstName")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("lastName"))) { - setLastName(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("lastName")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("email"))) { - setEmail(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("email")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("password"))) { - setPassword(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("password")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("phone"))) { - setPhone(ModelBase::stringFromHttpContent( - multipart->getContent(utility::conversions::to_string_t("phone")))); - } - if (multipart->hasContent(utility::conversions::to_string_t("userStatus"))) { - setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent( - utility::conversions::to_string_t("userStatus")))); - } +User::User() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Username = utility::conversions::to_string_t(""); + m_UsernameIsSet = false; + m_FirstName = utility::conversions::to_string_t(""); + m_FirstNameIsSet = false; + m_LastName = utility::conversions::to_string_t(""); + m_LastNameIsSet = false; + m_Email = utility::conversions::to_string_t(""); + m_EmailIsSet = false; + m_Password = utility::conversions::to_string_t(""); + m_PasswordIsSet = false; + m_Phone = utility::conversions::to_string_t(""); + m_PhoneIsSet = false; + m_UserStatus = 0; + m_UserStatusIsSet = false; } -int64_t User::getId() const { return m_Id; } +User::~User() +{ +} -void User::setId(int64_t value) { - m_Id = value; - m_IdIsSet = true; +void User::validate() +{ + // TODO: implement validation } -bool User::idIsSet() const { return m_IdIsSet; } +web::json::value User::toJson() const +{ + web::json::value val = web::json::value::object(); -void User::unsetId() { m_IdIsSet = false; } + if(m_IdIsSet) + { + val[utility::conversions::to_string_t("id")] = ModelBase::toJson(m_Id); + } + if(m_UsernameIsSet) + { + val[utility::conversions::to_string_t("username")] = ModelBase::toJson(m_Username); + } + if(m_FirstNameIsSet) + { + val[utility::conversions::to_string_t("firstName")] = ModelBase::toJson(m_FirstName); + } + if(m_LastNameIsSet) + { + val[utility::conversions::to_string_t("lastName")] = ModelBase::toJson(m_LastName); + } + if(m_EmailIsSet) + { + val[utility::conversions::to_string_t("email")] = ModelBase::toJson(m_Email); + } + if(m_PasswordIsSet) + { + val[utility::conversions::to_string_t("password")] = ModelBase::toJson(m_Password); + } + if(m_PhoneIsSet) + { + val[utility::conversions::to_string_t("phone")] = ModelBase::toJson(m_Phone); + } + if(m_UserStatusIsSet) + { + val[utility::conversions::to_string_t("userStatus")] = ModelBase::toJson(m_UserStatus); + } -utility::string_t User::getUsername() const { return m_Username; } + return val; +} -void User::setUsername(const utility::string_t &value) { - m_Username = value; - m_UsernameIsSet = true; +void User::fromJson(const web::json::value& val) +{ + if(val.has_field(utility::conversions::to_string_t("id"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id")); + if(!fieldValue.is_null()) + { + setId(ModelBase::int64_tFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("username"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("username")); + if(!fieldValue.is_null()) + { + setUsername(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("firstName"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("firstName")); + if(!fieldValue.is_null()) + { + setFirstName(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("lastName"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("lastName")); + if(!fieldValue.is_null()) + { + setLastName(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("email"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("email")); + if(!fieldValue.is_null()) + { + setEmail(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("password"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("password")); + if(!fieldValue.is_null()) + { + setPassword(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("phone"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("phone")); + if(!fieldValue.is_null()) + { + setPhone(ModelBase::stringFromJson(fieldValue)); + } + } + if(val.has_field(utility::conversions::to_string_t("userStatus"))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("userStatus")); + if(!fieldValue.is_null()) + { + setUserStatus(ModelBase::int32_tFromJson(fieldValue)); + } + } } -bool User::usernameIsSet() const { return m_UsernameIsSet; } +void User::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } -void User::unsetUsername() { m_UsernameIsSet = false; } + if(m_IdIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("id"), m_Id)); + } + if(m_UsernameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("username"), m_Username)); + } + if(m_FirstNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("firstName"), m_FirstName)); + } + if(m_LastNameIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("lastName"), m_LastName)); + } + if(m_EmailIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("email"), m_Email)); + } + if(m_PasswordIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("password"), m_Password)); + } + if(m_PhoneIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("phone"), m_Phone)); + } + if(m_UserStatusIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("userStatus"), m_UserStatus)); + } +} -utility::string_t User::getFirstName() const { return m_FirstName; } +void User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) +{ + utility::string_t namePrefix = prefix; + if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(".")) + { + namePrefix += utility::conversions::to_string_t("."); + } -void User::setFirstName(const utility::string_t &value) { - m_FirstName = value; - m_FirstNameIsSet = true; + if(multipart->hasContent(utility::conversions::to_string_t("id"))) + { + setId(ModelBase::int64_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("id")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("username"))) + { + setUsername(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("username")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("firstName"))) + { + setFirstName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("firstName")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("lastName"))) + { + setLastName(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("lastName")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("email"))) + { + setEmail(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("email")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("password"))) + { + setPassword(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("password")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("phone"))) + { + setPhone(ModelBase::stringFromHttpContent(multipart->getContent(utility::conversions::to_string_t("phone")))); + } + if(multipart->hasContent(utility::conversions::to_string_t("userStatus"))) + { + setUserStatus(ModelBase::int32_tFromHttpContent(multipart->getContent(utility::conversions::to_string_t("userStatus")))); + } } -bool User::firstNameIsSet() const { return m_FirstNameIsSet; } +int64_t User::getId() const +{ + return m_Id; +} -void User::unsetFirstName() { m_FirstNameIsSet = false; } +void User::setId(int64_t value) +{ + m_Id = value; + m_IdIsSet = true; +} -utility::string_t User::getLastName() const { return m_LastName; } +bool User::idIsSet() const +{ + return m_IdIsSet; +} + +void User::unsetId() +{ + m_IdIsSet = false; +} + +utility::string_t User::getUsername() const +{ + return m_Username; +} + +void User::setUsername(const utility::string_t& value) +{ + m_Username = value; + m_UsernameIsSet = true; +} + +bool User::usernameIsSet() const +{ + return m_UsernameIsSet; +} + +void User::unsetUsername() +{ + m_UsernameIsSet = false; +} + +utility::string_t User::getFirstName() const +{ + return m_FirstName; +} + +void User::setFirstName(const utility::string_t& value) +{ + m_FirstName = value; + m_FirstNameIsSet = true; +} + +bool User::firstNameIsSet() const +{ + return m_FirstNameIsSet; +} + +void User::unsetFirstName() +{ + m_FirstNameIsSet = false; +} + +utility::string_t User::getLastName() const +{ + return m_LastName; +} -void User::setLastName(const utility::string_t &value) { - m_LastName = value; - m_LastNameIsSet = true; +void User::setLastName(const utility::string_t& value) +{ + m_LastName = value; + m_LastNameIsSet = true; } -bool User::lastNameIsSet() const { return m_LastNameIsSet; } +bool User::lastNameIsSet() const +{ + return m_LastNameIsSet; +} -void User::unsetLastName() { m_LastNameIsSet = false; } +void User::unsetLastName() +{ + m_LastNameIsSet = false; +} + +utility::string_t User::getEmail() const +{ + return m_Email; +} -utility::string_t User::getEmail() const { return m_Email; } +void User::setEmail(const utility::string_t& value) +{ + m_Email = value; + m_EmailIsSet = true; +} -void User::setEmail(const utility::string_t &value) { - m_Email = value; - m_EmailIsSet = true; +bool User::emailIsSet() const +{ + return m_EmailIsSet; } -bool User::emailIsSet() const { return m_EmailIsSet; } +void User::unsetEmail() +{ + m_EmailIsSet = false; +} -void User::unsetEmail() { m_EmailIsSet = false; } +utility::string_t User::getPassword() const +{ + return m_Password; +} -utility::string_t User::getPassword() const { return m_Password; } +void User::setPassword(const utility::string_t& value) +{ + m_Password = value; + m_PasswordIsSet = true; +} -void User::setPassword(const utility::string_t &value) { - m_Password = value; - m_PasswordIsSet = true; +bool User::passwordIsSet() const +{ + return m_PasswordIsSet; } -bool User::passwordIsSet() const { return m_PasswordIsSet; } +void User::unsetPassword() +{ + m_PasswordIsSet = false; +} -void User::unsetPassword() { m_PasswordIsSet = false; } +utility::string_t User::getPhone() const +{ + return m_Phone; +} -utility::string_t User::getPhone() const { return m_Phone; } +void User::setPhone(const utility::string_t& value) +{ + m_Phone = value; + m_PhoneIsSet = true; +} -void User::setPhone(const utility::string_t &value) { - m_Phone = value; - m_PhoneIsSet = true; +bool User::phoneIsSet() const +{ + return m_PhoneIsSet; } -bool User::phoneIsSet() const { return m_PhoneIsSet; } +void User::unsetPhone() +{ + m_PhoneIsSet = false; +} -void User::unsetPhone() { m_PhoneIsSet = false; } +int32_t User::getUserStatus() const +{ + return m_UserStatus; +} -int32_t User::getUserStatus() const { return m_UserStatus; } +void User::setUserStatus(int32_t value) +{ + m_UserStatus = value; + m_UserStatusIsSet = true; +} -void User::setUserStatus(int32_t value) { - m_UserStatus = value; - m_UserStatusIsSet = true; +bool User::userStatusIsSet() const +{ + return m_UserStatusIsSet; } -bool User::userStatusIsSet() const { return m_UserStatusIsSet; } +void User::unsetUserStatus() +{ + m_UserStatusIsSet = false; +} -void User::unsetUserStatus() { m_UserStatusIsSet = false; } +} +} +} +} -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org diff --git a/samples/client/petstore/cpp-restsdk/model/User.h b/samples/client/petstore/cpp-restsdk/model/User.h index 2c7748e9807..1a177f06832 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.h +++ b/samples/client/petstore/cpp-restsdk/model/User.h @@ -1,7 +1,6 @@ /** * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api - * key `special-key` to test the authorization filters. + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * * OpenAPI spec version: 1.0.0 * @@ -19,6 +18,7 @@ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ + #include "../ModelBase.h" #include <cpprest/details/basic_types.h> @@ -31,121 +31,122 @@ namespace model { /// <summary> /// A User who is purchasing from the pet store /// </summary> -class User : public ModelBase { +class User + : public ModelBase +{ public: - User(); - virtual ~User(); + User(); + virtual ~User(); + + ///////////////////////////////////////////// + /// ModelBase overrides - ///////////////////////////////////////////// - /// ModelBase overrides + void validate() override; - void validate() override; + web::json::value toJson() const override; + void fromJson(const web::json::value& json) override; - web::json::value toJson() const override; - void fromJson(const web::json::value &json) override; + void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; + void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; - void toMultipart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) const override; - void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, - const utility::string_t &namePrefix) override; + ///////////////////////////////////////////// + /// User members - ///////////////////////////////////////////// - /// User members + /// <summary> + /// + /// </summary> + int64_t getId() const; + bool idIsSet() const; + void unsetId(); - /// <summary> - /// - /// </summary> - int64_t getId() const; - bool idIsSet() const; - void unsetId(); + void setId(int64_t value); - void setId(int64_t value); + /// <summary> + /// + /// </summary> + utility::string_t getUsername() const; + bool usernameIsSet() const; + void unsetUsername(); - /// <summary> - /// - /// </summary> - utility::string_t getUsername() const; - bool usernameIsSet() const; - void unsetUsername(); + void setUsername(const utility::string_t& value); - void setUsername(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getFirstName() const; + bool firstNameIsSet() const; + void unsetFirstName(); - /// <summary> - /// - /// </summary> - utility::string_t getFirstName() const; - bool firstNameIsSet() const; - void unsetFirstName(); + void setFirstName(const utility::string_t& value); - void setFirstName(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getLastName() const; + bool lastNameIsSet() const; + void unsetLastName(); - /// <summary> - /// - /// </summary> - utility::string_t getLastName() const; - bool lastNameIsSet() const; - void unsetLastName(); + void setLastName(const utility::string_t& value); - void setLastName(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getEmail() const; + bool emailIsSet() const; + void unsetEmail(); - /// <summary> - /// - /// </summary> - utility::string_t getEmail() const; - bool emailIsSet() const; - void unsetEmail(); + void setEmail(const utility::string_t& value); - void setEmail(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getPassword() const; + bool passwordIsSet() const; + void unsetPassword(); - /// <summary> - /// - /// </summary> - utility::string_t getPassword() const; - bool passwordIsSet() const; - void unsetPassword(); + void setPassword(const utility::string_t& value); - void setPassword(const utility::string_t &value); + /// <summary> + /// + /// </summary> + utility::string_t getPhone() const; + bool phoneIsSet() const; + void unsetPhone(); - /// <summary> - /// - /// </summary> - utility::string_t getPhone() const; - bool phoneIsSet() const; - void unsetPhone(); + void setPhone(const utility::string_t& value); - void setPhone(const utility::string_t &value); + /// <summary> + /// User Status + /// </summary> + int32_t getUserStatus() const; + bool userStatusIsSet() const; + void unsetUserStatus(); - /// <summary> - /// User Status - /// </summary> - int32_t getUserStatus() const; - bool userStatusIsSet() const; - void unsetUserStatus(); + void setUserStatus(int32_t value); - void setUserStatus(int32_t value); protected: - int64_t m_Id; - bool m_IdIsSet; - utility::string_t m_Username; - bool m_UsernameIsSet; - utility::string_t m_FirstName; - bool m_FirstNameIsSet; - utility::string_t m_LastName; - bool m_LastNameIsSet; - utility::string_t m_Email; - bool m_EmailIsSet; - utility::string_t m_Password; - bool m_PasswordIsSet; - utility::string_t m_Phone; - bool m_PhoneIsSet; - int32_t m_UserStatus; - bool m_UserStatusIsSet; + int64_t m_Id; + bool m_IdIsSet; + utility::string_t m_Username; + bool m_UsernameIsSet; + utility::string_t m_FirstName; + bool m_FirstNameIsSet; + utility::string_t m_LastName; + bool m_LastNameIsSet; + utility::string_t m_Email; + bool m_EmailIsSet; + utility::string_t m_Password; + bool m_PasswordIsSet; + utility::string_t m_Phone; + bool m_PhoneIsSet; + int32_t m_UserStatus; + bool m_UserStatusIsSet; }; -} // namespace model -} // namespace client -} // namespace openapitools -} // namespace org +} +} +} +} #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ */ -- GitLab