[[BUG][C][cpp-restsdk] Missing Set.h when trying to generate from Twitter OpenAPI JSON #9969](https://github.com/OpenAPITools/openapi-generator/issues/9969) (#18631)

- Handling `std::set` in cpp-restdsk
    - Member variables using `std:set` added to `Pet` in cpp-restsdk 3.0 Petstore sample

[cpp-pistache-server] taking into account a remark on this issue about cpp-pistache-server and its set management

    - Switching `std::vector` to `std::set` for openapi set type in cpp-pistache-server
This commit is contained in:
Marc Le Bihan 2024-05-15 08:51:59 +02:00 committed by GitHub
parent 4e61738348
commit 1fa2d474b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
76 changed files with 10150 additions and 36 deletions

View File

@ -0,0 +1,6 @@
generatorName: cpp-restsdk
outputDir: samples/client/petstore/cpp-restsdk/client-everything
inputSpec: modules/openapi-generator/src/test/resources/3_0/issues-anytype-object-set-petstore-everything.yaml
templateDir: modules/openapi-generator/src/main/resources/cpp-rest-sdk-client
additionalProperties:
packageName: CppRestPetstoreClient

View File

@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---------- | ------- |
|nlohmann::json|#include <nlohmann/json.hpp>|
|std::map|#include <map>|
|std::set|#include <set>|
|std::string|#include <string>|
|std::vector|#include <vector>|

View File

@ -36,6 +36,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|HttpContent|#include "HttpContent.h"|
|Object|#include "Object.h"|
|std::map|#include <map>|
|std::set|#include <set>|
|std::string|#include <string>|
|std::vector|#include <vector>|
|utility::datetime|#include <cpprest/details/basic_types.h>|

View File

@ -70,7 +70,10 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
/** std:map (for map) */
private static final String STD_MAP = "std::map";
/** std:vector (for array, set) */
/** std:set (for set) */
private static final String STD_SET = "std::set";
/** std:vector (for array) */
private static final String STD_VECTOR = "std::vector";
@Override
@ -148,7 +151,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
typeMapping.put("boolean", "bool");
typeMapping.put("array", STD_VECTOR);
typeMapping.put("map", STD_MAP);
typeMapping.put("set", STD_VECTOR);
typeMapping.put("set", STD_SET);
typeMapping.put("file", STD_STRING);
typeMapping.put("object", NLOHMANN_JSON);
typeMapping.put("binary", STD_STRING);
@ -161,6 +164,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
super.importMapping = new HashMap<>();
importMapping.put(STD_VECTOR, "#include <vector>");
importMapping.put(STD_MAP, "#include <map>");
importMapping.put(STD_SET, "#include <set>");
importMapping.put(STD_STRING, "#include <string>");
importMapping.put(NLOHMANN_JSON, "#include <nlohmann/json.hpp>");

View File

@ -20,7 +20,6 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.servers.Server;
@ -161,6 +160,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
typeMapping.put("long", "int64_t");
typeMapping.put("boolean", "bool");
typeMapping.put("array", "std::vector");
typeMapping.put("set", "std::set");
typeMapping.put("map", "std::map");
typeMapping.put("file", "HttpContent");
typeMapping.put("object", "Object");
@ -173,6 +173,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
super.importMapping = new HashMap<>();
importMapping.put("std::vector", "#include <vector>");
importMapping.put("std::map", "#include <map>");
importMapping.put("std::set", "#include <set>");
importMapping.put("std::string", "#include <string>");
importMapping.put("HttpContent", "#include \"HttpContent.h\"");
importMapping.put("Object", "#include \"Object.h\"");

View File

@ -13,6 +13,7 @@
#include <sstream>
#include <vector>
#include <map>
#include <set>
namespace {{helpersNamespace}}
{
@ -82,6 +83,15 @@ namespace {{helpersNamespace}}
return true;
}
/// <summary>
/// Determine if the given vector<T> only has unique elements. T must provide the == operator.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::set<T>& set)
{
return true;
}
std::string toStringValue(const std::string &value);
std::string toStringValue(const int32_t value);
std::string toStringValue(const int64_t value);

View File

@ -17,6 +17,7 @@
#include <cpprest/json.h>
#include <map>
#include <set>
#include <vector>
{{#modelNamespaceDeclarations}}
@ -52,6 +53,8 @@ public:
static utility::string_t toString( const std::shared_ptr<T>& val );
template <typename T>
static utility::string_t toString( const std::vector<T> & val );
template <typename T>
static utility::string_t toString( const std::set<T> & val );
static web::json::value toJson( bool val );
static web::json::value toJson( float val );
@ -68,6 +71,8 @@ public:
template<typename T>
static web::json::value toJson( const std::vector<T>& val );
template<typename T>
static web::json::value toJson( const std::set<T>& val );
template<typename T>
static web::json::value toJson( const std::map<utility::string_t, T>& val );
static bool fromString( const utility::string_t& val, bool & );
@ -85,6 +90,8 @@ public:
template<typename T>
static bool fromString( const utility::string_t& val, std::vector<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::set<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::map<utility::string_t, T> & );
static bool fromJson( const web::json::value& val, bool & );
@ -102,6 +109,8 @@ public:
template<typename T>
static bool fromJson( const web::json::value& val, std::vector<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::set<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::map<utility::string_t, T> & );
@ -120,6 +129,8 @@ public:
template <typename 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("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::set<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, bool & );
@ -136,6 +147,8 @@ public:
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::set<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & );
static utility::string_t toBase64( utility::string_t value );
@ -155,6 +168,8 @@ utility::string_t ModelBase::toString( const std::shared_ptr<T>& val )
}
return utility::string_t(ss.str());
}
// std::vector to string
template<typename T>
utility::string_t ModelBase::toString( const std::vector<T> & val )
{
@ -169,6 +184,24 @@ utility::string_t ModelBase::toString( const std::vector<T> & val )
}
return strArray;
}
// std::set to string
template<typename T>
utility::string_t ModelBase::toString( const std::set<T> & val )
{
utility::string_t strArray;
for ( const auto &item : val )
{
strArray.append( toString(item) + "," );
}
if (val.count() > 0)
{
strArray.pop_back();
}
return strArray;
}
template<typename T>
web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
{
@ -179,6 +212,8 @@ web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
}
return retVal;
}
// std::vector to json
template<typename T>
web::json::value ModelBase::toJson( const std::vector<T>& value )
{
@ -189,6 +224,21 @@ web::json::value ModelBase::toJson( const std::vector<T>& value )
}
return web::json::value::array(ret);
}
// std::set to json
template<typename T>
web::json::value ModelBase::toJson( const std::set<T>& value )
{
// There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array.
std::vector<web::json::value> ret;
for ( const auto& x : value )
{
ret.push_back( toJson(x) );
}
return web::json::value::array(ret);
}
template<typename T>
web::json::value ModelBase::toJson( const std::map<utility::string_t, T>& val )
{
@ -279,6 +329,7 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& n
}
return content;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType )
{
@ -290,6 +341,7 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
return content;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType )
{

View File

@ -725,6 +725,44 @@ components:
- available
- pending
- sold
certificates:
description: pedigree and other certificates
type: array
uniqueItems: true
items:
type: string
vaccinationBook:
description: Vaccination book of the pet
type: object
required:
- vaccines
properties:
vaccines:
type: array
uniqueItems: true
items:
title: vaccine
type: object
required:
- date
- boosterRequired
properties:
date:
format: date
description: vaccination date
boosterRequired:
type: boolean
description: true if a booster is still needed to complete the vaccination
xml:
name: Pet
ApiResponse:

View File

@ -763,9 +763,9 @@ components:
- pending
- sold
# ---------------------------------------------------------
# Properties that dedicate this configuration to this issue
# ---------------------------------------------------------
# -----------------------------------------------------------------------
# Properties that dedicate this configuration to some issues or checkings
# -----------------------------------------------------------------------
# https://github.com/OpenAPITools/openapi-generator/issues/2769
# object property (leading to Object.h)
@ -782,21 +782,44 @@ components:
description: to help you installing your pet at home
# Leading to Set.h
certificates:
description: pedigree and other certificates
type: array
uniqueItems: true
items:
type: string
# https://github.com/OpenAPITools/openapi-generator/issues/14234
bestFriends:
description: Pet best friends!
vaccinationBook:
description: Vaccination book of the pet
type: object
required:
- bestFriends
- vaccines
properties:
bestFriends:
vaccines:
type: array
uniqueItems: true
items:
type: string
title: vaccine
type: object
required:
- date
- boosterRequired
properties:
date:
format: date
description: vaccination date
boosterRequired:
type: boolean
description: true if a booster is still needed to complete the vaccination
xml:
name: Pet

View File

@ -0,0 +1,29 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app

View File

@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,46 @@
.gitignore
CMakeLists.txt
Config.cmake.in
README.md
git_push.sh
include/CppRestPetstoreClient/AnyType.h
include/CppRestPetstoreClient/ApiClient.h
include/CppRestPetstoreClient/ApiConfiguration.h
include/CppRestPetstoreClient/ApiException.h
include/CppRestPetstoreClient/HttpContent.h
include/CppRestPetstoreClient/IHttpBody.h
include/CppRestPetstoreClient/JsonBody.h
include/CppRestPetstoreClient/ModelBase.h
include/CppRestPetstoreClient/MultipartFormData.h
include/CppRestPetstoreClient/Object.h
include/CppRestPetstoreClient/api/PetApi.h
include/CppRestPetstoreClient/api/StoreApi.h
include/CppRestPetstoreClient/api/UserApi.h
include/CppRestPetstoreClient/model/ApiResponse.h
include/CppRestPetstoreClient/model/Category.h
include/CppRestPetstoreClient/model/Order.h
include/CppRestPetstoreClient/model/Pet.h
include/CppRestPetstoreClient/model/Pet_vaccinationBook.h
include/CppRestPetstoreClient/model/Tag.h
include/CppRestPetstoreClient/model/User.h
include/CppRestPetstoreClient/model/Vaccine.h
src/AnyType.cpp
src/ApiClient.cpp
src/ApiConfiguration.cpp
src/ApiException.cpp
src/HttpContent.cpp
src/JsonBody.cpp
src/ModelBase.cpp
src/MultipartFormData.cpp
src/Object.cpp
src/api/PetApi.cpp
src/api/StoreApi.cpp
src/api/UserApi.cpp
src/model/ApiResponse.cpp
src/model/Category.cpp
src/model/Order.cpp
src/model/Pet.cpp
src/model/Pet_vaccinationBook.cpp
src/model/Tag.cpp
src/model/User.cpp
src/model/Vaccine.cpp

View File

@ -0,0 +1 @@
7.6.0-SNAPSHOT

View File

@ -0,0 +1,93 @@
#
# 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.
#
# The version of the OpenAPI document: 1.0.0
#
# https://openapi-generator.tech
#
# NOTE: Auto generated by OpenAPI Generator (https://openapi-generator.tech).
cmake_minimum_required (VERSION 3.1)
project(CppRestPetstoreClient)
# Force -fPIC even if the project is configured for building a static library.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
find_package(cpprestsdk REQUIRED)
find_package(Boost REQUIRED)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
file(GLOB_RECURSE HEADER_FILES "include/*.h")
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wno-unused-variable>
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if (UNIX)
message(STATUS "Building client library for Linux/Unix")
if (BUILD_SHARED_LIBS)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest crypto)
endif()
else()
message(STATUS "Building client library for Windows")
if (BUILD_SHARED_LIBS)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers cpprestsdk::cpprest bcrypt)
endif()
endif()
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
EXPORT ${PROJECT_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

View File

@ -0,0 +1,5 @@
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
check_required_components("@PROJECT_NAME@")

View File

@ -0,0 +1,51 @@
# C++ API client
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI spec](https://openapis.org) from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version:
- Generator version: 7.6.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.CppRestSdkClientCodegen
- API namespace: org.openapitools.client.api
- Model namespace: org.openapitools.client.model
## Installation
### Prerequisites
Install [cpprestsdk](https://github.com/Microsoft/cpprestsdk).
- Windows: `vcpkg install cpprestsdk cpprestsdk:x64-windows boost-uuid boost-uuid:x64-windows`
- Mac: `brew install cpprestsdk`
- Linux: `sudo apt-get install libcpprest-dev`
### Build
```sh
cmake -DCPPREST_ROOT=/usr -DCMAKE_CXX_FLAGS="-I/usr/local/opt/openssl/include" -DCMAKE_MODULE_LINKER_FLAGS="-L/usr/local/opt/openssl/lib"
make
```
### Build on Windows with Visual Studio (VS2017)
- Right click on folder containing source code
- Select 'Open in visual studio'
- Once visual studio opens, CMake should show up in top menu bar.
- Select CMake > Build All.
*Note: If the CMake menu item doesn't show up in Visual Studio, CMake
for Visual Studio must be installed. In this case, open the 'Visual Studio
Installer' application. Select 'modify' Visual Studio 2017. Make sure
'Desktop Development with C++' is installed, and specifically that 'Visual
C++ tools for CMake' is selected in the 'Installation Details' section.
Also be sure to review the CMakeLists.txt file. Edits are likely required.*
## Author

View File

@ -0,0 +1,57 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4
if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=$(git remote)
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,58 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* AnyType.h
*
* This is the implementation of an any JSON type.
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_
#include "CppRestPetstoreClient/Object.h"
#include <cpprest/details/basic_types.h>
#include <cpprest/json.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class AnyType : public Object {
public:
AnyType();
virtual ~AnyType();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value &json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart,
const utility::string_t &namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
const utility::string_t &namePrefix) override;
private:
web::json::value m_value;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_AnyType_H_ */

View File

@ -0,0 +1,114 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ApiClient.h
*
* This is an API client responsible for stating the HTTP calls
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_
#define ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_
#include "CppRestPetstoreClient/ApiConfiguration.h"
#include "CppRestPetstoreClient/ApiException.h"
#include "CppRestPetstoreClient/IHttpBody.h"
#include "CppRestPetstoreClient/HttpContent.h"
#if defined (_WIN32) || defined (_WIN64)
#undef U
#endif
#include <cpprest/details/basic_types.h>
#include <cpprest/http_client.h>
#include <memory>
#include <vector>
#include <functional>
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
class ApiClient
{
public:
ApiClient( std::shared_ptr<const ApiConfiguration> configuration = nullptr );
virtual ~ApiClient();
typedef std::function<void(web::http::status_code, const web::http::http_headers&)> ResponseHandlerType;
const ResponseHandlerType& getResponseHandler() const;
void setResponseHandler(const ResponseHandlerType& responseHandler);
std::shared_ptr<const ApiConfiguration> getConfiguration() const;
void setConfiguration(std::shared_ptr<const 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);
static utility::string_t parameterToString(bool value);
template<class T>
static utility::string_t parameterToString(const std::vector<T>& value);
template<class T>
static utility::string_t parameterToString(const std::shared_ptr<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:
ResponseHandlerType m_ResponseHandler;
std::shared_ptr<const ApiConfiguration> m_Configuration;
};
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]);
}
return ss.str();
}
template<class T>
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
{
return parameterToString(*value.get());
}
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiClient_H_ */

View File

@ -0,0 +1,66 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ApiConfiguration.h
*
* This class represents a single item of a multipart-formdata request.
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_
#define ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_
#include <cpprest/details/basic_types.h>
#include <cpprest/http_client.h>
#include <map>
namespace org {
namespace openapitools {
namespace client {
namespace api {
class ApiConfiguration
{
public:
ApiConfiguration();
virtual ~ApiConfiguration();
const web::http::client::http_client_config& getHttpConfig() const;
void setHttpConfig( web::http::client::http_client_config& 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 );
std::map<utility::string_t, utility::string_t>& getDefaultHeaders();
const std::map<utility::string_t, utility::string_t>& getDefaultHeaders() const;
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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiConfiguration_H_ */

View File

@ -0,0 +1,60 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ApiException.h
*
* This is the exception being thrown in case the api call was not successful
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_
#define ORG_OPENAPITOOLS_CLIENT_API_ApiException_H_
#include <cpprest/details/basic_types.h>
#include <cpprest/http_msg.h>
#include <memory>
#include <map>
namespace org {
namespace openapitools {
namespace client {
namespace api {
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;
protected:
std::shared_ptr<std::istream> m_Content;
std::map<utility::string_t, utility::string_t> m_Headers;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_ApiBase_H_ */

View File

@ -0,0 +1,69 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* HttpContent.h
*
* This class represents a single item of a multipart-formdata request.
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_
#include <cpprest/details/basic_types.h>
#include <memory>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class HttpContent
{
public:
HttpContent();
virtual ~HttpContent();
virtual utility::string_t getContentDisposition() const;
virtual void setContentDisposition( const utility::string_t& value );
virtual utility::string_t getName() const;
virtual void setName( const utility::string_t& value );
virtual utility::string_t getFileName() const;
virtual void setFileName( const utility::string_t& value );
virtual utility::string_t getContentType() const;
virtual void setContentType( const utility::string_t& value );
virtual std::shared_ptr<std::istream> getData() const;
virtual void setData( std::shared_ptr<std::istream> value );
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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_HttpContent_H_ */

View File

@ -0,0 +1,42 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* IHttpBody.h
*
* This is the interface for contents that can be sent to a remote HTTP server.
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_
#include <iostream>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class IHttpBody
{
public:
virtual ~IHttpBody() { }
virtual void writeTo( std::ostream& stream ) = 0;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_IHttpBody_H_ */

View File

@ -0,0 +1,49 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* JsonBody.h
*
* This is a JSON http body which can be submitted via http
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_
#include "CppRestPetstoreClient/IHttpBody.h"
#include <cpprest/json.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class JsonBody
: public IHttpBody
{
public:
JsonBody( const web::json::value& value );
virtual ~JsonBody();
void writeTo( std::ostream& target ) override;
protected:
web::json::value m_Json;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_JsonBody_H_ */

View File

@ -0,0 +1,394 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ModelBase.h
*
* This is the base class for all model classes
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_
#include "CppRestPetstoreClient/HttpContent.h"
#include "CppRestPetstoreClient/MultipartFormData.h"
#include <cpprest/details/basic_types.h>
#include <cpprest/json.h>
#include <map>
#include <set>
#include <vector>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class ModelBase
{
public:
ModelBase();
virtual ~ModelBase();
virtual void validate() = 0;
virtual web::json::value toJson() const = 0;
virtual bool fromJson( const web::json::value& json ) = 0;
virtual void toMultipart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) const = 0;
virtual bool fromMultiPart( std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix ) = 0;
virtual bool isSet() const;
static utility::string_t toString( const bool val );
static utility::string_t toString( const float val );
static utility::string_t toString( const double val );
static utility::string_t toString( const int32_t val );
static utility::string_t toString( const int64_t val );
static utility::string_t toString( const utility::string_t &val );
static utility::string_t toString( const utility::datetime &val );
static utility::string_t toString( const web::json::value &val );
static utility::string_t toString( const std::shared_ptr<HttpContent>& val );
template <typename T>
static utility::string_t toString( const std::shared_ptr<T>& val );
template <typename T>
static utility::string_t toString( const std::vector<T> & val );
template <typename T>
static utility::string_t toString( const std::set<T> & val );
static web::json::value toJson( bool val );
static web::json::value toJson( float val );
static web::json::value toJson( double val );
static web::json::value toJson( int32_t val );
static web::json::value toJson( int64_t val );
static web::json::value toJson( const utility::string_t& val );
static web::json::value toJson( const utility::datetime& val );
static web::json::value toJson( const web::json::value& val );
static web::json::value toJson( const std::shared_ptr<HttpContent>& val );
template<typename T>
static web::json::value toJson( const std::shared_ptr<T>& val );
static web::json::value toJson( const std::shared_ptr<utility::datetime>& val );
template<typename T>
static web::json::value toJson( const std::vector<T>& val );
template<typename T>
static web::json::value toJson( const std::set<T>& val );
template<typename T>
static web::json::value toJson( const std::map<utility::string_t, T>& val );
static bool fromString( const utility::string_t& val, bool & );
static bool fromString( const utility::string_t& val, float & );
static bool fromString( const utility::string_t& val, double & );
static bool fromString( const utility::string_t& val, int32_t & );
static bool fromString( const utility::string_t& val, int64_t & );
static bool fromString( const utility::string_t& val, utility::string_t & );
static bool fromString( const utility::string_t& val, utility::datetime & );
static bool fromString( const utility::string_t& val, web::json::value & );
static bool fromString( const utility::string_t& val, std::shared_ptr<HttpContent> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::shared_ptr<T>& );
static bool fromString( const utility::string_t& val, std::shared_ptr<utility::datetime>& outVal );
template<typename T>
static bool fromString( const utility::string_t& val, std::vector<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::set<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::map<utility::string_t, T> & );
static bool fromJson( const web::json::value& val, bool & );
static bool fromJson( const web::json::value& val, float & );
static bool fromJson( const web::json::value& val, double & );
static bool fromJson( const web::json::value& val, int32_t & );
static bool fromJson( const web::json::value& val, int64_t & );
static bool fromJson( const web::json::value& val, utility::string_t & );
static bool fromJson( const web::json::value& val, utility::datetime & );
static bool fromJson( const web::json::value& val, web::json::value & );
static bool fromJson( const web::json::value& val, std::shared_ptr<HttpContent> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::shared_ptr<T>& );
static bool fromJson( const web::json::value& val, std::shared_ptr<utility::datetime> &outVal );
template<typename T>
static bool fromJson( const web::json::value& val, std::vector<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::set<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::map<utility::string_t, T> & );
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, float 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("") );
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, 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, 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, const std::shared_ptr<HttpContent>& );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<T>& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
static std::shared_ptr<HttpContent> toHttpContent(const utility::string_t& name, const std::shared_ptr<utility::datetime>& value , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
template <typename 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("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::set<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, bool & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, float & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, double & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int64_t & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, int32_t & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::string_t & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::datetime & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, web::json::value & );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::set<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & );
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 );
protected:
bool m_IsSet;
};
template <typename T>
utility::string_t ModelBase::toString( const std::shared_ptr<T>& val )
{
utility::stringstream_t ss;
if( val != nullptr )
{
val->toJson().serialize(ss);
}
return utility::string_t(ss.str());
}
// std::vector to string
template<typename T>
utility::string_t ModelBase::toString( const std::vector<T> & val )
{
utility::string_t strArray;
for ( const auto &item : val )
{
strArray.append( toString(item) + "," );
}
if (val.count() > 0)
{
strArray.pop_back();
}
return strArray;
}
// std::set to string
template<typename T>
utility::string_t ModelBase::toString( const std::set<T> & val )
{
utility::string_t strArray;
for ( const auto &item : val )
{
strArray.append( toString(item) + "," );
}
if (val.count() > 0)
{
strArray.pop_back();
}
return strArray;
}
template<typename T>
web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
{
web::json::value retVal;
if(val != nullptr)
{
retVal = val->toJson();
}
return retVal;
}
// std::vector to json
template<typename T>
web::json::value ModelBase::toJson( const std::vector<T>& value )
{
std::vector<web::json::value> ret;
for ( const auto& x : value )
{
ret.push_back( toJson(x) );
}
return web::json::value::array(ret);
}
// std::set to json
template<typename T>
web::json::value ModelBase::toJson( const std::set<T>& value )
{
// There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array.
std::vector<web::json::value> ret;
for ( const auto& x : value )
{
ret.push_back( toJson(x) );
}
return web::json::value::array(ret);
}
template<typename T>
web::json::value ModelBase::toJson( const std::map<utility::string_t, T>& val )
{
web::json::value obj;
for ( const auto &itemkey : val )
{
obj[itemkey.first] = toJson( itemkey.second );
}
return obj;
}
template<typename T>
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<T>& outVal )
{
bool ok = false;
if(outVal == nullptr)
{
outVal = std::shared_ptr<T>(new T());
}
if( outVal != nullptr )
{
ok = outVal->fromJson(web::json::value::parse(val));
}
return ok;
}
template<typename T>
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<T> &outVal )
{
bool ok = false;
if(outVal == nullptr)
{
outVal = std::shared_ptr<T>(new T());
}
if( outVal != nullptr )
{
ok = outVal->fromJson(val);
}
return ok;
}
template<typename T>
bool ModelBase::fromJson( const web::json::value& val, std::vector<T> &outVal )
{
bool ok = true;
if (val.is_array())
{
for (const web::json::value & jitem : val.as_array())
{
T item;
ok &= fromJson(jitem, item);
outVal.push_back(item);
}
}
else
{
ok = false;
}
return ok;
}
template<typename T>
bool ModelBase::fromJson( const web::json::value& jval, std::map<utility::string_t, T> &outVal )
{
bool ok = true;
if ( jval.is_object() )
{
auto obj = jval.as_object();
for( auto objItr = obj.begin() ; objItr != obj.end() ; objItr++ )
{
T itemVal;
ok &= fromJson(objItr->second, itemVal);
outVal.insert(std::pair<utility::string_t, T>(objItr->first, itemVal));
}
}
else
{
ok = false;
}
return ok;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr<T>& value , const utility::string_t& contentType )
{
std::shared_ptr<HttpContent> content( new HttpContent );
if (value != nullptr )
{
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->toJson().serialize() ) ) ) );
}
return content;
}
template <typename 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;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType )
{
web::json::value jobj = 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(jobj.serialize()) ) ) );
return content;
}
template <typename T>
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& outVal )
{
utility::string_t str;
if(val == nullptr) return false;
if( outVal == nullptr )
{
outVal = std::shared_ptr<T>(new T());
}
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
template <typename T>
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & )
{
return true;
}
template <typename T>
bool ModelBase::fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & )
{
return true;
}
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ModelBase_H_ */

View File

@ -0,0 +1,61 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* MultipartFormData.h
*
* 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 "CppRestPetstoreClient/IHttpBody.h"
#include "CppRestPetstoreClient/HttpContent.h"
#include <cpprest/details/basic_types.h>
#include <vector>
#include <map>
#include <memory>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class MultipartFormData
: public IHttpBody
{
public:
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 );
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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_MultipartFormData_H_ */

View File

@ -0,0 +1,62 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Object.h
*
* This is the implementation of a JSON object.
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
#include <cpprest/json.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class Object : public ModelBase
{
public:
Object();
virtual ~Object();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool 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);
private:
web::json::value m_object;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Object_H_ */

View File

@ -0,0 +1,150 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* PetApi.h
*
*
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_
#define ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_
#include "CppRestPetstoreClient/ApiClient.h"
#include "CppRestPetstoreClient/model/ApiResponse.h"
#include "CppRestPetstoreClient/HttpContent.h"
#include "CppRestPetstoreClient/model/Pet.h"
#include <vector>
#include <cpprest/details/basic_types.h>
#include <boost/optional.hpp>
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
class PetApi
{
public:
explicit PetApi( std::shared_ptr<const 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<std::shared_ptr<Pet>> addPet(
std::shared_ptr<Pet> pet
) const;
/// <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(&quot;&quot;))</param>
pplx::task<void> deletePet(
int64_t petId,
boost::optional<utility::string_t> apiKey
) const;
/// <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
) const;
/// <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
) const;
/// <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
) const;
/// <summary>
/// Update an existing pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="pet">Pet object that needs to be added to the store</param>
pplx::task<std::shared_ptr<Pet>> updatePet(
std::shared_ptr<Pet> pet
) const;
/// <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(&quot;&quot;))</param>
/// <param name="status">Updated status of the pet (optional, default to utility::conversions::to_string_t(&quot;&quot;))</param>
pplx::task<void> updatePetWithForm(
int64_t petId,
boost::optional<utility::string_t> name,
boost::optional<utility::string_t> status
) const;
/// <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(&quot;&quot;))</param>
/// <param name="file">file to upload (optional, default to utility::conversions::to_string_t(&quot;&quot;))</param>
pplx::task<std::shared_ptr<ApiResponse>> uploadFile(
int64_t petId,
boost::optional<utility::string_t> additionalMetadata,
boost::optional<std::shared_ptr<HttpContent>> file
) const;
protected:
std::shared_ptr<const ApiClient> m_ApiClient;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_PetApi_H_ */

View File

@ -0,0 +1,96 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* StoreApi.h
*
*
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_
#define ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_
#include "CppRestPetstoreClient/ApiClient.h"
#include "CppRestPetstoreClient/model/Order.h"
#include <map>
#include <cpprest/details/basic_types.h>
#include <boost/optional.hpp>
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
class StoreApi
{
public:
explicit StoreApi( std::shared_ptr<const ApiClient> apiClient );
virtual ~StoreApi();
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt; 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
) const;
/// <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(
) const;
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generate exceptions
/// </remarks>
/// <param name="orderId">ID of pet that needs to be fetched</param>
pplx::task<std::shared_ptr<Order>> getOrderById(
int64_t orderId
) const;
/// <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
) const;
protected:
std::shared_ptr<const ApiClient> m_ApiClient;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_StoreApi_H_ */

View File

@ -0,0 +1,140 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* UserApi.h
*
*
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_
#define ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_
#include "CppRestPetstoreClient/ApiClient.h"
#include "CppRestPetstoreClient/model/User.h"
#include <vector>
#include <cpprest/details/basic_types.h>
#include <boost/optional.hpp>
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
class UserApi
{
public:
explicit UserApi( std::shared_ptr<const 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
) const;
/// <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
) const;
/// <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
) const;
/// <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
) const;
/// <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
) const;
/// <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
) const;
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <remarks>
///
/// </remarks>
pplx::task<void> logoutUser(
) const;
/// <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
) const;
protected:
std::shared_ptr<const ApiClient> m_ApiClient;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_API_UserApi_H_ */

View File

@ -0,0 +1,99 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* ApiResponse.h
*
* Describes the result of uploading an image resource
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
/// Describes the result of uploading an image resource
/// </summary>
class ApiResponse
: public ModelBase
{
public:
ApiResponse();
virtual ~ApiResponse();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// ApiResponse members
/// <summary>
///
/// </summary>
int32_t getCode() const;
bool codeIsSet() const;
void unsetCode();
void setCode(int32_t value);
/// <summary>
///
/// </summary>
utility::string_t getType() const;
bool typeIsSet() const;
void unsetType();
void setType(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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_ */

View File

@ -0,0 +1,88 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Category.h
*
* A category for a pet
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
/// A category for a pet
/// </summary>
class Category
: public ModelBase
{
public:
Category();
virtual ~Category();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Category members
/// <summary>
///
/// </summary>
int64_t getId() const;
bool idIsSet() const;
void unsetId();
void setId(int64_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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_ */

View File

@ -0,0 +1,132 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Order.h
*
* An order for a pets from the pet store
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
/// An order for a pets from the pet store
/// </summary>
class Order
: public ModelBase
{
public:
Order();
virtual ~Order();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Order members
/// <summary>
///
/// </summary>
int64_t getId() const;
bool idIsSet() const;
void unsetId();
void setId(int64_t value);
/// <summary>
///
/// </summary>
int64_t getPetId() const;
bool petIdIsSet() const;
void unsetPetId();
void setPetId(int64_t value);
/// <summary>
///
/// </summary>
int32_t getQuantity() const;
bool quantityIsSet() const;
void unsetQuantity();
void setQuantity(int32_t value);
/// <summary>
///
/// </summary>
utility::datetime getShipDate() const;
bool shipDateIsSet() const;
void unsetShipDate();
void setShipDate(const utility::datetime& value);
/// <summary>
/// Order Status
/// </summary>
utility::string_t getStatus() const;
bool statusIsSet() const;
void unsetStatus();
void setStatus(const utility::string_t& 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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_ */

View File

@ -0,0 +1,186 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Pet.h
*
* A pet for sale in the pet store
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include "CppRestPetstoreClient/model/Tag.h"
#include "CppRestPetstoreClient/model/Category.h"
#include <cpprest/details/basic_types.h>
#include "CppRestPetstoreClient/Object.h"
#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h"
#include <vector>
#include "CppRestPetstoreClient/AnyType.h"
#include <set>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class Category;
class Tag;
class Pet_vaccinationBook;
/// <summary>
/// A pet for sale in the pet store
/// </summary>
class Pet
: public ModelBase
{
public:
Pet();
virtual ~Pet();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Pet members
/// <summary>
///
/// </summary>
int64_t getId() const;
bool idIsSet() const;
void unsetId();
void setId(int64_t value);
/// <summary>
///
/// </summary>
std::shared_ptr<Category> getCategory() const;
bool categoryIsSet() const;
void unsetCategory();
void setCategory(const std::shared_ptr<Category>& value);
/// <summary>
///
/// </summary>
utility::string_t getName() const;
bool nameIsSet() const;
void unsetName();
void setName(const utility::string_t& value);
/// <summary>
///
/// </summary>
std::vector<utility::string_t>& getPhotoUrls();
bool photoUrlsIsSet() const;
void unsetPhotoUrls();
void setPhotoUrls(const std::vector<utility::string_t>& value);
/// <summary>
///
/// </summary>
std::vector<std::shared_ptr<Tag>>& getTags();
bool tagsIsSet() const;
void unsetTags();
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();
void setStatus(const utility::string_t& value);
/// <summary>
/// last veterinarian visit advice
/// </summary>
std::shared_ptr<Object> getVeterinarianVisit() const;
bool veterinarianVisitIsSet() const;
void unsetVeterinarianVisit();
void setVeterinarianVisit(const std::shared_ptr<Object>& value);
/// <summary>
/// to help you installing your pet at home
/// </summary>
std::vector<std::shared_ptr<AnyType>>& getGoodies();
bool goodiesIsSet() const;
void unsetGoodies();
void setGoodies(const std::vector<std::shared_ptr<AnyType>>& value);
/// <summary>
/// pedigree and other certificates
/// </summary>
std::set<utility::string_t>& getCertificates();
bool certificatesIsSet() const;
void unsetCertificates();
void setCertificates(const std::set<utility::string_t>& value);
/// <summary>
///
/// </summary>
std::shared_ptr<Pet_vaccinationBook> getVaccinationBook() const;
bool vaccinationBookIsSet() const;
void unsetVaccinationBook();
void setVaccinationBook(const std::shared_ptr<Pet_vaccinationBook>& value);
protected:
int64_t m_Id;
bool m_IdIsSet;
std::shared_ptr<Category> m_Category;
bool m_CategoryIsSet;
utility::string_t m_Name;
bool m_NameIsSet;
std::vector<utility::string_t> m_PhotoUrls;
bool m_PhotoUrlsIsSet;
std::vector<std::shared_ptr<Tag>> m_Tags;
bool m_TagsIsSet;
utility::string_t m_Status;
bool m_StatusIsSet;
std::shared_ptr<Object> m_VeterinarianVisit;
bool m_VeterinarianVisitIsSet;
std::vector<std::shared_ptr<AnyType>> m_Goodies;
bool m_GoodiesIsSet;
std::set<utility::string_t> m_Certificates;
bool m_CertificatesIsSet;
std::shared_ptr<Pet_vaccinationBook> m_VaccinationBook;
bool m_VaccinationBookIsSet;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_ */

View File

@ -0,0 +1,79 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Pet_vaccinationBook.h
*
* Vaccination book of the pet
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include "CppRestPetstoreClient/model/Vaccine.h"
#include <set>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class Vaccine;
/// <summary>
/// Vaccination book of the pet
/// </summary>
class Pet_vaccinationBook
: public ModelBase
{
public:
Pet_vaccinationBook();
virtual ~Pet_vaccinationBook();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Pet_vaccinationBook members
/// <summary>
///
/// </summary>
std::set<std::shared_ptr<Vaccine>>& getVaccines();
bool vaccinesIsSet() const;
void unsetVaccines();
void setVaccines(const std::set<std::shared_ptr<Vaccine>>& value);
protected:
std::set<std::shared_ptr<Vaccine>> m_Vaccines;
bool m_VaccinesIsSet;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ */

View File

@ -0,0 +1,88 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Tag.h
*
* A tag for a pet
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
/// A tag for a pet
/// </summary>
class Tag
: public ModelBase
{
public:
Tag();
virtual ~Tag();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Tag members
/// <summary>
///
/// </summary>
int64_t getId() const;
bool idIsSet() const;
void unsetId();
void setId(int64_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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_ */

View File

@ -0,0 +1,154 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* User.h
*
* A User who is purchasing from the pet store
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
/// A User who is purchasing from the pet store
/// </summary>
class User
: public ModelBase
{
public:
User();
virtual ~User();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// User members
/// <summary>
///
/// </summary>
int64_t getId() const;
bool idIsSet() const;
void unsetId();
void setId(int64_t value);
/// <summary>
///
/// </summary>
utility::string_t getUsername() const;
bool usernameIsSet() const;
void unsetUsername();
void setUsername(const utility::string_t& value);
/// <summary>
///
/// </summary>
utility::string_t getFirstName() const;
bool firstNameIsSet() const;
void unsetFirstName();
void setFirstName(const utility::string_t& value);
/// <summary>
///
/// </summary>
utility::string_t getLastName() const;
bool lastNameIsSet() const;
void unsetLastName();
void setLastName(const utility::string_t& value);
/// <summary>
///
/// </summary>
utility::string_t getEmail() const;
bool emailIsSet() const;
void unsetEmail();
void setEmail(const utility::string_t& value);
/// <summary>
///
/// </summary>
utility::string_t getPassword() const;
bool passwordIsSet() const;
void unsetPassword();
void setPassword(const utility::string_t& value);
/// <summary>
///
/// </summary>
utility::string_t getPhone() const;
bool phoneIsSet() const;
void unsetPhone();
void setPhone(const utility::string_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;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_ */

View File

@ -0,0 +1,88 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Vaccine.h
*
*
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include "CppRestPetstoreClient/AnyType.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
///
/// </summary>
class Vaccine
: public ModelBase
{
public:
Vaccine();
virtual ~Vaccine();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Vaccine members
/// <summary>
/// vaccination date
/// </summary>
std::shared_ptr<AnyType> getDate() const;
bool dateIsSet() const;
void unsetdate();
void setDate(const std::shared_ptr<AnyType>& value);
/// <summary>
/// true if a booster is still needed to complete the vaccination
/// </summary>
bool isBoosterRequired() const;
bool boosterRequiredIsSet() const;
void unsetBoosterRequired();
void setBoosterRequired(bool value);
protected:
std::shared_ptr<AnyType> m_date;
bool m_dateIsSet;
bool m_BoosterRequired;
bool m_BoosterRequiredIsSet;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ */

View File

@ -0,0 +1,52 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/AnyType.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
AnyType::AnyType() { m_value = web::json::value::null(); }
AnyType::~AnyType() {}
void AnyType::validate() {}
web::json::value AnyType::toJson() const { return m_value; }
bool AnyType::fromJson(const web::json::value &val) {
m_value = val;
m_IsSet = true;
return isSet();
}
void AnyType::toMultipart(std::shared_ptr<MultipartFormData> multipart,
const utility::string_t &prefix) const {
if (m_value.is_object()) {
return Object::toMultipart(multipart, prefix);
}
throw std::runtime_error("AnyType::toMultipart: unsupported type");
}
bool AnyType::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
const utility::string_t &prefix) {
if (m_value.is_object()) {
return Object::fromMultiPart(multipart, prefix);
}
return false;
}
}
}
}
}

View File

@ -0,0 +1,208 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/ApiClient.h"
#include "CppRestPetstoreClient/MultipartFormData.h"
#include "CppRestPetstoreClient/ModelBase.h"
#include <sstream>
#include <limits>
#include <iomanip>
template <typename T>
utility::string_t toString(const T value)
{
utility::ostringstream_t out;
out << std::setprecision(std::numeric_limits<T>::digits10) << std::fixed << value;
return out.str();
}
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
ApiClient::ApiClient(std::shared_ptr<const ApiConfiguration> configuration )
: m_Configuration(configuration)
{
}
ApiClient::~ApiClient()
{
}
const ApiClient::ResponseHandlerType& ApiClient::getResponseHandler() const {
return m_ResponseHandler;
}
void ApiClient::setResponseHandler(const ResponseHandlerType& responseHandler) {
m_ResponseHandler = responseHandler;
}
std::shared_ptr<const ApiConfiguration> ApiClient::getConfiguration() const
{
return m_Configuration;
}
void ApiClient::setConfiguration(std::shared_ptr<const ApiConfiguration> configuration)
{
m_Configuration = configuration;
}
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(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(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(bool value)
{
std::stringstream valueAsStringStream;
valueAsStringStream << std::boolalpha << value;
return utility::conversions::to_string_t(valueAsStringStream.str());
}
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 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 (const auto& kvp : headerParams)
{
request.headers().add(kvp.first, kvp.second);
}
if (fileParams.size() > 0)
{
MultipartFormData uploadData;
for (const auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
for (const auto& kvp : fileParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
const 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();
const 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 (!formParams.empty())
{
request.set_body(body_data);
}
}
else
{
web::http::uri_builder formData;
for (const 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 (const 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);
}
}
}
}
}

View File

@ -0,0 +1,85 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/ApiConfiguration.h"
namespace org {
namespace openapitools {
namespace client {
namespace api {
ApiConfiguration::ApiConfiguration()
{
}
ApiConfiguration::~ApiConfiguration()
{
}
const web::http::client::http_client_config& ApiConfiguration::getHttpConfig() const
{
return m_HttpConfig;
}
void ApiConfiguration::setHttpConfig( web::http::client::http_client_config& value )
{
m_HttpConfig = value;
}
utility::string_t ApiConfiguration::getBaseUrl() const
{
return m_BaseUrl;
}
void ApiConfiguration::setBaseUrl( const utility::string_t value )
{
m_BaseUrl = value;
}
utility::string_t ApiConfiguration::getUserAgent() const
{
return m_UserAgent;
}
void ApiConfiguration::setUserAgent( const utility::string_t value )
{
m_UserAgent = value;
}
std::map<utility::string_t, utility::string_t>& ApiConfiguration::getDefaultHeaders()
{
return m_DefaultHeaders;
}
const std::map<utility::string_t, utility::string_t>& ApiConfiguration::getDefaultHeaders() const
{
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("");
}
void ApiConfiguration::setApiKey( const utility::string_t& prefix, const utility::string_t& apiKey )
{
m_ApiKeys[prefix] = apiKey;
}
}
}
}
}

View File

@ -0,0 +1,53 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/ApiException.h"
namespace org {
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()
{
}
std::shared_ptr<std::istream> ApiException::getContent() const
{
return m_Content;
}
std::map<utility::string_t, utility::string_t>& ApiException::getHeaders()
{
return m_Headers;
}
}
}
}
}

View File

@ -0,0 +1,86 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/HttpContent.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
HttpContent::HttpContent()
{
}
HttpContent::~HttpContent()
{
}
utility::string_t HttpContent::getContentDisposition() const
{
return m_ContentDisposition;
}
void HttpContent::setContentDisposition( const utility::string_t & value )
{
m_ContentDisposition = value;
}
utility::string_t HttpContent::getName() const
{
return m_Name;
}
void HttpContent::setName( const utility::string_t & value )
{
m_Name = value;
}
utility::string_t HttpContent::getFileName() const
{
return m_FileName;
}
void HttpContent::setFileName( const utility::string_t & value )
{
m_FileName = value;
}
utility::string_t HttpContent::getContentType() const
{
return m_ContentType;
}
void HttpContent::setContentType( const utility::string_t & value )
{
m_ContentType = value;
}
std::shared_ptr<std::istream> HttpContent::getData() const
{
return m_Data;
}
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();
}
}
}
}
}

View File

@ -0,0 +1,36 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/JsonBody.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
JsonBody::JsonBody( const web::json::value& json)
: m_Json(json)
{
}
JsonBody::~JsonBody()
{
}
void JsonBody::writeTo( std::ostream& target )
{
m_Json.serialize(target);
}
}
}
}
}

View File

@ -0,0 +1,665 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/ModelBase.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
ModelBase::ModelBase(): m_IsSet(false)
{
}
ModelBase::~ModelBase()
{
}
bool ModelBase::isSet() const
{
return m_IsSet;
}
utility::string_t ModelBase::toString( const bool val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString( const float val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString( const double val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString( const int32_t val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString( const int64_t val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString (const utility::string_t &val )
{
utility::stringstream_t ss;
ss << val;
return utility::string_t(ss.str());
}
utility::string_t ModelBase::toString( const utility::datetime &val )
{
return val.to_string(utility::datetime::ISO_8601);
}
utility::string_t ModelBase::toString( const web::json::value &val )
{
return val.serialize();
}
utility::string_t ModelBase::toString( const std::shared_ptr<HttpContent>& val )
{
utility::stringstream_t ss;
if( val != nullptr )
{
ss << val->getData();
}
return utility::string_t(ss.str());
}
web::json::value ModelBase::toJson(bool value)
{
return web::json::value::boolean(value);
}
web::json::value ModelBase::toJson( float 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( 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( 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( const web::json::value& value )
{
return value;
}
web::json::value ModelBase::toJson( const std::shared_ptr<HttpContent>& content )
{
web::json::value value;
if(content != nullptr)
{
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( const std::shared_ptr<utility::datetime>& val )
{
web::json::value retVal;
if(val != nullptr)
{
retVal = toJson(*val);
}
return retVal;
}
bool ModelBase::fromString( const utility::string_t& val, bool &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
success = false;
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, float &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
int64_t intVal = 0;
success = ModelBase::fromString(val, intVal);
if(success)
{
outVal = static_cast<float>(intVal);
}
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, double &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
int64_t intVal = 0;
success = ModelBase::fromString(val, intVal);
if(success)
{
outVal = static_cast<double>(intVal);
}
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, int32_t &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
success = false;
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, int64_t &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
success = false;
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, utility::string_t &outVal )
{
utility::stringstream_t ss(val);
bool success = true;
try
{
ss >> outVal;
}
catch (...)
{
success = false;
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, utility::datetime &outVal )
{
bool success = true;
auto dt = utility::datetime::from_string(val, utility::datetime::ISO_8601);
if( dt.is_initialized() )
{
outVal = dt;
}
else
{
success = false;
}
return success;
}
bool ModelBase::fromString( const utility::string_t& val, web::json::value &outVal )
{
outVal = web::json::value::parse(val);
return !outVal.is_null();
}
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<HttpContent>& outVal )
{
bool ok = true;
if(outVal == nullptr)
{
outVal = std::shared_ptr<HttpContent>(new HttpContent());
}
if(outVal != nullptr)
{
outVal->setData(std::shared_ptr<std::istream>(new std::stringstream(utility::conversions::to_utf8string(val))));
}
else
{
ok = false;
}
return ok;
}
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<utility::datetime>& outVal )
{
bool ok = false;
if(outVal == nullptr)
{
outVal = std::shared_ptr<utility::datetime>(new utility::datetime());
}
if( outVal != nullptr )
{
ok = fromJson(web::json::value::parse(val), *outVal);
}
return ok;
}
bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
{
outVal = !val.is_boolean() ? false : val.as_bool();
return val.is_boolean();
}
bool ModelBase::fromJson( const web::json::value& val, float & outVal )
{
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<float>::quiet_NaN(): static_cast<float>(val.as_double());
return val.is_double() || val.is_integer();
}
bool ModelBase::fromJson( const web::json::value& val, double & outVal )
{
outVal = (!val.is_double() && !val.is_integer()) ? std::numeric_limits<double>::quiet_NaN(): val.as_double();
return val.is_double() || val.is_integer();
}
bool ModelBase::fromJson( const web::json::value& val, int32_t & outVal )
{
outVal = !val.is_integer() ? std::numeric_limits<int32_t>::quiet_NaN() : val.as_integer();
return val.is_integer();
}
bool ModelBase::fromJson( const web::json::value& val, int64_t & outVal )
{
outVal = !val.is_number() ? std::numeric_limits<int64_t>::quiet_NaN() : val.as_number().to_int64();
return val.is_number();
}
bool ModelBase::fromJson( const web::json::value& val, utility::string_t & outVal )
{
outVal = val.is_string() ? val.as_string() : utility::conversions::to_string_t("");
return val.is_string();
}
bool ModelBase::fromJson( const web::json::value& val, utility::datetime & outVal )
{
outVal = val.is_null() ? utility::datetime::from_string(utility::conversions::to_string_t("NULL"), utility::datetime::ISO_8601) : utility::datetime::from_string(val.as_string(), utility::datetime::ISO_8601);
return outVal.is_initialized();
}
bool ModelBase::fromJson( const web::json::value& val, web::json::value & outVal )
{
outVal = val;
return !val.is_null();
}
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpContent>& content )
{
bool result = false;
if( content != nullptr)
{
result = true;
if(content == nullptr)
{
content = std::shared_ptr<HttpContent>(new HttpContent());
}
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
{
utility::string_t value;
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentDisposition")), value);
content->setContentDisposition( value );
}
if(val.has_field(utility::conversions::to_string_t("ContentType")))
{
utility::string_t value;
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("ContentType")), value);
content->setContentType( value );
}
if(val.has_field(utility::conversions::to_string_t("FileName")))
{
utility::string_t value;
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("FileName")), value);
content->setFileName( value );
}
if(val.has_field(utility::conversions::to_string_t("InputStream")))
{
utility::string_t value;
result = result && ModelBase::fromJson(val.at(utility::conversions::to_string_t("InputStream")), value);
content->setData( ModelBase::fromBase64( value ) );
}
}
return result;
}
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<utility::datetime> &outVal )
{
bool ok = false;
if(outVal == nullptr)
{
outVal = std::shared_ptr<utility::datetime>(new utility::datetime());
}
if( outVal != nullptr )
{
ok = fromJson(val, *outVal);
}
return ok;
}
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, bool 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, float 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, 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, 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, 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, const std::shared_ptr<HttpContent>& value )
{
std::shared_ptr<HttpContent> content( new HttpContent );
if( value != nullptr )
{
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 std::shared_ptr<utility::datetime>& value , const utility::string_t& contentType )
{
std::shared_ptr<HttpContent> content( new HttpContent );
if (value != nullptr )
{
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( toJson(*value).serialize() ) ) ) );
}
return content;
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, bool & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, float & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, double & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int32_t & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, int64_t & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::string_t & outVal )
{
if( val == nullptr ) return false;
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>());
outVal = utility::conversions::to_string_t(str);
return true;
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, utility::datetime & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
outVal = utility::datetime::from_string(str, utility::datetime::ISO_8601);
return true;
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, web::json::value & outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& outVal )
{
utility::string_t str;
if( val == nullptr ) return false;
if( outVal == nullptr )
{
outVal = std::shared_ptr<HttpContent>(new HttpContent());
}
ModelBase::fromHttpContent(val, str);
return fromString(str, outVal);
}
// 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;
}
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;
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;
}
outBuf[0] = (temp >> 16) & 0x000000FF;
outBuf[1] = (temp >> 8) & 0x000000FF;
outBuf[2] = (temp) & 0x000000FF;
result->write( outBuf, 3 );
}
return result;
}
}
}
}
}

View File

@ -0,0 +1,112 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/MultipartFormData.h"
#include "CppRestPetstoreClient/ModelBase.h"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
namespace org {
namespace openapitools {
namespace client {
namespace model {
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()
{
}
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;
}
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;
}
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--" << utility::conversions::to_utf8string( m_Boundary ) << "--\r\n";
}
}
}
}
}

View File

@ -0,0 +1,91 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/Object.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
Object::Object()
{
m_object = web::json::value::object();
}
Object::~Object()
{
}
void Object::validate()
{
}
web::json::value Object::toJson() const
{
return m_object;
}
bool Object::fromJson(const web::json::value& val)
{
if (val.is_object())
{
m_object = val;
m_IsSet = true;
}
return isSet();
}
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));
}
bool 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(".");
}
if( ModelBase::fromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")), m_object ) )
{
m_IsSet = true;
}
return isSet();
}
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)
{
if( !value.is_null() )
{
m_object[key] = value;
m_IsSet = true;
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,552 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/api/StoreApi.h"
#include "CppRestPetstoreClient/IHttpBody.h"
#include "CppRestPetstoreClient/JsonBody.h"
#include "CppRestPetstoreClient/MultipartFormData.h"
#include <boost/algorithm/string/replace.hpp>
#include <unordered_set>
namespace org {
namespace openapitools {
namespace client {
namespace api {
using namespace org::openapitools::client::model;
StoreApi::StoreApi( std::shared_ptr<const ApiClient> apiClient )
: m_ApiClient(apiClient)
{
}
StoreApi::~StoreApi()
{
}
pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) const
{
std::shared_ptr<const 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("}"), web::uri::encode_uri(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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
{
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
}
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)
{
if (m_ApiClient->getResponseHandler())
{
m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
}
// 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()));
}
// 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()));
}
}
return localVarResponse.extract_string();
})
.then([=](utility::string_t localVarResponse)
{
return void();
});
}
pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() const
{
std::shared_ptr<const 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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
{
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
}
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)
{
if (m_ApiClient->getResponseHandler())
{
m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
}
// 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()));
}
// 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()));
}
}
return localVarResponse.extract_string();
})
.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() )
{
int32_t localVarItemObj;
ModelBase::fromJson(localVarItem.second, localVarItemObj);
localVarResult[localVarItem.first] = localVarItemObj;
}
}
// 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"));
}
return localVarResult;
});
}
pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) const
{
std::shared_ptr<const 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("}"), web::uri::encode_uri(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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
{
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
}
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)
{
if (m_ApiClient->getResponseHandler())
{
m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
}
// 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()));
}
// 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()));
}
}
return localVarResponse.extract_string();
})
.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);
ModelBase::fromJson(localVarJson, localVarResult);
}
// 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"));
}
return localVarResult;
});
}
pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> order) const
{
// 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<const 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;
localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
{
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
}
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)
{
if (m_ApiClient->getResponseHandler())
{
m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
}
// 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()));
}
// 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()));
}
}
return localVarResponse.extract_string();
})
.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);
ModelBase::fromJson(localVarJson, localVarResult);
}
// 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"));
}
return localVarResult;
});
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,216 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/ApiResponse.h"
namespace org {
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()
{
}
void ApiResponse::validate()
{
// TODO: implement validation
}
web::json::value ApiResponse::toJson() const
{
web::json::value val = web::json::value::object();
if(m_CodeIsSet)
{
val[utility::conversions::to_string_t(U("code"))] = ModelBase::toJson(m_Code);
}
if(m_TypeIsSet)
{
val[utility::conversions::to_string_t(U("type"))] = ModelBase::toJson(m_Type);
}
if(m_MessageIsSet)
{
val[utility::conversions::to_string_t(U("message"))] = ModelBase::toJson(m_Message);
}
return val;
}
bool ApiResponse::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("code"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("code")));
if(!fieldValue.is_null())
{
int32_t refVal_setCode;
ok &= ModelBase::fromJson(fieldValue, refVal_setCode);
setCode(refVal_setCode);
}
}
if(val.has_field(utility::conversions::to_string_t(U("type"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("type")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setType;
ok &= ModelBase::fromJson(fieldValue, refVal_setType);
setType(refVal_setType);
}
}
if(val.has_field(utility::conversions::to_string_t(U("message"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("message")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setMessage;
ok &= ModelBase::fromJson(fieldValue, refVal_setMessage);
setMessage(refVal_setMessage);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_CodeIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("code")), m_Code));
}
if(m_TypeIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("type")), m_Type));
}
if(m_MessageIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("message")), m_Message));
}
}
bool ApiResponse::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("code"))))
{
int32_t refVal_setCode;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("code"))), refVal_setCode );
setCode(refVal_setCode);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("type"))))
{
utility::string_t refVal_setType;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("type"))), refVal_setType );
setType(refVal_setType);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("message"))))
{
utility::string_t refVal_setMessage;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("message"))), refVal_setMessage );
setMessage(refVal_setMessage);
}
return ok;
}
int32_t ApiResponse::getCode() const
{
return m_Code;
}
void ApiResponse::setCode(int32_t value)
{
m_Code = value;
m_CodeIsSet = true;
}
bool ApiResponse::codeIsSet() const
{
return m_CodeIsSet;
}
void ApiResponse::unsetCode()
{
m_CodeIsSet = false;
}
utility::string_t ApiResponse::getType() const
{
return m_Type;
}
void ApiResponse::setType(const utility::string_t& value)
{
m_Type = value;
m_TypeIsSet = true;
}
bool ApiResponse::typeIsSet() const
{
return m_TypeIsSet;
}
void ApiResponse::unsetType()
{
m_TypeIsSet = false;
}
utility::string_t ApiResponse::getMessage() const
{
return m_Message;
}
void ApiResponse::setMessage(const utility::string_t& value)
{
m_Message = value;
m_MessageIsSet = true;
}
bool ApiResponse::messageIsSet() const
{
return m_MessageIsSet;
}
void ApiResponse::unsetMessage()
{
m_MessageIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,170 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Category.h"
namespace org {
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()
{
}
void Category::validate()
{
// TODO: implement validation
}
web::json::value Category::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
{
val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id);
}
if(m_NameIsSet)
{
val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name);
}
return val;
}
bool Category::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
ok &= ModelBase::fromJson(fieldValue, refVal_setId);
setId(refVal_setId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("name"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setName;
ok &= ModelBase::fromJson(fieldValue, refVal_setName);
setName(refVal_setName);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
}
if(m_NameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name));
}
}
bool Category::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("name"))))
{
utility::string_t refVal_setName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName );
setName(refVal_setName);
}
return ok;
}
int64_t Category::getId() const
{
return m_Id;
}
void Category::setId(int64_t value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Category::idIsSet() const
{
return m_IdIsSet;
}
void Category::unsetId()
{
m_IdIsSet = false;
}
utility::string_t Category::getName() const
{
return m_Name;
}
void Category::setName(const utility::string_t& value)
{
m_Name = value;
m_NameIsSet = true;
}
bool Category::nameIsSet() const
{
return m_NameIsSet;
}
void Category::unsetName()
{
m_NameIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,354 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Order.h"
namespace org {
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(U("id"))] = ModelBase::toJson(m_Id);
}
if(m_PetIdIsSet)
{
val[utility::conversions::to_string_t(U("petId"))] = ModelBase::toJson(m_PetId);
}
if(m_QuantityIsSet)
{
val[utility::conversions::to_string_t(U("quantity"))] = ModelBase::toJson(m_Quantity);
}
if(m_ShipDateIsSet)
{
val[utility::conversions::to_string_t(U("shipDate"))] = ModelBase::toJson(m_ShipDate);
}
if(m_StatusIsSet)
{
val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status);
}
if(m_CompleteIsSet)
{
val[utility::conversions::to_string_t(U("complete"))] = ModelBase::toJson(m_Complete);
}
return val;
}
bool Order::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
ok &= ModelBase::fromJson(fieldValue, refVal_setId);
setId(refVal_setId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("petId"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("petId")));
if(!fieldValue.is_null())
{
int64_t refVal_setPetId;
ok &= ModelBase::fromJson(fieldValue, refVal_setPetId);
setPetId(refVal_setPetId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("quantity"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("quantity")));
if(!fieldValue.is_null())
{
int32_t refVal_setQuantity;
ok &= ModelBase::fromJson(fieldValue, refVal_setQuantity);
setQuantity(refVal_setQuantity);
}
}
if(val.has_field(utility::conversions::to_string_t(U("shipDate"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("shipDate")));
if(!fieldValue.is_null())
{
utility::datetime refVal_setShipDate;
ok &= ModelBase::fromJson(fieldValue, refVal_setShipDate);
setShipDate(refVal_setShipDate);
}
}
if(val.has_field(utility::conversions::to_string_t(U("status"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("status")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setStatus;
ok &= ModelBase::fromJson(fieldValue, refVal_setStatus);
setStatus(refVal_setStatus);
}
}
if(val.has_field(utility::conversions::to_string_t(U("complete"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("complete")));
if(!fieldValue.is_null())
{
bool refVal_setComplete;
ok &= ModelBase::fromJson(fieldValue, refVal_setComplete);
setComplete(refVal_setComplete);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
}
if(m_PetIdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("petId")), m_PetId));
}
if(m_QuantityIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("quantity")), m_Quantity));
}
if(m_ShipDateIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("shipDate")), m_ShipDate));
}
if(m_StatusIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status));
}
if(m_CompleteIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("complete")), m_Complete));
}
}
bool Order::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("petId"))))
{
int64_t refVal_setPetId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("petId"))), refVal_setPetId );
setPetId(refVal_setPetId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("quantity"))))
{
int32_t refVal_setQuantity;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("quantity"))), refVal_setQuantity );
setQuantity(refVal_setQuantity);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("shipDate"))))
{
utility::datetime refVal_setShipDate;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("shipDate"))), refVal_setShipDate );
setShipDate(refVal_setShipDate);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("status"))))
{
utility::string_t refVal_setStatus;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus );
setStatus(refVal_setStatus);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("complete"))))
{
bool refVal_setComplete;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("complete"))), refVal_setComplete );
setComplete(refVal_setComplete);
}
return ok;
}
int64_t Order::getId() const
{
return m_Id;
}
void Order::setId(int64_t value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Order::idIsSet() const
{
return m_IdIsSet;
}
void Order::unsetId()
{
m_IdIsSet = false;
}
int64_t Order::getPetId() const
{
return m_PetId;
}
void Order::setPetId(int64_t value)
{
m_PetId = value;
m_PetIdIsSet = true;
}
bool Order::petIdIsSet() const
{
return m_PetIdIsSet;
}
void Order::unsetPetId()
{
m_PetIdIsSet = false;
}
int32_t Order::getQuantity() const
{
return m_Quantity;
}
void Order::setQuantity(int32_t value)
{
m_Quantity = value;
m_QuantityIsSet = true;
}
bool Order::quantityIsSet() const
{
return m_QuantityIsSet;
}
void Order::unsetQuantity()
{
m_QuantityIsSet = false;
}
utility::datetime Order::getShipDate() const
{
return m_ShipDate;
}
void Order::setShipDate(const utility::datetime& value)
{
m_ShipDate = value;
m_ShipDateIsSet = true;
}
bool Order::shipDateIsSet() const
{
return m_ShipDateIsSet;
}
void Order::unsetShipDate()
{
m_ShipDateIsSet = false;
}
utility::string_t Order::getStatus() const
{
return m_Status;
}
void Order::setStatus(const utility::string_t& value)
{
m_Status = value;
m_StatusIsSet = true;
}
bool Order::statusIsSet() const
{
return m_StatusIsSet;
}
void Order::unsetStatus()
{
m_StatusIsSet = false;
}
bool Order::isComplete() const
{
return m_Complete;
}
void Order::setComplete(bool value)
{
m_Complete = value;
m_CompleteIsSet = true;
}
bool Order::completeIsSet() const
{
return m_CompleteIsSet;
}
void Order::unsetComplete()
{
m_CompleteIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,531 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Pet.h"
namespace org {
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_NameIsSet = false;
m_PhotoUrlsIsSet = false;
m_TagsIsSet = false;
m_Status = utility::conversions::to_string_t("");
m_StatusIsSet = false;
m_VeterinarianVisitIsSet = false;
m_GoodiesIsSet = false;
m_CertificatesIsSet = false;
m_VaccinationBookIsSet = false;
}
Pet::~Pet()
{
}
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(U("id"))] = ModelBase::toJson(m_Id);
}
if(m_CategoryIsSet)
{
val[utility::conversions::to_string_t(U("category"))] = ModelBase::toJson(m_Category);
}
if(m_NameIsSet)
{
val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name);
}
if(m_PhotoUrlsIsSet)
{
val[utility::conversions::to_string_t(U("photoUrls"))] = ModelBase::toJson(m_PhotoUrls);
}
if(m_TagsIsSet)
{
val[utility::conversions::to_string_t(U("tags"))] = ModelBase::toJson(m_Tags);
}
if(m_StatusIsSet)
{
val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status);
}
if(m_VeterinarianVisitIsSet)
{
val[utility::conversions::to_string_t(U("veterinarianVisit"))] = ModelBase::toJson(m_VeterinarianVisit);
}
if(m_GoodiesIsSet)
{
val[utility::conversions::to_string_t(U("goodies"))] = ModelBase::toJson(m_Goodies);
}
if(m_CertificatesIsSet)
{
val[utility::conversions::to_string_t(U("certificates"))] = ModelBase::toJson(m_Certificates);
}
if(m_VaccinationBookIsSet)
{
val[utility::conversions::to_string_t(U("vaccinationBook"))] = ModelBase::toJson(m_VaccinationBook);
}
return val;
}
bool Pet::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
ok &= ModelBase::fromJson(fieldValue, refVal_setId);
setId(refVal_setId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("category"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("category")));
if(!fieldValue.is_null())
{
std::shared_ptr<Category> refVal_setCategory;
ok &= ModelBase::fromJson(fieldValue, refVal_setCategory);
setCategory(refVal_setCategory);
}
}
if(val.has_field(utility::conversions::to_string_t(U("name"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setName;
ok &= ModelBase::fromJson(fieldValue, refVal_setName);
setName(refVal_setName);
}
}
if(val.has_field(utility::conversions::to_string_t(U("photoUrls"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("photoUrls")));
if(!fieldValue.is_null())
{
std::vector<utility::string_t> refVal_setPhotoUrls;
ok &= ModelBase::fromJson(fieldValue, refVal_setPhotoUrls);
setPhotoUrls(refVal_setPhotoUrls);
}
}
if(val.has_field(utility::conversions::to_string_t(U("tags"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("tags")));
if(!fieldValue.is_null())
{
std::vector<std::shared_ptr<Tag>> refVal_setTags;
ok &= ModelBase::fromJson(fieldValue, refVal_setTags);
setTags(refVal_setTags);
}
}
if(val.has_field(utility::conversions::to_string_t(U("status"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("status")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setStatus;
ok &= ModelBase::fromJson(fieldValue, refVal_setStatus);
setStatus(refVal_setStatus);
}
}
if(val.has_field(utility::conversions::to_string_t(U("veterinarianVisit"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("veterinarianVisit")));
if(!fieldValue.is_null())
{
std::shared_ptr<Object> refVal_setVeterinarianVisit;
ok &= ModelBase::fromJson(fieldValue, refVal_setVeterinarianVisit);
setVeterinarianVisit(refVal_setVeterinarianVisit);
}
}
if(val.has_field(utility::conversions::to_string_t(U("goodies"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("goodies")));
if(!fieldValue.is_null())
{
std::vector<std::shared_ptr<AnyType>> refVal_setGoodies;
ok &= ModelBase::fromJson(fieldValue, refVal_setGoodies);
setGoodies(refVal_setGoodies);
}
}
if(val.has_field(utility::conversions::to_string_t(U("certificates"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("certificates")));
if(!fieldValue.is_null())
{
std::set<utility::string_t> refVal_setCertificates;
ok &= ModelBase::fromJson(fieldValue, refVal_setCertificates);
setCertificates(refVal_setCertificates);
}
}
if(val.has_field(utility::conversions::to_string_t(U("vaccinationBook"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccinationBook")));
if(!fieldValue.is_null())
{
std::shared_ptr<Pet_vaccinationBook> refVal_setVaccinationBook;
ok &= ModelBase::fromJson(fieldValue, refVal_setVaccinationBook);
setVaccinationBook(refVal_setVaccinationBook);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
}
if(m_CategoryIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("category")), m_Category));
}
if(m_NameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name));
}
if(m_PhotoUrlsIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("photoUrls")), m_PhotoUrls));
}
if(m_TagsIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("tags")), m_Tags));
}
if(m_StatusIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status));
}
if(m_VeterinarianVisitIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("veterinarianVisit")), m_VeterinarianVisit));
}
if(m_GoodiesIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("goodies")), m_Goodies));
}
if(m_CertificatesIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("certificates")), m_Certificates));
}
if(m_VaccinationBookIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccinationBook")), m_VaccinationBook));
}
}
bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("category"))))
{
std::shared_ptr<Category> refVal_setCategory;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("category"))), refVal_setCategory );
setCategory(refVal_setCategory);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("name"))))
{
utility::string_t refVal_setName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName );
setName(refVal_setName);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("photoUrls"))))
{
std::vector<utility::string_t> refVal_setPhotoUrls;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("photoUrls"))), refVal_setPhotoUrls );
setPhotoUrls(refVal_setPhotoUrls);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("tags"))))
{
std::vector<std::shared_ptr<Tag>> refVal_setTags;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("tags"))), refVal_setTags );
setTags(refVal_setTags);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("status"))))
{
utility::string_t refVal_setStatus;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus );
setStatus(refVal_setStatus);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("veterinarianVisit"))))
{
std::shared_ptr<Object> refVal_setVeterinarianVisit;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("veterinarianVisit"))), refVal_setVeterinarianVisit );
setVeterinarianVisit(refVal_setVeterinarianVisit);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("goodies"))))
{
std::vector<std::shared_ptr<AnyType>> refVal_setGoodies;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("goodies"))), refVal_setGoodies );
setGoodies(refVal_setGoodies);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("certificates"))))
{
std::set<utility::string_t> refVal_setCertificates;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("certificates"))), refVal_setCertificates );
setCertificates(refVal_setCertificates);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("vaccinationBook"))))
{
std::shared_ptr<Pet_vaccinationBook> refVal_setVaccinationBook;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccinationBook"))), refVal_setVaccinationBook );
setVaccinationBook(refVal_setVaccinationBook);
}
return ok;
}
int64_t Pet::getId() const
{
return m_Id;
}
void Pet::setId(int64_t value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Pet::idIsSet() const
{
return m_IdIsSet;
}
void Pet::unsetId()
{
m_IdIsSet = false;
}
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;
}
bool Pet::categoryIsSet() const
{
return m_CategoryIsSet;
}
void Pet::unsetCategory()
{
m_CategoryIsSet = false;
}
utility::string_t Pet::getName() const
{
return m_Name;
}
void Pet::setName(const utility::string_t& value)
{
m_Name = value;
m_NameIsSet = true;
}
bool Pet::nameIsSet() const
{
return m_NameIsSet;
}
void Pet::unsetName()
{
m_NameIsSet = false;
}
std::vector<utility::string_t>& Pet::getPhotoUrls()
{
return m_PhotoUrls;
}
void Pet::setPhotoUrls(const std::vector<utility::string_t>& value)
{
m_PhotoUrls = value;
m_PhotoUrlsIsSet = true;
}
bool Pet::photoUrlsIsSet() const
{
return m_PhotoUrlsIsSet;
}
void Pet::unsetPhotoUrls()
{
m_PhotoUrlsIsSet = false;
}
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;
}
bool Pet::tagsIsSet() const
{
return m_TagsIsSet;
}
void Pet::unsetTags()
{
m_TagsIsSet = false;
}
utility::string_t Pet::getStatus() const
{
return m_Status;
}
void Pet::setStatus(const utility::string_t& value)
{
m_Status = value;
m_StatusIsSet = true;
}
bool Pet::statusIsSet() const
{
return m_StatusIsSet;
}
void Pet::unsetStatus()
{
m_StatusIsSet = false;
}
std::shared_ptr<Object> Pet::getVeterinarianVisit() const
{
return m_VeterinarianVisit;
}
void Pet::setVeterinarianVisit(const std::shared_ptr<Object>& value)
{
m_VeterinarianVisit = value;
m_VeterinarianVisitIsSet = true;
}
bool Pet::veterinarianVisitIsSet() const
{
return m_VeterinarianVisitIsSet;
}
void Pet::unsetVeterinarianVisit()
{
m_VeterinarianVisitIsSet = false;
}
std::vector<std::shared_ptr<AnyType>>& Pet::getGoodies()
{
return m_Goodies;
}
void Pet::setGoodies(const std::vector<std::shared_ptr<AnyType>>& value)
{
m_Goodies = value;
m_GoodiesIsSet = true;
}
bool Pet::goodiesIsSet() const
{
return m_GoodiesIsSet;
}
void Pet::unsetGoodies()
{
m_GoodiesIsSet = false;
}
std::set<utility::string_t>& Pet::getCertificates()
{
return m_Certificates;
}
void Pet::setCertificates(const std::set<utility::string_t>& value)
{
m_Certificates = value;
m_CertificatesIsSet = true;
}
bool Pet::certificatesIsSet() const
{
return m_CertificatesIsSet;
}
void Pet::unsetCertificates()
{
m_CertificatesIsSet = false;
}
std::shared_ptr<Pet_vaccinationBook> Pet::getVaccinationBook() const
{
return m_VaccinationBook;
}
void Pet::setVaccinationBook(const std::shared_ptr<Pet_vaccinationBook>& value)
{
m_VaccinationBook = value;
m_VaccinationBookIsSet = true;
}
bool Pet::vaccinationBookIsSet() const
{
return m_VaccinationBookIsSet;
}
void Pet::unsetVaccinationBook()
{
m_VaccinationBookIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,123 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
Pet_vaccinationBook::Pet_vaccinationBook()
{
m_VaccinesIsSet = false;
}
Pet_vaccinationBook::~Pet_vaccinationBook()
{
}
void Pet_vaccinationBook::validate()
{
// TODO: implement validation
}
web::json::value Pet_vaccinationBook::toJson() const
{
web::json::value val = web::json::value::object();
if(m_VaccinesIsSet)
{
val[utility::conversions::to_string_t(U("vaccines"))] = ModelBase::toJson(m_Vaccines);
}
return val;
}
bool Pet_vaccinationBook::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("vaccines"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccines")));
if(!fieldValue.is_null())
{
std::set<std::shared_ptr<Vaccine>> refVal_setVaccines;
ok &= ModelBase::fromJson(fieldValue, refVal_setVaccines);
setVaccines(refVal_setVaccines);
}
}
return ok;
}
void Pet_vaccinationBook::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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_VaccinesIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccines")), m_Vaccines));
}
}
bool Pet_vaccinationBook::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("vaccines"))))
{
std::set<std::shared_ptr<Vaccine>> refVal_setVaccines;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccines"))), refVal_setVaccines );
setVaccines(refVal_setVaccines);
}
return ok;
}
std::set<std::shared_ptr<Vaccine>>& Pet_vaccinationBook::getVaccines()
{
return m_Vaccines;
}
void Pet_vaccinationBook::setVaccines(const std::set<std::shared_ptr<Vaccine>>& value)
{
m_Vaccines = value;
m_VaccinesIsSet = true;
}
bool Pet_vaccinationBook::vaccinesIsSet() const
{
return m_VaccinesIsSet;
}
void Pet_vaccinationBook::unsetVaccines()
{
m_VaccinesIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,170 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Tag.h"
namespace org {
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()
{
}
void Tag::validate()
{
// TODO: implement validation
}
web::json::value Tag::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
{
val[utility::conversions::to_string_t(U("id"))] = ModelBase::toJson(m_Id);
}
if(m_NameIsSet)
{
val[utility::conversions::to_string_t(U("name"))] = ModelBase::toJson(m_Name);
}
return val;
}
bool Tag::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
ok &= ModelBase::fromJson(fieldValue, refVal_setId);
setId(refVal_setId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("name"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("name")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setName;
ok &= ModelBase::fromJson(fieldValue, refVal_setName);
setName(refVal_setName);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
}
if(m_NameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("name")), m_Name));
}
}
bool Tag::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("name"))))
{
utility::string_t refVal_setName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("name"))), refVal_setName );
setName(refVal_setName);
}
return ok;
}
int64_t Tag::getId() const
{
return m_Id;
}
void Tag::setId(int64_t value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Tag::idIsSet() const
{
return m_IdIsSet;
}
void Tag::unsetId()
{
m_IdIsSet = false;
}
utility::string_t Tag::getName() const
{
return m_Name;
}
void Tag::setName(const utility::string_t& value)
{
m_Name = value;
m_NameIsSet = true;
}
bool Tag::nameIsSet() const
{
return m_NameIsSet;
}
void Tag::unsetName()
{
m_NameIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,446 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/User.h"
namespace org {
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(U("id"))] = ModelBase::toJson(m_Id);
}
if(m_UsernameIsSet)
{
val[utility::conversions::to_string_t(U("username"))] = ModelBase::toJson(m_Username);
}
if(m_FirstNameIsSet)
{
val[utility::conversions::to_string_t(U("firstName"))] = ModelBase::toJson(m_FirstName);
}
if(m_LastNameIsSet)
{
val[utility::conversions::to_string_t(U("lastName"))] = ModelBase::toJson(m_LastName);
}
if(m_EmailIsSet)
{
val[utility::conversions::to_string_t(U("email"))] = ModelBase::toJson(m_Email);
}
if(m_PasswordIsSet)
{
val[utility::conversions::to_string_t(U("password"))] = ModelBase::toJson(m_Password);
}
if(m_PhoneIsSet)
{
val[utility::conversions::to_string_t(U("phone"))] = ModelBase::toJson(m_Phone);
}
if(m_UserStatusIsSet)
{
val[utility::conversions::to_string_t(U("userStatus"))] = ModelBase::toJson(m_UserStatus);
}
return val;
}
bool User::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("id"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("id")));
if(!fieldValue.is_null())
{
int64_t refVal_setId;
ok &= ModelBase::fromJson(fieldValue, refVal_setId);
setId(refVal_setId);
}
}
if(val.has_field(utility::conversions::to_string_t(U("username"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("username")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setUsername;
ok &= ModelBase::fromJson(fieldValue, refVal_setUsername);
setUsername(refVal_setUsername);
}
}
if(val.has_field(utility::conversions::to_string_t(U("firstName"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("firstName")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setFirstName;
ok &= ModelBase::fromJson(fieldValue, refVal_setFirstName);
setFirstName(refVal_setFirstName);
}
}
if(val.has_field(utility::conversions::to_string_t(U("lastName"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("lastName")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setLastName;
ok &= ModelBase::fromJson(fieldValue, refVal_setLastName);
setLastName(refVal_setLastName);
}
}
if(val.has_field(utility::conversions::to_string_t(U("email"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("email")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setEmail;
ok &= ModelBase::fromJson(fieldValue, refVal_setEmail);
setEmail(refVal_setEmail);
}
}
if(val.has_field(utility::conversions::to_string_t(U("password"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("password")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setPassword;
ok &= ModelBase::fromJson(fieldValue, refVal_setPassword);
setPassword(refVal_setPassword);
}
}
if(val.has_field(utility::conversions::to_string_t(U("phone"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("phone")));
if(!fieldValue.is_null())
{
utility::string_t refVal_setPhone;
ok &= ModelBase::fromJson(fieldValue, refVal_setPhone);
setPhone(refVal_setPhone);
}
}
if(val.has_field(utility::conversions::to_string_t(U("userStatus"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("userStatus")));
if(!fieldValue.is_null())
{
int32_t refVal_setUserStatus;
ok &= ModelBase::fromJson(fieldValue, refVal_setUserStatus);
setUserStatus(refVal_setUserStatus);
}
}
return ok;
}
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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_IdIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("id")), m_Id));
}
if(m_UsernameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("username")), m_Username));
}
if(m_FirstNameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("firstName")), m_FirstName));
}
if(m_LastNameIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("lastName")), m_LastName));
}
if(m_EmailIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("email")), m_Email));
}
if(m_PasswordIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("password")), m_Password));
}
if(m_PhoneIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("phone")), m_Phone));
}
if(m_UserStatusIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("userStatus")), m_UserStatus));
}
}
bool User::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("id"))))
{
int64_t refVal_setId;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("id"))), refVal_setId );
setId(refVal_setId);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("username"))))
{
utility::string_t refVal_setUsername;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("username"))), refVal_setUsername );
setUsername(refVal_setUsername);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("firstName"))))
{
utility::string_t refVal_setFirstName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("firstName"))), refVal_setFirstName );
setFirstName(refVal_setFirstName);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("lastName"))))
{
utility::string_t refVal_setLastName;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("lastName"))), refVal_setLastName );
setLastName(refVal_setLastName);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("email"))))
{
utility::string_t refVal_setEmail;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("email"))), refVal_setEmail );
setEmail(refVal_setEmail);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("password"))))
{
utility::string_t refVal_setPassword;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("password"))), refVal_setPassword );
setPassword(refVal_setPassword);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("phone"))))
{
utility::string_t refVal_setPhone;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("phone"))), refVal_setPhone );
setPhone(refVal_setPhone);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("userStatus"))))
{
int32_t refVal_setUserStatus;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("userStatus"))), refVal_setUserStatus );
setUserStatus(refVal_setUserStatus);
}
return ok;
}
int64_t User::getId() const
{
return m_Id;
}
void User::setId(int64_t value)
{
m_Id = value;
m_IdIsSet = true;
}
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;
}
bool User::lastNameIsSet() const
{
return m_LastNameIsSet;
}
void User::unsetLastName()
{
m_LastNameIsSet = false;
}
utility::string_t User::getEmail() const
{
return m_Email;
}
void User::setEmail(const utility::string_t& value)
{
m_Email = value;
m_EmailIsSet = true;
}
bool User::emailIsSet() const
{
return m_EmailIsSet;
}
void User::unsetEmail()
{
m_EmailIsSet = false;
}
utility::string_t User::getPassword() const
{
return m_Password;
}
void User::setPassword(const utility::string_t& value)
{
m_Password = value;
m_PasswordIsSet = true;
}
bool User::passwordIsSet() const
{
return m_PasswordIsSet;
}
void User::unsetPassword()
{
m_PasswordIsSet = false;
}
utility::string_t User::getPhone() const
{
return m_Phone;
}
void User::setPhone(const utility::string_t& value)
{
m_Phone = value;
m_PhoneIsSet = true;
}
bool User::phoneIsSet() const
{
return m_PhoneIsSet;
}
void User::unsetPhone()
{
m_PhoneIsSet = false;
}
int32_t User::getUserStatus() const
{
return m_UserStatus;
}
void User::setUserStatus(int32_t value)
{
m_UserStatus = value;
m_UserStatusIsSet = true;
}
bool User::userStatusIsSet() const
{
return m_UserStatusIsSet;
}
void User::unsetUserStatus()
{
m_UserStatusIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,169 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Vaccine.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
Vaccine::Vaccine()
{
m_dateIsSet = false;
m_BoosterRequired = false;
m_BoosterRequiredIsSet = false;
}
Vaccine::~Vaccine()
{
}
void Vaccine::validate()
{
// TODO: implement validation
}
web::json::value Vaccine::toJson() const
{
web::json::value val = web::json::value::object();
if(m_dateIsSet)
{
val[utility::conversions::to_string_t(U("date"))] = ModelBase::toJson(m_date);
}
if(m_BoosterRequiredIsSet)
{
val[utility::conversions::to_string_t(U("boosterRequired"))] = ModelBase::toJson(m_BoosterRequired);
}
return val;
}
bool Vaccine::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("date"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("date")));
if(!fieldValue.is_null())
{
std::shared_ptr<AnyType> refVal_setDate;
ok &= ModelBase::fromJson(fieldValue, refVal_setDate);
setDate(refVal_setDate);
}
}
if(val.has_field(utility::conversions::to_string_t(U("boosterRequired"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("boosterRequired")));
if(!fieldValue.is_null())
{
bool refVal_setBoosterRequired;
ok &= ModelBase::fromJson(fieldValue, refVal_setBoosterRequired);
setBoosterRequired(refVal_setBoosterRequired);
}
}
return ok;
}
void Vaccine::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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_dateIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("date")), m_date));
}
if(m_BoosterRequiredIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("boosterRequired")), m_BoosterRequired));
}
}
bool Vaccine::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("date"))))
{
std::shared_ptr<AnyType> refVal_setDate;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("date"))), refVal_setDate );
setDate(refVal_setDate);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("boosterRequired"))))
{
bool refVal_setBoosterRequired;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("boosterRequired"))), refVal_setBoosterRequired );
setBoosterRequired(refVal_setBoosterRequired);
}
return ok;
}
std::shared_ptr<AnyType> Vaccine::getDate() const
{
return m_date;
}
void Vaccine::setDate(const std::shared_ptr<AnyType>& value)
{
m_date = value;
m_dateIsSet = true;
}
bool Vaccine::dateIsSet() const
{
return m_dateIsSet;
}
void Vaccine::unsetdate()
{
m_dateIsSet = false;
}
bool Vaccine::isBoosterRequired() const
{
return m_BoosterRequired;
}
void Vaccine::setBoosterRequired(bool value)
{
m_BoosterRequired = value;
m_BoosterRequiredIsSet = true;
}
bool Vaccine::boosterRequiredIsSet() const
{
return m_BoosterRequiredIsSet;
}
void Vaccine::unsetBoosterRequired()
{
m_BoosterRequiredIsSet = false;
}
}
}
}
}

View File

@ -20,8 +20,10 @@ include/CppRestPetstoreClient/model/ApiResponse.h
include/CppRestPetstoreClient/model/Category.h
include/CppRestPetstoreClient/model/Order.h
include/CppRestPetstoreClient/model/Pet.h
include/CppRestPetstoreClient/model/Pet_vaccinationBook.h
include/CppRestPetstoreClient/model/Tag.h
include/CppRestPetstoreClient/model/User.h
include/CppRestPetstoreClient/model/Vaccine.h
src/AnyType.cpp
src/ApiClient.cpp
src/ApiConfiguration.cpp
@ -38,5 +40,7 @@ src/model/ApiResponse.cpp
src/model/Category.cpp
src/model/Order.cpp
src/model/Pet.cpp
src/model/Pet_vaccinationBook.cpp
src/model/Tag.cpp
src/model/User.cpp
src/model/Vaccine.cpp

View File

@ -27,6 +27,7 @@
#include <cpprest/json.h>
#include <map>
#include <set>
#include <vector>
namespace org {
@ -63,6 +64,8 @@ public:
static utility::string_t toString( const std::shared_ptr<T>& val );
template <typename T>
static utility::string_t toString( const std::vector<T> & val );
template <typename T>
static utility::string_t toString( const std::set<T> & val );
static web::json::value toJson( bool val );
static web::json::value toJson( float val );
@ -79,6 +82,8 @@ public:
template<typename T>
static web::json::value toJson( const std::vector<T>& val );
template<typename T>
static web::json::value toJson( const std::set<T>& val );
template<typename T>
static web::json::value toJson( const std::map<utility::string_t, T>& val );
static bool fromString( const utility::string_t& val, bool & );
@ -96,6 +101,8 @@ public:
template<typename T>
static bool fromString( const utility::string_t& val, std::vector<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::set<T> & );
template<typename T>
static bool fromString( const utility::string_t& val, std::map<utility::string_t, T> & );
static bool fromJson( const web::json::value& val, bool & );
@ -113,6 +120,8 @@ public:
template<typename T>
static bool fromJson( const web::json::value& val, std::vector<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::set<T> & );
template<typename T>
static bool fromJson( const web::json::value& val, std::map<utility::string_t, T> & );
@ -131,6 +140,8 @@ public:
template <typename 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("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::set<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
template <typename T>
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
static bool fromHttpContent( std::shared_ptr<HttpContent> val, bool & );
@ -147,6 +158,8 @@ public:
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::set<T> & );
template <typename T>
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::map<utility::string_t, T> & );
static utility::string_t toBase64( utility::string_t value );
@ -166,6 +179,8 @@ utility::string_t ModelBase::toString( const std::shared_ptr<T>& val )
}
return utility::string_t(ss.str());
}
// std::vector to string
template<typename T>
utility::string_t ModelBase::toString( const std::vector<T> & val )
{
@ -180,6 +195,24 @@ utility::string_t ModelBase::toString( const std::vector<T> & val )
}
return strArray;
}
// std::set to string
template<typename T>
utility::string_t ModelBase::toString( const std::set<T> & val )
{
utility::string_t strArray;
for ( const auto &item : val )
{
strArray.append( toString(item) + "," );
}
if (val.count() > 0)
{
strArray.pop_back();
}
return strArray;
}
template<typename T>
web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
{
@ -190,6 +223,8 @@ web::json::value ModelBase::toJson( const std::shared_ptr<T>& val )
}
return retVal;
}
// std::vector to json
template<typename T>
web::json::value ModelBase::toJson( const std::vector<T>& value )
{
@ -200,6 +235,21 @@ web::json::value ModelBase::toJson( const std::vector<T>& value )
}
return web::json::value::array(ret);
}
// std::set to json
template<typename T>
web::json::value ModelBase::toJson( const std::set<T>& value )
{
// There's no protoype web::json::value::array(...) taking a std::set parameter. Converting to std::vector to get an array.
std::vector<web::json::value> ret;
for ( const auto& x : value )
{
ret.push_back( toJson(x) );
}
return web::json::value::array(ret);
}
template<typename T>
web::json::value ModelBase::toJson( const std::map<utility::string_t, T>& val )
{
@ -290,6 +340,7 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& n
}
return content;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType )
{
@ -301,6 +352,7 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) );
return content;
}
template <typename T>
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::map<utility::string_t, T>& value, const utility::string_t& contentType )
{

View File

@ -24,7 +24,9 @@
#include "CppRestPetstoreClient/model/Tag.h"
#include "CppRestPetstoreClient/model/Category.h"
#include <cpprest/details/basic_types.h>
#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h"
#include <vector>
#include <set>
namespace org {
namespace openapitools {
@ -33,6 +35,7 @@ namespace model {
class Category;
class Tag;
class Pet_vaccinationBook;
/// <summary>
/// A pet for sale in the pet store
@ -112,6 +115,24 @@ public:
void setStatus(const utility::string_t& value);
/// <summary>
/// pedigree and other certificates
/// </summary>
std::set<utility::string_t>& getCertificates();
bool certificatesIsSet() const;
void unsetCertificates();
void setCertificates(const std::set<utility::string_t>& value);
/// <summary>
///
/// </summary>
std::shared_ptr<Pet_vaccinationBook> getVaccinationBook() const;
bool vaccinationBookIsSet() const;
void unsetVaccinationBook();
void setVaccinationBook(const std::shared_ptr<Pet_vaccinationBook>& value);
protected:
int64_t m_Id;
@ -126,6 +147,10 @@ protected:
bool m_TagsIsSet;
utility::string_t m_Status;
bool m_StatusIsSet;
std::set<utility::string_t> m_Certificates;
bool m_CertificatesIsSet;
std::shared_ptr<Pet_vaccinationBook> m_VaccinationBook;
bool m_VaccinationBookIsSet;
};

View File

@ -0,0 +1,79 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Pet_vaccinationBook.h
*
* Vaccination book of the pet
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include "CppRestPetstoreClient/model/Vaccine.h"
#include <set>
namespace org {
namespace openapitools {
namespace client {
namespace model {
class Vaccine;
/// <summary>
/// Vaccination book of the pet
/// </summary>
class Pet_vaccinationBook
: public ModelBase
{
public:
Pet_vaccinationBook();
virtual ~Pet_vaccinationBook();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Pet_vaccinationBook members
/// <summary>
///
/// </summary>
std::set<std::shared_ptr<Vaccine>>& getVaccines();
bool vaccinesIsSet() const;
void unsetVaccines();
void setVaccines(const std::set<std::shared_ptr<Vaccine>>& value);
protected:
std::set<std::shared_ptr<Vaccine>> m_Vaccines;
bool m_VaccinesIsSet;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_vaccinationBook_H_ */

View File

@ -0,0 +1,88 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Vaccine.h
*
*
*/
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_
#include "CppRestPetstoreClient/ModelBase.h"
#include "CppRestPetstoreClient/AnyType.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
/// <summary>
///
/// </summary>
class Vaccine
: public ModelBase
{
public:
Vaccine();
virtual ~Vaccine();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// Vaccine members
/// <summary>
/// vaccination date
/// </summary>
std::shared_ptr<AnyType> getDate() const;
bool dateIsSet() const;
void unsetdate();
void setDate(const std::shared_ptr<AnyType>& value);
/// <summary>
/// true if a booster is still needed to complete the vaccination
/// </summary>
bool isBoosterRequired() const;
bool boosterRequiredIsSet() const;
void unsetBoosterRequired();
void setBoosterRequired(bool value);
protected:
std::shared_ptr<AnyType> m_date;
bool m_dateIsSet;
bool m_BoosterRequired;
bool m_BoosterRequiredIsSet;
};
}
}
}
}
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_ */

View File

@ -31,6 +31,8 @@ Pet::Pet()
m_TagsIsSet = false;
m_Status = utility::conversions::to_string_t("");
m_StatusIsSet = false;
m_CertificatesIsSet = false;
m_VaccinationBookIsSet = false;
}
Pet::~Pet()
@ -71,6 +73,14 @@ web::json::value Pet::toJson() const
{
val[utility::conversions::to_string_t(U("status"))] = ModelBase::toJson(m_Status);
}
if(m_CertificatesIsSet)
{
val[utility::conversions::to_string_t(U("certificates"))] = ModelBase::toJson(m_Certificates);
}
if(m_VaccinationBookIsSet)
{
val[utility::conversions::to_string_t(U("vaccinationBook"))] = ModelBase::toJson(m_VaccinationBook);
}
return val;
}
@ -139,6 +149,26 @@ bool Pet::fromJson(const web::json::value& val)
setStatus(refVal_setStatus);
}
}
if(val.has_field(utility::conversions::to_string_t(U("certificates"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("certificates")));
if(!fieldValue.is_null())
{
std::set<utility::string_t> refVal_setCertificates;
ok &= ModelBase::fromJson(fieldValue, refVal_setCertificates);
setCertificates(refVal_setCertificates);
}
}
if(val.has_field(utility::conversions::to_string_t(U("vaccinationBook"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccinationBook")));
if(!fieldValue.is_null())
{
std::shared_ptr<Pet_vaccinationBook> refVal_setVaccinationBook;
ok &= ModelBase::fromJson(fieldValue, refVal_setVaccinationBook);
setVaccinationBook(refVal_setVaccinationBook);
}
}
return ok;
}
@ -173,6 +203,14 @@ void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("status")), m_Status));
}
if(m_CertificatesIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("certificates")), m_Certificates));
}
if(m_VaccinationBookIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccinationBook")), m_VaccinationBook));
}
}
bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
@ -220,6 +258,18 @@ bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const util
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("status"))), refVal_setStatus );
setStatus(refVal_setStatus);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("certificates"))))
{
std::set<utility::string_t> refVal_setCertificates;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("certificates"))), refVal_setCertificates );
setCertificates(refVal_setCertificates);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("vaccinationBook"))))
{
std::shared_ptr<Pet_vaccinationBook> refVal_setVaccinationBook;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccinationBook"))), refVal_setVaccinationBook );
setVaccinationBook(refVal_setVaccinationBook);
}
return ok;
}
@ -343,6 +393,46 @@ void Pet::unsetStatus()
{
m_StatusIsSet = false;
}
std::set<utility::string_t>& Pet::getCertificates()
{
return m_Certificates;
}
void Pet::setCertificates(const std::set<utility::string_t>& value)
{
m_Certificates = value;
m_CertificatesIsSet = true;
}
bool Pet::certificatesIsSet() const
{
return m_CertificatesIsSet;
}
void Pet::unsetCertificates()
{
m_CertificatesIsSet = false;
}
std::shared_ptr<Pet_vaccinationBook> Pet::getVaccinationBook() const
{
return m_VaccinationBook;
}
void Pet::setVaccinationBook(const std::shared_ptr<Pet_vaccinationBook>& value)
{
m_VaccinationBook = value;
m_VaccinationBookIsSet = true;
}
bool Pet::vaccinationBookIsSet() const
{
return m_VaccinationBookIsSet;
}
void Pet::unsetVaccinationBook()
{
m_VaccinationBookIsSet = false;
}
}
}
}

View File

@ -0,0 +1,123 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Pet_vaccinationBook.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
Pet_vaccinationBook::Pet_vaccinationBook()
{
m_VaccinesIsSet = false;
}
Pet_vaccinationBook::~Pet_vaccinationBook()
{
}
void Pet_vaccinationBook::validate()
{
// TODO: implement validation
}
web::json::value Pet_vaccinationBook::toJson() const
{
web::json::value val = web::json::value::object();
if(m_VaccinesIsSet)
{
val[utility::conversions::to_string_t(U("vaccines"))] = ModelBase::toJson(m_Vaccines);
}
return val;
}
bool Pet_vaccinationBook::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("vaccines"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("vaccines")));
if(!fieldValue.is_null())
{
std::set<std::shared_ptr<Vaccine>> refVal_setVaccines;
ok &= ModelBase::fromJson(fieldValue, refVal_setVaccines);
setVaccines(refVal_setVaccines);
}
}
return ok;
}
void Pet_vaccinationBook::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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_VaccinesIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("vaccines")), m_Vaccines));
}
}
bool Pet_vaccinationBook::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("vaccines"))))
{
std::set<std::shared_ptr<Vaccine>> refVal_setVaccines;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("vaccines"))), refVal_setVaccines );
setVaccines(refVal_setVaccines);
}
return ok;
}
std::set<std::shared_ptr<Vaccine>>& Pet_vaccinationBook::getVaccines()
{
return m_Vaccines;
}
void Pet_vaccinationBook::setVaccines(const std::set<std::shared_ptr<Vaccine>>& value)
{
m_Vaccines = value;
m_VaccinesIsSet = true;
}
bool Pet_vaccinationBook::vaccinesIsSet() const
{
return m_VaccinesIsSet;
}
void Pet_vaccinationBook::unsetVaccines()
{
m_VaccinesIsSet = false;
}
}
}
}
}

View File

@ -0,0 +1,169 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
* NOTE: This class is auto generated by OpenAPI-Generator 7.6.0-SNAPSHOT.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "CppRestPetstoreClient/model/Vaccine.h"
namespace org {
namespace openapitools {
namespace client {
namespace model {
Vaccine::Vaccine()
{
m_dateIsSet = false;
m_BoosterRequired = false;
m_BoosterRequiredIsSet = false;
}
Vaccine::~Vaccine()
{
}
void Vaccine::validate()
{
// TODO: implement validation
}
web::json::value Vaccine::toJson() const
{
web::json::value val = web::json::value::object();
if(m_dateIsSet)
{
val[utility::conversions::to_string_t(U("date"))] = ModelBase::toJson(m_date);
}
if(m_BoosterRequiredIsSet)
{
val[utility::conversions::to_string_t(U("boosterRequired"))] = ModelBase::toJson(m_BoosterRequired);
}
return val;
}
bool Vaccine::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t(U("date"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("date")));
if(!fieldValue.is_null())
{
std::shared_ptr<AnyType> refVal_setDate;
ok &= ModelBase::fromJson(fieldValue, refVal_setDate);
setDate(refVal_setDate);
}
}
if(val.has_field(utility::conversions::to_string_t(U("boosterRequired"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(U("boosterRequired")));
if(!fieldValue.is_null())
{
bool refVal_setBoosterRequired;
ok &= ModelBase::fromJson(fieldValue, refVal_setBoosterRequired);
setBoosterRequired(refVal_setBoosterRequired);
}
}
return ok;
}
void Vaccine::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(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(m_dateIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("date")), m_date));
}
if(m_BoosterRequiredIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(U("boosterRequired")), m_BoosterRequired));
}
}
bool Vaccine::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
bool ok = true;
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t(U(".")))
{
namePrefix += utility::conversions::to_string_t(U("."));
}
if(multipart->hasContent(utility::conversions::to_string_t(U("date"))))
{
std::shared_ptr<AnyType> refVal_setDate;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("date"))), refVal_setDate );
setDate(refVal_setDate);
}
if(multipart->hasContent(utility::conversions::to_string_t(U("boosterRequired"))))
{
bool refVal_setBoosterRequired;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(U("boosterRequired"))), refVal_setBoosterRequired );
setBoosterRequired(refVal_setBoosterRequired);
}
return ok;
}
std::shared_ptr<AnyType> Vaccine::getDate() const
{
return m_date;
}
void Vaccine::setDate(const std::shared_ptr<AnyType>& value)
{
m_date = value;
m_dateIsSet = true;
}
bool Vaccine::dateIsSet() const
{
return m_dateIsSet;
}
void Vaccine::unsetdate()
{
m_dateIsSet = false;
}
bool Vaccine::isBoosterRequired() const
{
return m_BoosterRequired;
}
void Vaccine::setBoosterRequired(bool value)
{
m_BoosterRequired = value;
m_BoosterRequiredIsSet = true;
}
bool Vaccine::boosterRequiredIsSet() const
{
return m_BoosterRequiredIsSet;
}
void Vaccine::unsetBoosterRequired()
{
m_BoosterRequiredIsSet = false;
}
}
}
}
}

View File

@ -24,9 +24,11 @@ model/Order.cpp
model/Order.h
model/Pet.cpp
model/Pet.h
model/Pet_bestFriends.cpp
model/Pet_bestFriends.h
model/Pet_vaccinationBook.cpp
model/Pet_vaccinationBook.h
model/Tag.cpp
model/Tag.h
model/User.cpp
model/User.h
model/Vaccine.cpp
model/Vaccine.h

View File

@ -23,6 +23,7 @@
#include <sstream>
#include <vector>
#include <map>
#include <set>
namespace org::openapitools::server::helpers
{
@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers
return true;
}
/// <summary>
/// Determine if the given vector<T> only has unique elements. T must provide the == operator.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::set<T>& set)
{
return true;
}
std::string toStringValue(const std::string &value);
std::string toStringValue(const int32_t value);
std::string toStringValue(const int64_t value);

View File

@ -30,7 +30,8 @@ Pet::Pet()
m_StatusIsSet = false;
m_VeterinarianVisitIsSet = false;
m_GoodiesIsSet = false;
m_BestFriendsIsSet = false;
m_CertificatesIsSet = false;
m_VaccinationBookIsSet = false;
}
@ -111,6 +112,32 @@ bool Pet::validate(std::stringstream& msg, const std::string& pathPrefix) const
i++;
}
}
}
if (certificatesIsSet())
{
const std::set<std::string>& value = m_Certificates;
const std::string currentValuePath = _pathPrefix + ".certificates";
if (!org::openapitools::server::helpers::hasOnlyUniqueItems(value))
{
success = false;
msg << currentValuePath << ": may not contain the same item more than once;";
}
{ // Recursive validation of array elements
const std::string oldValuePath = currentValuePath;
int i = 0;
for (const std::string& value : value)
{
const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]";
i++;
}
}
@ -150,7 +177,10 @@ bool Pet::operator==(const Pet& rhs) const
((!goodiesIsSet() && !rhs.goodiesIsSet()) || (goodiesIsSet() && rhs.goodiesIsSet() && getGoodies() == rhs.getGoodies())) &&
((!bestFriendsIsSet() && !rhs.bestFriendsIsSet()) || (bestFriendsIsSet() && rhs.bestFriendsIsSet() && getBestFriends() == rhs.getBestFriends()))
((!certificatesIsSet() && !rhs.certificatesIsSet()) || (certificatesIsSet() && rhs.certificatesIsSet() && getCertificates() == rhs.getCertificates())) &&
((!vaccinationBookIsSet() && !rhs.vaccinationBookIsSet()) || (vaccinationBookIsSet() && rhs.vaccinationBookIsSet() && getVaccinationBook() == rhs.getVaccinationBook()))
;
}
@ -177,8 +207,10 @@ void to_json(nlohmann::json& j, const Pet& o)
j["veterinarianVisit"] = o.m_VeterinarianVisit;
if(o.goodiesIsSet() || !o.m_Goodies.empty())
j["goodies"] = o.m_Goodies;
if(o.bestFriendsIsSet())
j["bestFriends"] = o.m_BestFriends;
if(o.certificatesIsSet() || !o.m_Certificates.empty())
j["certificates"] = o.m_Certificates;
if(o.vaccinationBookIsSet())
j["vaccinationBook"] = o.m_VaccinationBook;
}
@ -216,10 +248,15 @@ void from_json(const nlohmann::json& j, Pet& o)
j.at("goodies").get_to(o.m_Goodies);
o.m_GoodiesIsSet = true;
}
if(j.find("bestFriends") != j.end())
if(j.find("certificates") != j.end())
{
j.at("bestFriends").get_to(o.m_BestFriends);
o.m_BestFriendsIsSet = true;
j.at("certificates").get_to(o.m_Certificates);
o.m_CertificatesIsSet = true;
}
if(j.find("vaccinationBook") != j.end())
{
j.at("vaccinationBook").get_to(o.m_VaccinationBook);
o.m_VaccinationBookIsSet = true;
}
}
@ -342,22 +379,39 @@ void Pet::unsetGoodies()
{
m_GoodiesIsSet = false;
}
org::openapitools::server::model::Pet_bestFriends Pet::getBestFriends() const
std::set<std::string> Pet::getCertificates() const
{
return m_BestFriends;
return m_Certificates;
}
void Pet::setBestFriends(org::openapitools::server::model::Pet_bestFriends const& value)
void Pet::setCertificates(std::set<std::string> const& value)
{
m_BestFriends = value;
m_BestFriendsIsSet = true;
m_Certificates = value;
m_CertificatesIsSet = true;
}
bool Pet::bestFriendsIsSet() const
bool Pet::certificatesIsSet() const
{
return m_BestFriendsIsSet;
return m_CertificatesIsSet;
}
void Pet::unsetBestFriends()
void Pet::unsetCertificates()
{
m_BestFriendsIsSet = false;
m_CertificatesIsSet = false;
}
org::openapitools::server::model::Pet_vaccinationBook Pet::getVaccinationBook() const
{
return m_VaccinationBook;
}
void Pet::setVaccinationBook(org::openapitools::server::model::Pet_vaccinationBook const& value)
{
m_VaccinationBook = value;
m_VaccinationBookIsSet = true;
}
bool Pet::vaccinationBookIsSet() const
{
return m_VaccinationBookIsSet;
}
void Pet::unsetVaccinationBook()
{
m_VaccinationBookIsSet = false;
}

View File

@ -21,10 +21,11 @@
#include "Tag.h"
#include <nlohmann/json.hpp>
#include "Pet_bestFriends.h"
#include "Pet_vaccinationBook.h"
#include <string>
#include "Category.h"
#include <vector>
#include <set>
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
@ -116,12 +117,19 @@ public:
bool goodiesIsSet() const;
void unsetGoodies();
/// <summary>
/// pedigree and other certificates
/// </summary>
std::set<std::string> getCertificates() const;
void setCertificates(std::set<std::string> const& value);
bool certificatesIsSet() const;
void unsetCertificates();
/// <summary>
///
/// </summary>
org::openapitools::server::model::Pet_bestFriends getBestFriends() const;
void setBestFriends(org::openapitools::server::model::Pet_bestFriends const& value);
bool bestFriendsIsSet() const;
void unsetBestFriends();
org::openapitools::server::model::Pet_vaccinationBook getVaccinationBook() const;
void setVaccinationBook(org::openapitools::server::model::Pet_vaccinationBook const& value);
bool vaccinationBookIsSet() const;
void unsetVaccinationBook();
friend void to_json(nlohmann::json& j, const Pet& o);
friend void from_json(const nlohmann::json& j, Pet& o);
@ -142,8 +150,10 @@ protected:
bool m_VeterinarianVisitIsSet;
std::vector<nlohmann::json> m_Goodies;
bool m_GoodiesIsSet;
org::openapitools::server::model::Pet_bestFriends m_BestFriends;
bool m_BestFriendsIsSet;
std::set<std::string> m_Certificates;
bool m_CertificatesIsSet;
org::openapitools::server::model::Pet_vaccinationBook m_VaccinationBook;
bool m_VaccinationBookIsSet;
};

View File

@ -0,0 +1,116 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Pet_vaccinationBook.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
Pet_vaccinationBook::Pet_vaccinationBook()
{
}
void Pet_vaccinationBook::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool Pet_vaccinationBook::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool Pet_vaccinationBook::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Pet_vaccinationBook" : pathPrefix;
/* Vaccines */ {
const std::set<org::openapitools::server::model::Vaccine>& value = m_Vaccines;
const std::string currentValuePath = _pathPrefix + ".vaccines";
if (!org::openapitools::server::helpers::hasOnlyUniqueItems(value))
{
success = false;
msg << currentValuePath << ": may not contain the same item more than once;";
}
{ // Recursive validation of array elements
const std::string oldValuePath = currentValuePath;
int i = 0;
for (const org::openapitools::server::model::Vaccine& value : value)
{
const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]";
success = value.validate(msg, currentValuePath + ".vaccines") && success;
i++;
}
}
}
return success;
}
bool Pet_vaccinationBook::operator==(const Pet_vaccinationBook& rhs) const
{
return
(getVaccines() == rhs.getVaccines())
;
}
bool Pet_vaccinationBook::operator!=(const Pet_vaccinationBook& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const Pet_vaccinationBook& o)
{
j = nlohmann::json::object();
j["vaccines"] = o.m_Vaccines;
}
void from_json(const nlohmann::json& j, Pet_vaccinationBook& o)
{
j.at("vaccines").get_to(o.m_Vaccines);
}
std::set<org::openapitools::server::model::Vaccine> Pet_vaccinationBook::getVaccines() const
{
return m_Vaccines;
}
void Pet_vaccinationBook::setVaccines(std::set<org::openapitools::server::model::Vaccine> const& value)
{
m_Vaccines = value;
}
} // namespace org::openapitools::server::model

View File

@ -0,0 +1,78 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Pet_vaccinationBook.h
*
* Vaccination book of the pet
*/
#ifndef Pet_vaccinationBook_H_
#define Pet_vaccinationBook_H_
#include "Vaccine.h"
#include <set>
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
{
/// <summary>
/// Vaccination book of the pet
/// </summary>
class Pet_vaccinationBook
{
public:
Pet_vaccinationBook();
virtual ~Pet_vaccinationBook() = default;
/// <summary>
/// Validate the current data in the model. Throws a ValidationException on failure.
/// </summary>
void validate() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes an error
/// message into the given stringstream.
/// </summary>
bool validate(std::stringstream& msg) const;
/// <summary>
/// Helper overload for validate. Used when one model stores another model and calls it's validate.
/// Not meant to be called outside that case.
/// </summary>
bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
bool operator==(const Pet_vaccinationBook& rhs) const;
bool operator!=(const Pet_vaccinationBook& rhs) const;
/////////////////////////////////////////////
/// Pet_vaccinationBook members
/// <summary>
///
/// </summary>
std::set<org::openapitools::server::model::Vaccine> getVaccines() const;
void setVaccines(std::set<org::openapitools::server::model::Vaccine> const& value);
friend void to_json(nlohmann::json& j, const Pet_vaccinationBook& o);
friend void from_json(const nlohmann::json& j, Pet_vaccinationBook& o);
protected:
std::set<org::openapitools::server::model::Vaccine> m_Vaccines;
};
} // namespace org::openapitools::server::model
#endif /* Pet_vaccinationBook_H_ */

View File

@ -0,0 +1,104 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Vaccine.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
Vaccine::Vaccine()
{
m_BoosterRequired = false;
}
void Vaccine::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool Vaccine::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool Vaccine::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "Vaccine" : pathPrefix;
return success;
}
bool Vaccine::operator==(const Vaccine& rhs) const
{
return
(getDate() == rhs.getDate())
&&
(isBoosterRequired() == rhs.isBoosterRequired())
;
}
bool Vaccine::operator!=(const Vaccine& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const Vaccine& o)
{
j = nlohmann::json::object();
j["date"] = o.m_date;
j["boosterRequired"] = o.m_BoosterRequired;
}
void from_json(const nlohmann::json& j, Vaccine& o)
{
j.at("date").get_to(o.m_date);
j.at("boosterRequired").get_to(o.m_BoosterRequired);
}
nlohmann::json Vaccine::getDate() const
{
return m_date;
}
void Vaccine::setDate(nlohmann::json const& value)
{
m_date = value;
}
bool Vaccine::isBoosterRequired() const
{
return m_BoosterRequired;
}
void Vaccine::setBoosterRequired(bool const value)
{
m_BoosterRequired = value;
}
} // namespace org::openapitools::server::model

View File

@ -0,0 +1,84 @@
/**
* 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.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Vaccine.h
*
*
*/
#ifndef Vaccine_H_
#define Vaccine_H_
#include <nlohmann/json.hpp>
#include <nlohmann/json.hpp>
namespace org::openapitools::server::model
{
/// <summary>
///
/// </summary>
class Vaccine
{
public:
Vaccine();
virtual ~Vaccine() = default;
/// <summary>
/// Validate the current data in the model. Throws a ValidationException on failure.
/// </summary>
void validate() const;
/// <summary>
/// Validate the current data in the model. Returns false on error and writes an error
/// message into the given stringstream.
/// </summary>
bool validate(std::stringstream& msg) const;
/// <summary>
/// Helper overload for validate. Used when one model stores another model and calls it's validate.
/// Not meant to be called outside that case.
/// </summary>
bool validate(std::stringstream& msg, const std::string& pathPrefix) const;
bool operator==(const Vaccine& rhs) const;
bool operator!=(const Vaccine& rhs) const;
/////////////////////////////////////////////
/// Vaccine members
/// <summary>
/// vaccination date
/// </summary>
nlohmann::json getDate() const;
void setDate(nlohmann::json const& value);
/// <summary>
/// true if a booster is still needed to complete the vaccination
/// </summary>
bool isBoosterRequired() const;
void setBoosterRequired(bool const value);
friend void to_json(nlohmann::json& j, const Vaccine& o);
friend void from_json(const nlohmann::json& j, Vaccine& o);
protected:
nlohmann::json m_date;
bool m_BoosterRequired;
};
} // namespace org::openapitools::server::model
#endif /* Vaccine_H_ */

View File

@ -23,6 +23,7 @@
#include <sstream>
#include <vector>
#include <map>
#include <set>
namespace org::openapitools::server::helpers
{
@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers
return true;
}
/// <summary>
/// Determine if the given vector<T> only has unique elements. T must provide the == operator.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::set<T>& set)
{
return true;
}
std::string toStringValue(const std::string &value);
std::string toStringValue(const int32_t value);
std::string toStringValue(const int64_t value);

View File

@ -23,6 +23,7 @@
#include <sstream>
#include <vector>
#include <map>
#include <set>
namespace org::openapitools::server::helpers
{
@ -92,6 +93,15 @@ namespace org::openapitools::server::helpers
return true;
}
/// <summary>
/// Determine if the given vector<T> only has unique elements. T must provide the == operator.
/// </summary>
template <typename T>
bool hasOnlyUniqueItems(const std::set<T>& set)
{
return true;
}
std::string toStringValue(const std::string &value);
std::string toStringValue(const int32_t value);
std::string toStringValue(const int64_t value);